From 7bdf221081ebc450ee4277ffbca945db651819f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A0n=20Todorovich?= Date: Thu, 30 Jun 2022 15:11:52 -0300 Subject: [PATCH] [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. --- product_category_tax/models/product_product.py | 2 +- product_category_tax/models/product_template.py | 2 +- product_category_tax/tests/test_product_category_tax.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/product_category_tax/models/product_product.py b/product_category_tax/models/product_product.py index 16c41a503..afc712d47 100644 --- a/product_category_tax/models/product_product.py +++ b/product_category_tax/models/product_product.py @@ -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() diff --git a/product_category_tax/models/product_template.py b/product_category_tax/models/product_template.py index e8e838530..f950db002 100644 --- a/product_category_tax/models/product_template.py +++ b/product_category_tax/models/product_template.py @@ -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() diff --git a/product_category_tax/tests/test_product_category_tax.py b/product_category_tax/tests/test_product_category_tax.py index 9d1d0b2b6..cfbe1a84f 100644 --- a/product_category_tax/tests/test_product_category_tax.py +++ b/product_category_tax/tests/test_product_category_tax.py @@ -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"""