Skip to content

Commit

Permalink
Merge PR #180 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by sbidoul
  • Loading branch information
OCA-git-bot committed Feb 11, 2024
2 parents 0afea76 + 77b83d1 commit 47d20d2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion product_search_multi_value/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import product_template
from . import product
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
_logger = logging.getLogger(__name__)


class ProductTemplate(models.Model):

_inherit = "product.template"
class ProductSearchMultiMixin(models.AbstractModel):
_name = "product.search.multi.mixin"
_description = "Product search multi value mixin"

search_multi = fields.Char(
"Multiple search",
Expand Down Expand Up @@ -52,3 +52,13 @@ def _search_multi(self, operator, value):
domain_search_field = [(search_field, operator, tuple(value_list))]
domain_list.append(domain_search_field)
return comparator(domain_list)


class ProductTemplate(models.Model):
_inherit = ["product.template", "product.search.multi.mixin"]
_name = "product.template"


class ProductProduct(models.Model):
_inherit = ["product.product", "product.search.multi.mixin"]
_name = "product.product"
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ def test_search_multi_value(self):
domain = [("search_multi", "!=", default_code_values)]
with self.assertRaises(UserError):
self.env["product.template"].search_count(domain)

def test_variant_search_multi_value(self):
default_code_values = " FURN_0096 FURN_0097 FURN_0098"
domain = [("search_multi", "ilike", default_code_values)]
res = self.env["product.product"].search_count(domain)
self.assertEqual(res, 3)

0 comments on commit 47d20d2

Please sign in to comment.