diff --git a/base_product_mass_addition/__manifest__.py b/base_product_mass_addition/__manifest__.py index 40ae9d7b747..8d4726f7650 100644 --- a/base_product_mass_addition/__manifest__.py +++ b/base_product_mass_addition/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Base Product Mass Addition", - "version": "14.0.1.2.0", + "version": "15.0.1.0.0", "author": "Akretion, Odoo Community Association (OCA)", "website": "https://github.com/OCA/product-attribute", "license": "AGPL-3", diff --git a/base_product_mass_addition/models/product_product.py b/base_product_mass_addition/models/product_product.py index 75337d1ff74..0e87b67fb71 100644 --- a/base_product_mass_addition/models/product_product.py +++ b/base_product_mass_addition/models/product_product.py @@ -48,15 +48,23 @@ def modified(self, fnames, create=False, before=False): # We achieve it by reverting the changes made by ``write`` [^1], before [^2] # reaching any explicit flush [^3] or inverse computation [^4]. # - # [^1]: https://github.com/odoo/odoo/blob/f74434c6f/odoo/models.py#L3652-L3663 - # [^2]: https://github.com/odoo/odoo/blob/f74434c6f/odoo/models.py#L3686 - # [^3]: https://github.com/odoo/odoo/blob/f74434c6f/odoo/models.py#L3689 - # [^4]: https://github.com/odoo/odoo/blob/f74434c6f/odoo/models.py#L3703 + # [^1]: + # https://github.com/odoo/odoo/blob/3991737a53e75398fcf70b1924525783b54d256b/odoo/models.py#L3778-L3787 # noqa: B950 + # [^2]: + # https://github.com/odoo/odoo/blob/3991737a53e75398fcf70b1924525783b54d256b/odoo/models.py#L3882 # noqa: B950 + # [^3]: + # https://github.com/odoo/odoo/blob/3991737a53e75398fcf70b1924525783b54d256b/odoo/models.py#L3885 # noqa: B950 + # [^4]: + # https://github.com/odoo/odoo/blob/f74434c6f4303650e886d99fb950c763f2d4cc6e/odoo/models.py#L3703 # noqa: B950 # # Basically, if all we're modifying are quick magic fields, and we don't have # any other column to flush besides the LOG_ACCESS_COLUMNS, clear it. quick_fnames = ("qty_to_process", "quick_uom_id") - if self and fnames and all(fname in quick_fnames for fname in fnames): + if ( + self + and fnames + and any(quick_fname in fnames for quick_fname in quick_fnames) + ): for record in self.filtered("id"): towrite = self.env.all.towrite[self._name] vals = towrite[record.id] diff --git a/base_product_mass_addition/readme/CONTRIBUTORS.rst b/base_product_mass_addition/readme/CONTRIBUTORS.rst index c69ea34bcfe..b30018c3bec 100644 --- a/base_product_mass_addition/readme/CONTRIBUTORS.rst +++ b/base_product_mass_addition/readme/CONTRIBUTORS.rst @@ -8,3 +8,7 @@ Akretion * `Camptocamp `_ * Iván Todorovich + +* `Sygel `_: + + * Ángel García de la Chica Herrera diff --git a/base_product_mass_addition/tests/test_product_mass_addition.py b/base_product_mass_addition/tests/test_product_mass_addition.py index 8241e2eccc0..51b2bbd0ef6 100644 --- a/base_product_mass_addition/tests/test_product_mass_addition.py +++ b/base_product_mass_addition/tests/test_product_mass_addition.py @@ -4,10 +4,10 @@ from odoo_test_helper import FakeModelLoader -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestProductMassAddition(SavepointCase): +class TestProductMassAddition(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -55,7 +55,33 @@ def test_quick_should_not_write_on_product(self): self.product.qty_to_process = 1.0 self.env["base"].flush() self.assertEqual(self.product.write_uid, user_demo) - # Case 2: Updating other fields should still work + # Case 2: Updating quick_uom_id shouldn't write on products + self.product.quick_uom_id = self.env.ref("uom.product_uom_categ_unit").uom_ids[ + 1 + ] + self.env["base"].flush() + self.assertEqual(self.product.write_uid, user_demo) + + def test_quick_should_write_on_product(self): + """Updating fields that are not magic fields should update + product metadata""" + # Change the product write_uid for testing + user_demo = self.env.ref("base.user_demo") + self.product.write_uid = user_demo + self.env["base"].flush() + self.assertEqual(self.product.write_uid, user_demo) + # Case 1: Updating name field should write on product's metadata self.product.name = "Testing" self.env["base"].flush() self.assertEqual(self.product.write_uid, self.env.user) + # Change the product write_uid for testing + user_demo = self.env.ref("base.user_demo") + self.product.write_uid = user_demo + self.env["base"].flush() + self.assertEqual(self.product.write_uid, user_demo) + # Case 2: Updating qty_to_process and name before flush should + # write on product's metadata + self.product.qty_to_process = 2.0 + self.product.name = "Testing 2" + self.env["base"].flush() + self.assertEqual(self.product.write_uid, self.env.user) diff --git a/base_product_mass_addition/views/product_view.xml b/base_product_mass_addition/views/product_view.xml index 5de8d8fd8b4..4e8739fddcb 100644 --- a/base_product_mass_addition/views/product_view.xml +++ b/base_product_mass_addition/views/product_view.xml @@ -5,7 +5,7 @@ product.product - +