[IMP] nfu_ecommerce: Make attribute selection an AND-filter

This commit is contained in:
Niels Göttsch 2026-05-26 08:59:39 +02:00 committed by madmooose
parent 7e63a17abc
commit f913eac312
6 changed files with 26 additions and 3 deletions

View file

@ -57,6 +57,7 @@ Changelog
- 16.0.1.4.3: Drop session if SO belongs to another website (Odoo 16 bug)
- 16.0.1.4.3: Remove is_published filtering and use job manager only on more than one
- 16.0.1.4.5: Make open Packagings more visible
- 16.0.1.5.0: Make attribute selection an AND-filter
Bug Tracker
===========

View file

@ -4,7 +4,7 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "website",
"version": "16.0.1.4.5",
"version": "16.0.1.5.0",
"depends": [
"sale_product_configurator",
"website_sale",

View file

@ -1,5 +1,6 @@
from odoo import fields, http
from odoo.http import request
from odoo.osv import expression
from odoo.tools import lazy
from odoo.addons.website_sale.controllers.main import WebsiteSale
@ -73,6 +74,18 @@ class WebsiteSale(WebsiteSale):
new_values["packaging_info"] = packaging_info
return new_values
def _get_search_domain(
self, search, category, attrib_values, search_in_description=True
):
# AND across all selected attribute values instead of OR within same attribute
domain = super()._get_search_domain(search, category, [], search_in_description)
if attrib_values:
attr_domains = [
[("attribute_line_ids.value_ids", "in", [v[1]])] for v in attrib_values
]
domain = expression.AND([domain] + attr_domains)
return domain
def _get_search_order(self, post):
# is_published is company_dependent and has no DB column, so it cannot
# be used in ORDER BY. The shop domain already filters published products,

View file

@ -20,9 +20,16 @@ class ProductTemplate(models.Model):
product.is_published = False
def _search_get_detail(self, website, order, options):
search_details = super()._search_get_detail(website, order, options)
# Pass attrib_values as empty so the parent builds no attribute filter,
# then add one condition per value to enforce AND semantics.
attrib_values = options.get("attrib_values")
patched_options = dict(options, attrib_values=[]) if attrib_values else options
search_details = super()._search_get_detail(website, order, patched_options)
open_product_ids = options.get("open_product_ids")
domain = search_details["base_domain"]
if open_product_ids is not None:
domain.append([("id", "in", tuple(open_product_ids))])
if attrib_values:
for value in attrib_values:
domain.append([("attribute_line_ids.value_ids", "in", [value[1]])])
return search_details

View file

@ -13,3 +13,4 @@
- 16.0.1.4.3: Drop session if SO belongs to another website (Odoo 16 bug)
- 16.0.1.4.3: Remove is_published filtering and use job manager only on more than one
- 16.0.1.4.5: Make open Packagings more visible
- 16.0.1.5.0: Make attribute selection an AND-filter

View file

@ -413,6 +413,7 @@ adjustes the uom quantitiy</li>
<li>16.0.1.4.3: Drop session if SO belongs to another website (Odoo 16 bug)</li>
<li>16.0.1.4.3: Remove is_published filtering and use job manager only on more than one</li>
<li>16.0.1.4.5: Make open Packagings more visible</li>
<li>16.0.1.5.0: Make attribute selection an AND-filter</li>
</ul>
</div>
<div class="section" id="bug-tracker">