-
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pt_multi_link: improve UX by searching templates on default_code
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from . import test_product_template_link_type | ||
from . import test_product_template_link | ||
from . import test_product_template_linker | ||
from . import test_product_template |
50 changes: 50 additions & 0 deletions
50
product_template_multi_link/tests/test_product_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo.tests.common import SavepointCase | ||
|
||
|
||
class TestProductTemplate(SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.env = cls.env( | ||
context=dict( | ||
cls.env.context, | ||
tracking_disable=True, | ||
# compatibility flag when you run tests on a db | ||
# where `product_variant_multi_link` is installed. | ||
_product_variant_link_bypass_check=True, | ||
) | ||
) | ||
cls.product_template = cls.env["product.template"].create( | ||
{"name": "PTL_name", "default_code": "PTL_default_code"} | ||
) | ||
|
||
def test_product_template_name_search_with_name(self): | ||
# As soon as the value is matching the name of the template, it's working, | ||
# with or without the domain on 'id' | ||
product = self.env["product.template"].name_search("PTL_name") | ||
self.assertTrue(product) | ||
product = self.env["product.template"].name_search( | ||
"PTL_name", args=[("id", "!=", 0)] | ||
) | ||
self.assertTrue(product) | ||
product = self.env["product.template"].with_context(name_search_default_code=True).name_search( | ||
"PTL_name", args=[("id", "!=", 0)] | ||
) | ||
self.assertTrue(product) | ||
|
||
def test_product_template_name_search_with_default_code(self): | ||
product = self.env["product.template"].name_search("PTL_default_code") | ||
self.assertTrue(product) | ||
# Searching with the default_code => the template is not found | ||
product = self.env["product.template"].name_search( | ||
"PTL_default_code", args=[("id", "!=", 0)] | ||
) | ||
self.assertFalse(product) | ||
# Same but enable the search on default_code => the template is now found | ||
product = self.env["product.template"].with_context(name_search_default_code=True).name_search( | ||
"PTL_default_code", args=[("id", "!=", 0)] | ||
) | ||
self.assertTrue(product) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters