diff --git a/product_abc_classification_base/README.rst b/product_abc_classification_base/README.rst index 196e2ed4364b..bbed589ebf53 100644 --- a/product_abc_classification_base/README.rst +++ b/product_abc_classification_base/README.rst @@ -1,6 +1,6 @@ -============================== -Alc Product Abc Classification -============================== +========================== +Product Abc Classification +========================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -14,13 +14,13 @@ Alc Product Abc Classification :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github - :target: https://github.com/OCA/product-attribute/tree/10.0/product_abc_classification_base + :target: https://github.com/OCA/product-attribute/tree/16.0/product_abc_classification_base :alt: OCA/product-attribute .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-attribute-10-0/product-attribute-10-0-product_abc_classification_base + :target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_abc_classification_base :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/135/10.0 + :target: https://runbot.odoo-community.org/runbot/135/16.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -63,7 +63,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -82,6 +82,7 @@ Contributors * Miquel Raïch * Lindsay Marion * Laurent Mignon +* Denis Roussel Maintainers ~~~~~~~~~~~ @@ -96,6 +97,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/product-attribute `_ project on GitHub. +This module is part of the `OCA/product-attribute `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_abc_classification_base/__manifest__.py b/product_abc_classification_base/__manifest__.py index f0f46384aa18..cab1805d35e3 100644 --- a/product_abc_classification_base/__manifest__.py +++ b/product_abc_classification_base/__manifest__.py @@ -6,10 +6,11 @@ "name": "Product Abc Classification", "summary": """ ABC classification for sales and warehouse management""", - "version": "10.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV, ForgeFlow, Odoo Community Association (OCA)", "depends": ["product", "stock", "web_m2x_options"], + "website": "https://github.com/OCA/product-attribute", "data": [ "views/abc_classification_product_level.xml", "views/abc_classification_profile.xml", @@ -18,5 +19,4 @@ "security/ir.model.access.csv", "data/ir_cron.xml", ], - "demo": [], } diff --git a/product_abc_classification_base/data/ir_cron.xml b/product_abc_classification_base/data/ir_cron.xml index a8bb93fd5460..04303328c198 100644 --- a/product_abc_classification_base/data/ir_cron.xml +++ b/product_abc_classification_base/data/ir_cron.xml @@ -7,8 +7,8 @@ months -1 - abc.classification.profile - _cron_compute_abc_classification - () + + model._cron_compute_abc_classification() + code diff --git a/product_abc_classification_base/models/abc_classification_level.py b/product_abc_classification_base/models/abc_classification_level.py index 5144c5bb07ad..01b045eabc72 100644 --- a/product_abc_classification_base/models/abc_classification_level.py +++ b/product_abc_classification_base/models/abc_classification_level.py @@ -9,6 +9,7 @@ class AbcClassificationLevel(models.Model): _name = "abc.classification.level" + _description = "ABC Classification Level" _order = "percentage desc, id desc" _rec_name = "name" diff --git a/product_abc_classification_base/models/abc_classification_product_level.py b/product_abc_classification_base/models/abc_classification_product_level.py index 55690ec1bc69..1ad9cf6c1843 100644 --- a/product_abc_classification_base/models/abc_classification_product_level.py +++ b/product_abc_classification_base/models/abc_classification_product_level.py @@ -16,7 +16,7 @@ class AbcClassificationProductLevel(models.Model): manual_level_id = fields.Many2one( "abc.classification.level", string="Manual classification level", - track_visibility="onchange", + tracking=True, domain="[('profile_id', '=', profile_id)]", ) computed_level_id = fields.Many2one( @@ -129,18 +129,21 @@ def _compute_flag(self): rec.computed_level_id and rec.manual_level_id != rec.computed_level_id ) - @api.model - def create(self, vals): - if "manual_level_id" not in vals and "computed_level_id" in vals: - # at creation the manual level is set to the same value as the - # computed one - vals["manual_level_id"] = vals["computed_level_id"] - - if "profile_id" in vals: - profile = self.env["abc.classification.profile"].browse(vals["profile_id"]) - if profile.auto_apply_computed_value and "computed_level_id" in vals: + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if "manual_level_id" not in vals and "computed_level_id" in vals: + # at creation the manual level is set to the same value as the + # computed one vals["manual_level_id"] = vals["computed_level_id"] - return super(AbcClassificationProductLevel, self).create(vals) + + if "profile_id" in vals: + profile = self.env["abc.classification.profile"].browse( + vals["profile_id"] + ) + if profile.auto_apply_computed_value and "computed_level_id" in vals: + vals["manual_level_id"] = vals["computed_level_id"] + return super().create(vals_list) def write(self, vals): values = vals.copy() @@ -153,4 +156,4 @@ def write(self, vals): if profile.auto_apply_computed_value and "computed_level_id" in values: values["manual_level_id"] = values["computed_level_id"] - return super(AbcClassificationProductLevel, self).write(values) + return super().write(values) diff --git a/product_abc_classification_base/models/abc_classification_profile.py b/product_abc_classification_base/models/abc_classification_profile.py index 1c669d4a0ca1..b57b0a1e46d7 100644 --- a/product_abc_classification_base/models/abc_classification_profile.py +++ b/product_abc_classification_base/models/abc_classification_profile.py @@ -57,7 +57,6 @@ def _check_levels(self): ) ) - @api.multi def _compute_abc_classification(self): raise NotImplementedError() @@ -94,4 +93,4 @@ def _auto_apply_computed_value_for_product_levels(self): modified_levels = self.env["abc.classification.product.level"].browse(level_ids) # mark field as modified and trigger recompute of dependent fields. modified_levels.modified(["manual_level_id"]) - modified_levels.recompute() + modified_levels._recompute_recordset() diff --git a/product_abc_classification_base/readme/CONTRIBUTORS.rst b/product_abc_classification_base/readme/CONTRIBUTORS.rst index ebb18f6ff748..fe41e2ce43dd 100644 --- a/product_abc_classification_base/readme/CONTRIBUTORS.rst +++ b/product_abc_classification_base/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Miquel Raïch * Lindsay Marion * Laurent Mignon +* Denis Roussel diff --git a/product_abc_classification_base/static/description/index.html b/product_abc_classification_base/static/description/index.html index dd0266cbce4e..b309d87953d4 100644 --- a/product_abc_classification_base/static/description/index.html +++ b/product_abc_classification_base/static/description/index.html @@ -3,8 +3,8 @@ - -Alc Product Abc Classification + +Product Abc Classification -
-

Alc Product Abc Classification

+
+

Product Abc Classification

-

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

This modules provides the bases to build ABC analysis (or ABC classification) addons. These classification are used by inventory management teams to help identify the most important products in their portfolio and ensure they @@ -406,7 +406,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -424,6 +424,7 @@

Contributors

  • Miquel Raïch <miquel.raich@eficent.com>
  • Lindsay Marion <lindsay.marion@acsone.eu>
  • Laurent Mignon <laurent.mignon@acsone.eu>
  • +
  • Denis Roussel <denis.roussel@acsone.eu>
  • @@ -433,7 +434,7 @@

    Maintainers

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/product-attribute project on GitHub.

    +

    This module is part of the OCA/product-attribute project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/product_abc_classification_base/tests/common.py b/product_abc_classification_base/tests/common.py index f62e9dd2a41e..4900770fdce2 100644 --- a/product_abc_classification_base/tests/common.py +++ b/product_abc_classification_base/tests/common.py @@ -1,13 +1,14 @@ # Copyright 2021 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class ABCClassificationCase(SavepointCase): +class ABCClassificationCase(TransactionCase): @classmethod def setUpClass(cls): - super(ABCClassificationCase, cls).setUpClass() + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) # add a fake profile_type cls.ABCClassificationProfile = cls.env["abc.classification.profile"] cls.ABCClassificationProfile._fields["profile_type"].selection = [ @@ -21,7 +22,7 @@ def setUpClass(cls): class ABCClassificationLevelCase(ABCClassificationCase): @classmethod def setUpClass(cls): - super(ABCClassificationLevelCase, cls).setUpClass() + super().setUpClass() cls.classification_profile.write( { "level_ids": [ @@ -85,13 +86,13 @@ def setUpClass(cls): cls.size_attr = cls.env["product.attribute"].create( { "name": "Size", - "create_variant": False, + "create_variant": "no_variant", "value_ids": [(0, 0, {"name": "S"}), (0, 0, {"name": "M"})], } ) cls.size_attr_value_s = cls.size_attr.value_ids[0] cls.size_attr_value_m = cls.size_attr.value_ids[1] - cls.uom_unit = cls.env.ref("product.product_uom_unit") + cls.uom_unit = cls.env.ref("uom.product_uom_unit") cls.product_template = cls.env["product.template"].create( { "name": "Test sized", @@ -117,6 +118,6 @@ def _create_variant(cls, size_value): return cls.env["product.product"].create( { "product_tmpl_id": cls.product_template.id, - "attribute_value_ids": [(6, 0, size_value.ids)], + "product_template_attribute_value_ids": [(6, 0, size_value.ids)], } ) diff --git a/product_abc_classification_base/tests/test_abc_classification_product_level.py b/product_abc_classification_base/tests/test_abc_classification_product_level.py index fe87c93675ec..9b2db6df8722 100644 --- a/product_abc_classification_base/tests/test_abc_classification_product_level.py +++ b/product_abc_classification_base/tests/test_abc_classification_product_level.py @@ -11,7 +11,7 @@ class TestABCClassificationProductLevel(ABCClassificationLevelCase): @classmethod def setUpClass(cls): - super(TestABCClassificationProductLevel, cls).setUpClass() + super().setUpClass() cls.product_1 = cls.env["product.product"].create( { "name": "Test 1", diff --git a/product_abc_classification_base/tests/test_product.py b/product_abc_classification_base/tests/test_product.py index ed3406fcfaa4..923ae1eefe9b 100644 --- a/product_abc_classification_base/tests/test_product.py +++ b/product_abc_classification_base/tests/test_product.py @@ -7,7 +7,7 @@ class TestProduct(ABCClassificationLevelCase): @classmethod def setUpClass(cls): - super(TestProduct, cls).setUpClass() + super().setUpClass() def test_00(self): """ diff --git a/product_abc_classification_base/views/abc_classification_product_level.xml b/product_abc_classification_base/views/abc_classification_product_level.xml index fed469a26041..e6332542fe8f 100644 --- a/product_abc_classification_base/views/abc_classification_product_level.xml +++ b/product_abc_classification_base/views/abc_classification_product_level.xml @@ -20,7 +20,7 @@ diff --git a/product_abc_classification_base/views/abc_classification_profile.xml b/product_abc_classification_base/views/abc_classification_profile.xml index cca0af065376..781f0cd122c8 100644 --- a/product_abc_classification_base/views/abc_classification_profile.xml +++ b/product_abc_classification_base/views/abc_classification_profile.xml @@ -35,7 +35,7 @@ >abc.classification.profile.tree (in product_abc_classification_base) abc.classification.profile - + diff --git a/setup/product_abc_classification_base/odoo/__init__.py b/setup/product_abc_classification_base/odoo/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/setup/product_abc_classification_base/odoo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/product_abc_classification_base/odoo/addons/__init__.py b/setup/product_abc_classification_base/odoo/addons/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/setup/product_abc_classification_base/odoo/addons/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__)