diff --git a/nfu_ecommerce/README.rst b/nfu_ecommerce/README.rst
index 68cbf26..5fef683 100644
--- a/nfu_ecommerce/README.rst
+++ b/nfu_ecommerce/README.rst
@@ -37,6 +37,7 @@ Changelog
:0.0.1: Initial module.
:1.0.0: Live
+:1.1.0: Add Open Packagings Filter
Bug Tracker
===========
diff --git a/nfu_ecommerce/__manifest__.py b/nfu_ecommerce/__manifest__.py
index 12d756c..72f20fe 100644
--- a/nfu_ecommerce/__manifest__.py
+++ b/nfu_ecommerce/__manifest__.py
@@ -4,7 +4,7 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "website",
- "version": "16.0.1.0.0",
+ "version": "16.0.1.1.0",
"depends": ["website_sale", "nfu_sale_order_batch_packaging", "website_decimal_quantity"],
"data": ["views/product_template_views.xml", "views/templates.xml"],
"assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]},
diff --git a/nfu_ecommerce/controllers/main.py b/nfu_ecommerce/controllers/main.py
index 6f80ec1..52dc815 100644
--- a/nfu_ecommerce/controllers/main.py
+++ b/nfu_ecommerce/controllers/main.py
@@ -1,4 +1,5 @@
from odoo import fields, http
+from odoo.http import request
from odoo.addons.website_sale.controllers.main import WebsiteSale
@@ -10,3 +11,43 @@ class WebsiteSaleMinMax(WebsiteSale):
product_uom_ordered_qty = fields.Float(ordered_qty)
product_uom_max_qty = fields.Float(max_qty)
return super().cart_update(*args, ordered_qty=product_uom_ordered_qty, max_qty=product_uom_max_qty, **kw)
+
+
+class WebsiteSale(WebsiteSale):
+ def _get_search_options(
+ self, category=None, attrib_values=None, pricelist=None, min_price=0.0, max_price=0.0, conversion_rate=1, **post
+ ):
+ res = super()._get_search_options(
+ category=category,
+ attrib_values=attrib_values,
+ pricelist=pricelist,
+ min_price=min_price,
+ max_price=max_price,
+ conversion_rate=conversion_rate,
+ **post
+ )
+ res["open_product_ids"] = post.get("open_product_ids")
+ return res
+
+ @http.route(
+ [
+ "/shop",
+ "/shop/page/",
+ '/shop/category/',
+ '/shop/category//page/',
+ ],
+ type="http",
+ auth="public",
+ website=True,
+ )
+ def shop(self, page=0, category=None, search="", min_price=0.0, max_price=0.0, ppg=False, **post):
+ if post.get("open_packagings"):
+ batch = request.website.sale_get_order(force_create=True).batch_id
+ open_product_ids = (
+ batch.product_ids.filtered(lambda p: p.open_packaging_qty > 0).mapped("product_template_id").ids
+ )
+ post["open_product_ids"] = open_product_ids
+ else:
+ post["open_product_ids"] = []
+ res = super().shop(page=0, category=None, search="", min_price=0.0, max_price=0.0, ppg=False, **post)
+ return res
diff --git a/nfu_ecommerce/models/product_template.py b/nfu_ecommerce/models/product_template.py
index b785776..ab096e6 100644
--- a/nfu_ecommerce/models/product_template.py
+++ b/nfu_ecommerce/models/product_template.py
@@ -11,3 +11,11 @@ class ProductTemplate(models.Model):
def action_unpublish_on_website(self):
for product in self:
product.is_published = False
+
+ def _search_get_detail(self, website, order, options):
+ search_details = super()._search_get_detail(website, order, options)
+ open_product_ids = options.get("open_product_ids")
+ domain = search_details["base_domain"]
+ if len(open_product_ids):
+ domain.append([("id", "in", tuple(open_product_ids))])
+ return search_details
diff --git a/nfu_ecommerce/readme/HISTORY.rst b/nfu_ecommerce/readme/HISTORY.rst
index e9a3e7c..f8cb7c8 100644
--- a/nfu_ecommerce/readme/HISTORY.rst
+++ b/nfu_ecommerce/readme/HISTORY.rst
@@ -1,2 +1,3 @@
:0.0.1: Initial module.
-:1.0.0: Live
\ No newline at end of file
+:1.0.0: Live
+:1.1.0: Add Open Packagings Filter
\ No newline at end of file
diff --git a/nfu_ecommerce/static/description/index.html b/nfu_ecommerce/static/description/index.html
index 6d36996..e1e683a 100644
--- a/nfu_ecommerce/static/description/index.html
+++ b/nfu_ecommerce/static/description/index.html
@@ -397,6 +397,8 @@ and after the current order.
| 1.0.0: | Live |
+| 1.1.0: | Add Open Packagings Filter |
+
diff --git a/nfu_ecommerce/views/templates.xml b/nfu_ecommerce/views/templates.xml
index 0b7b619..aa1070e 100644
--- a/nfu_ecommerce/views/templates.xml
+++ b/nfu_ecommerce/views/templates.xml
@@ -1,5 +1,24 @@
+
+
+
+
+ Open Packagings
+
+
+
+
+
+
+
+
+
+
diff --git a/nfu_sale_order_batch_packaging/models/sale_order_batch_product.py b/nfu_sale_order_batch_packaging/models/sale_order_batch_product.py
index f2c3cb8..db0a8db 100644
--- a/nfu_sale_order_batch_packaging/models/sale_order_batch_product.py
+++ b/nfu_sale_order_batch_packaging/models/sale_order_batch_product.py
@@ -4,7 +4,7 @@ from odoo import api, fields, models
class SaleOrderBatchProduct(models.Model):
_inherit = "sale.order.batch.product"
- open_packaging_qty = fields.Float(compute="_compute_open_packagin_qty")
+ open_packaging_qty = fields.Float(compute="_compute_open_packagin_qty", store=True)
@api.depends("sale_order_line_ids.product_uom_qty")
def _compute_open_packagin_qty(self):