Skip to content

Commit

Permalink
[FIX] product: Variants settings on specific test
Browse files Browse the repository at this point in the history
Some tests on dynamic variants mechanism didn't pass on test
without demo data due to odoo#143543.

closes odoo#159709

Signed-off-by: Benjamin Hanquin (beha) <beha@odoo.com>
  • Loading branch information
beha-odoo committed Mar 28, 2024
1 parent 432ae64 commit a949ae1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/product/tests/test_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def test_default_code_and_negative_operator(self):
self.assertNotIn(self.product.id, res_ids)

def test_product_template_search_name_no_product_product(self):
# To be able to test dynamic variant "variants" feature must be set up
self.env.user.write({'groups_id': [(4, self.env.ref('product.group_product_variant').id)]})
color_attr = self.env['product.attribute'].create({'name': 'Color', 'create_variant': 'dynamic'})
color_attr_value_r = self.env['product.attribute.value'].create({'name': 'Red', 'attribute_id': color_attr.id})
color_attr_value_b = self.env['product.attribute.value'].create({'name': 'Blue', 'attribute_id': color_attr.id})
Expand Down
2 changes: 2 additions & 0 deletions addons/product/tests/test_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,8 @@ def unlink(slef):
Product._revert_method('unlink')

def test_name_search_dynamic_attributes(self):
# To be able to test dynamic variant "variants" feature must be set up
self.env.user.write({'groups_id': [(4, self.env.ref('product.group_product_variant').id)]})
dynamic_attr = self.env['product.attribute'].create({
'name': 'Dynamic',
'create_variant': 'dynamic',
Expand Down
2 changes: 2 additions & 0 deletions addons/stock/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def test_search_product_template(self):
calling `name_search` with a negative operator will exclude T from the
result.
"""
# To be able to test dynamic variant "variants" feature must be set up
self.env.user.write({'groups_id': [(4, self.env.ref('product.group_product_variant').id)]})
template = self.env['product.template'].create({
'name': 'Super Product',
})
Expand Down

0 comments on commit a949ae1

Please sign in to comment.