Skip to content

Commit

Permalink
[FIX] product_abc_classification: Use the good _for_xml_id() and add …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
rousseldenis committed Nov 17, 2022
1 parent 340dffd commit 2bc9ee1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def _compute_product_count(self):

def action_view_products(self):
products = self.mapped("product_variant_ids")
action = self.env["ir.actions.act_window"].for_xml_id(
"product", "product_variant_action"
action = self.env["ir.actions.act_window"]._for_xml_id(
"product.product_variant_action"
)
del action["context"]
if len(products) > 1:
Expand Down
30 changes: 30 additions & 0 deletions product_abc_classification/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,33 @@ def test_03(self):
product_level,
)
self.assertFalse(self.product_template.abc_classification_product_level_ids)

def test_04(self):
"""
Data:
A product template
Test case:
Check if resource id in action is the product variant one
"""
self.product_template.abc_classification_profile_ids = (
self.classification_profile
)
action = self.classification_profile.action_view_products()
self.assertEqual(action["res_id"], self.product_template.product_variant_ids.id)

def test_05(self):
"""
Data:
A product template with two variants
Test case:
Check if doamin in action is the product variants ids
"""
self._create_variant(self.size_attr_value_m)
self.product_template.product_variant_ids.abc_classification_profile_ids = (
self.classification_profile
)
action = self.classification_profile.action_view_products()
self.assertEqual(
action["domain"],
[("id", "in", self.product_template.product_variant_ids.ids)],
)

0 comments on commit 2bc9ee1

Please sign in to comment.