[FIX] product_category_tax: onchange method name shouldn't be too generic

Unless it's an override, onchange method names can't be too generic, otherwise
it has a high risk of unadvertedly overwriting another module's method.
This commit is contained in:
Ivàn Todorovich
2022-06-30 15:11:52 -03:00
parent aa9708c05d
commit 7bdf221081
3 changed files with 4 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ class ProductProduct(models.Model):
_inherit = "product.product"
@api.onchange("categ_id")
def onchange_categ_id(self):
def _onchange_categ_id_set_taxes(self):
if self.categ_id:
self.set_tax_from_category()

View File

@@ -10,7 +10,7 @@ class ProductTemplate(models.Model):
taxes_updeatable_from_category = fields.Boolean(default=True)
@api.onchange("categ_id")
def onchange_categ_id(self):
def _onchange_categ_id_set_taxes(self):
if self.categ_id:
self.set_tax_from_category()

View File

@@ -52,8 +52,8 @@ class ProductCategoryTax(common.SavepointCase):
self.product_test = self.product_obj.create(
{"name": "TEST 01", "categ_id": test_categ.id, "list_price": 155.0}
)
self.product_test.product_tmpl_id.onchange_categ_id()
self.assertEqual(self.product_test.supplier_taxes_id, self.tax_purchase)
self.product_test.product_tmpl_id._onchange_categ_id_set_taxes()
self.assertEquals(self.product_test.supplier_taxes_id, self.tax_purchase)
def test_02_update_taxes(self):
"""Default update"""