diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2019-08-29 08:25:18 +0000 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2019-08-29 10:19:47 +0000 |
| commit | 21ae503cf401afe4dddae6225fd346f89a210aeb (patch) | |
| tree | 316bcfa6a9cbf7feb1e2ad874961da76bda10bd2 /addons/product/tests | |
| parent | 3950702c86733f52fb373d55a0898baf593de239 (diff) | |
[FIX] product: name search on dynamic product template
Have a product template, assign a dynamic attribute to
(the corresponding variant will be created when used in a SO)
Try to name_search for it
e.g.: in the product configurator modal, type some letters to catch it in theory
Before this commit, the product template was not found by the name search
this is because the template doesn't have any variant yet
After this commit, it is found by the name search
OPW 2060603
closes odoo/odoo#36215
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Diffstat (limited to 'addons/product/tests')
| -rw-r--r-- | addons/product/tests/test_variants.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/product/tests/test_variants.py b/addons/product/tests/test_variants.py index 251996a2526..97323a0cee3 100644 --- a/addons/product/tests/test_variants.py +++ b/addons/product/tests/test_variants.py @@ -817,3 +817,25 @@ class TestVariantsArchive(common.TestProductCommon): "We should have re-activated one variant only.") Product._revert_method('unlink') + + def test_name_search_dynamic_attributes(self): + dynamic_attr = self.env['product.attribute'].create({ + 'name': 'Dynamic', + 'create_variant': 'dynamic', + 'value_ids': [(0, False, {'name': 'ValueDynamic'})], + }) + template = self.env['product.template'].create({ + 'name': 'cimanyd' + }) + self.assertEqual(len(template.product_variant_ids), 1) + + template.write({ + 'attribute_line_ids': [(0, False, { + 'attribute_id': dynamic_attr.id, + 'value_ids': [(4, dynamic_attr.value_ids[0].id, False)], + })] + }) + self.assertEqual(len(template.product_variant_ids), 0) + + name_searched = self.env['product.template'].name_search(name='cima') + self.assertIn(template.id, [ng[0] for ng in name_searched]) |
