From 0c1427e9e18d574b92f1a29d381de3d17d13871f Mon Sep 17 00:00:00 2001 From: thien Date: Fri, 29 Nov 2024 14:13:04 +0700 Subject: [PATCH] [MIG] product_variant_multi_link: Migration to 18.0 --- product_variant_multi_link/README.rst | 4 ++++ product_variant_multi_link/__manifest__.py | 2 +- product_variant_multi_link/models/product_product.py | 8 ++++---- .../models/product_template_link.py | 11 ++++++----- product_variant_multi_link/readme/CONTRIBUTORS.md | 1 + product_variant_multi_link/readme/CREDITS.md | 2 ++ .../static/description/index.html | 3 +++ .../tests/test_product_template_link.py | 4 ++-- .../views/product_template_link_view.xml | 7 +++++++ 9 files changed, 30 insertions(+), 12 deletions(-) diff --git a/product_variant_multi_link/README.rst b/product_variant_multi_link/README.rst index 402ebe4a43..6cf77e9951 100644 --- a/product_variant_multi_link/README.rst +++ b/product_variant_multi_link/README.rst @@ -63,6 +63,7 @@ Contributors ------------ - Simone Orsi +- Thien Vo Other credits ------------- @@ -72,6 +73,9 @@ The development of this module has been financially supported by: - Camptocamp - Cosanum +The migration of this module from 14.0 to 18.0 was financially supported +by Camptocamp. + Maintainers ----------- diff --git a/product_variant_multi_link/__manifest__.py b/product_variant_multi_link/__manifest__.py index 9068995eb3..4bc90d75b4 100644 --- a/product_variant_multi_link/__manifest__.py +++ b/product_variant_multi_link/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Product Multi Links (Variant)", - "version": "14.0.1.1.0", + "version": "18.0.1.0.0", "category": "Generic Modules", "author": "Camptocamp SA, Odoo Community Association (OCA)", "website": "https://github.com/OCA/e-commerce", diff --git a/product_variant_multi_link/models/product_product.py b/product_variant_multi_link/models/product_product.py index ec9a430c0b..f365e0a78d 100644 --- a/product_variant_multi_link/models/product_product.py +++ b/product_variant_multi_link/models/product_product.py @@ -2,7 +2,7 @@ # Simone Orsi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import AccessError @@ -24,7 +24,7 @@ def _compute_product_product_link_count(self): link_model = self.env["product.template.link"] # Set product_template_link_qty to 0 if user has no access on the model try: - link_model.check_access_rights("read") + link_model.check_access("read") except AccessError: self.update({"product_product_link_count": 0}) return @@ -72,9 +72,9 @@ def show_product_product_links(self): self.ensure_one() return { - "name": _("Product links"), + "name": self.env._("Product links"), "type": "ir.actions.act_window", - "view_mode": "tree,form", + "view_mode": "list,form", "res_model": "product.template.link", "domain": [ "|", diff --git a/product_variant_multi_link/models/product_template_link.py b/product_variant_multi_link/models/product_template_link.py index b67efc422d..a0fe778547 100644 --- a/product_variant_multi_link/models/product_template_link.py +++ b/product_variant_multi_link/models/product_template_link.py @@ -2,7 +2,7 @@ # Simone Orsi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, exceptions, fields, models +from odoo import api, exceptions, fields, models class ProductTemplateLink(models.Model): @@ -37,9 +37,9 @@ def _check_products(self): # to avoid issues w/ existing table and existing records if not rec.left_product_id or not rec.right_product_id: raise exceptions.ValidationError( - _("Source and target variants are required!") + self.env._("Source and target variants are required!") ) - super()._check_products() + return super()._check_products() def _check_product_not_different(self): res = super()._check_product_not_different() @@ -62,5 +62,6 @@ def _check_products_query_params(self): return params def _invalidate_links(self): - super()._invalidate_links() - self.env["product.product"].invalidate_cache(["product_variant_link_ids"]) + res = super()._invalidate_links() + self.env["product.product"].invalidate_model(["product_variant_link_ids"]) + return res diff --git a/product_variant_multi_link/readme/CONTRIBUTORS.md b/product_variant_multi_link/readme/CONTRIBUTORS.md index 5792655b0b..b680757610 100644 --- a/product_variant_multi_link/readme/CONTRIBUTORS.md +++ b/product_variant_multi_link/readme/CONTRIBUTORS.md @@ -1 +1,2 @@ - Simone Orsi \<\> +- Thien Vo \<\> diff --git a/product_variant_multi_link/readme/CREDITS.md b/product_variant_multi_link/readme/CREDITS.md index 01daa54ae8..1cdd82b5ad 100644 --- a/product_variant_multi_link/readme/CREDITS.md +++ b/product_variant_multi_link/readme/CREDITS.md @@ -2,3 +2,5 @@ The development of this module has been financially supported by: - Camptocamp - Cosanum + +The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp. diff --git a/product_variant_multi_link/static/description/index.html b/product_variant_multi_link/static/description/index.html index 707e64c7dd..4c3c670d95 100644 --- a/product_variant_multi_link/static/description/index.html +++ b/product_variant_multi_link/static/description/index.html @@ -410,6 +410,7 @@

Authors

Contributors

@@ -419,6 +420,8 @@

Other credits

  • Camptocamp
  • Cosanum
  • +

    The migration of this module from 14.0 to 18.0 was financially supported +by Camptocamp.

    Maintainers

    diff --git a/product_variant_multi_link/tests/test_product_template_link.py b/product_variant_multi_link/tests/test_product_template_link.py index 180ecfea3e..0463e5a8fa 100644 --- a/product_variant_multi_link/tests/test_product_template_link.py +++ b/product_variant_multi_link/tests/test_product_template_link.py @@ -3,10 +3,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.exceptions import ValidationError -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestProductVariantLink(SavepointCase): +class TestProductVariantLink(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/product_variant_multi_link/views/product_template_link_view.xml b/product_variant_multi_link/views/product_template_link_view.xml index 9c3d23b202..a6dc49fb24 100644 --- a/product_variant_multi_link/views/product_template_link_view.xml +++ b/product_variant_multi_link/views/product_template_link_view.xml @@ -11,6 +11,7 @@ @@ -26,12 +27,14 @@ @@ -47,12 +50,14 @@ @@ -68,12 +73,14 @@