diff --git a/product_template_multi_link/README.rst b/product_template_multi_link/README.rst index 48861f98bd..19fc14b4ae 100644 --- a/product_template_multi_link/README.rst +++ b/product_template_multi_link/README.rst @@ -124,6 +124,14 @@ Contributors - David Luis Mora +- Vo Hong Thien + +Other credits +------------- + +The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp. + Maintainers ----------- diff --git a/product_template_multi_link/__manifest__.py b/product_template_multi_link/__manifest__.py index e58d3e6b7e..f942cc8891 100644 --- a/product_template_multi_link/__manifest__.py +++ b/product_template_multi_link/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Product Multi Links (Template)", - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "category": "Generic Modules", "author": "GRAP, ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/e-commerce", diff --git a/product_template_multi_link/models/product_template.py b/product_template_multi_link/models/product_template.py index 7ef7ac37d9..f027128ba8 100644 --- a/product_template_multi_link/models/product_template.py +++ b/product_template_multi_link/models/product_template.py @@ -4,7 +4,7 @@ from collections import defaultdict -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import AccessError @@ -43,7 +43,7 @@ def _compute_product_template_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: for rec in self: rec.product_template_link_count = 0 @@ -82,9 +82,9 @@ def _compute_product_template_link_count(self): def show_product_template_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_template_multi_link/models/product_template_link.py b/product_template_multi_link/models/product_template_link.py index 1088972cf9..86670c1fab 100644 --- a/product_template_multi_link/models/product_template_link.py +++ b/product_template_multi_link/models/product_template_link.py @@ -5,7 +5,7 @@ from psycopg2.extensions import AsIs -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import ValidationError @@ -21,6 +21,9 @@ class ProductTemplateLink(models.Model): ondelete="cascade", index=True, ) + left_product_img = fields.Image( + string="Left Product Image", related="left_product_tmpl_id.image_128" + ) right_product_tmpl_id = fields.Many2one( string="Linked Product", comodel_name="product.template", @@ -28,6 +31,9 @@ class ProductTemplateLink(models.Model): ondelete="cascade", index=True, ) + right_product_img = fields.Image( + string="Right Product Image", related="right_product_tmpl_id.image_128" + ) type_id = fields.Many2one( string="Link type", comodel_name="product.template.link.type", @@ -59,7 +65,7 @@ def _check_products(self): self.flush_recordset() # flush required since the method uses plain sql if any(rec._check_product_not_different() for rec in self): raise ValidationError( - _("You can only create a link between 2 different products") + self.env._("You can only create a link between 2 different products") ) products = self.mapped("left_product_tmpl_id") + self.mapped( @@ -75,7 +81,7 @@ def _check_products(self): [link._duplicate_link_error_msg() for link in self.browse(ids)] ) raise ValidationError( - _( + self.env._( "Only one link with the same type is allowed between 2 " "products. \n %s" ) @@ -147,7 +153,9 @@ def _check_products_query_params(self): ) def _duplicate_link_error_msg(self): - return f"{self.left_product_tmpl_id.name} <-> {self.link_type_name} / {self.link_type_inverse_name} <-> {self.right_product_tmpl_id.name}" + return f"""( + {self.left_product_tmpl_id.name} <-> {self.link_type_name} / + {self.link_type_inverse_name} <-> {self.right_product_tmpl_id.name})""" @contextmanager def _invalidate_links_on_product_template(self): diff --git a/product_template_multi_link/readme/CONTRIBUTORS.md b/product_template_multi_link/readme/CONTRIBUTORS.md index 6f68ff2144..eeca57fe30 100644 --- a/product_template_multi_link/readme/CONTRIBUTORS.md +++ b/product_template_multi_link/readme/CONTRIBUTORS.md @@ -1,3 +1,4 @@ - Sylvain LE GAL \<\> - [Binhex](https://binhex.cloud//com): - - David Luis Mora \<\> \ No newline at end of file + - David Luis Mora \<\> +- Vo Hong Thien \<\> diff --git a/product_template_multi_link/readme/CREDITS.md b/product_template_multi_link/readme/CREDITS.md new file mode 100644 index 0000000000..83b3ec91f7 --- /dev/null +++ b/product_template_multi_link/readme/CREDITS.md @@ -0,0 +1 @@ +The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp. diff --git a/product_template_multi_link/static/description/index.html b/product_template_multi_link/static/description/index.html index 9db5a6844a..c98cbaa475 100644 --- a/product_template_multi_link/static/description/index.html +++ b/product_template_multi_link/static/description/index.html @@ -456,8 +456,14 @@

Contributors

  • David Luis Mora <d.luis@binhex.cloud>
  • +
  • Vo Hong Thien <thienvh@trobz.com>
  • +
    +

    Other credits

    +

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

    +

    Maintainers

    This module is maintained by the OCA.

    diff --git a/product_template_multi_link/tests/test_product_template_link.py b/product_template_multi_link/tests/test_product_template_link.py index 44797b2667..cdb8aa02b9 100644 --- a/product_template_multi_link/tests/test_product_template_link.py +++ b/product_template_multi_link/tests/test_product_template_link.py @@ -2,17 +2,17 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.exceptions import ValidationError -from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import BaseCommon -class TestProductTemplateLink(TransactionCase): + +class TestProductTemplateLink(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() cls.env = cls.env( context=dict( cls.env.context, - tracking_disable=True, # compatibility flag when you run tests on a db # where `product_variant_multi_link` is installed. _product_variant_link_bypass_check=True, diff --git a/product_template_multi_link/tests/test_product_template_link_type.py b/product_template_multi_link/tests/test_product_template_link_type.py index 5ede9a2f5b..b2ffeff770 100644 --- a/product_template_multi_link/tests/test_product_template_link_type.py +++ b/product_template_multi_link/tests/test_product_template_link_type.py @@ -3,15 +3,15 @@ from psycopg2 import IntegrityError -from odoo.tests import TransactionCase from odoo.tools import mute_logger +from odoo.addons.base.tests.common import BaseCommon -class TestProductTemplateLinkType(TransactionCase): + +class TestProductTemplateLinkType(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) cls.LinkType = cls.env["product.template.link.type"] cls.link_type_cross_selling = cls.env.ref( "product_template_multi_link.product_template_link_type_cross_selling" diff --git a/product_template_multi_link/tests/test_product_template_linker.py b/product_template_multi_link/tests/test_product_template_linker.py index acab71d901..7b8e556cf0 100644 --- a/product_template_multi_link/tests/test_product_template_linker.py +++ b/product_template_multi_link/tests/test_product_template_linker.py @@ -1,9 +1,9 @@ # Copyright 2020 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import BaseCommon -class TestProductTemplateLinker(TransactionCase): +class TestProductTemplateLinker(BaseCommon): """ Tests for product.template.linker """ @@ -11,7 +11,6 @@ class TestProductTemplateLinker(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) cls.wizard_obj = cls.env["product.template.linker"] cls.product_link_obj = cls.env["product.template.link"] cls.cross_sell = cls.env.ref( diff --git a/product_template_multi_link/views/action.xml b/product_template_multi_link/views/action.xml index e3eb07b878..b53d264b3f 100644 --- a/product_template_multi_link/views/action.xml +++ b/product_template_multi_link/views/action.xml @@ -3,7 +3,7 @@ Product Links product.template.link - tree,kanban,form + list,kanban,form Product Links product.template.link - tree,kanban + list,kanban [('product_template_id', '=', id)] {'default_product_template_id': id} diff --git a/product_template_multi_link/views/product_template_link_type.xml b/product_template_multi_link/views/product_template_link_type.xml index df9ba3c005..40814a81a6 100644 --- a/product_template_multi_link/views/product_template_link_type.xml +++ b/product_template_multi_link/views/product_template_link_type.xml @@ -5,22 +5,22 @@ product.template.link.type.tree (in product_template_multi_link) + >product.template.link.type.list (in product_template_multi_link) product.template.link.type - + - + Product Template Link Type product.template.link.type - tree,form + list,form [] {} diff --git a/product_template_multi_link/views/product_template_link_view.xml b/product_template_multi_link/views/product_template_link_view.xml index 0bd28e7048..ec6142b5c0 100644 --- a/product_template_multi_link/views/product_template_link_view.xml +++ b/product_template_multi_link/views/product_template_link_view.xml @@ -27,14 +27,14 @@ See odoo/addons/product/models/product_template.py // def name_search() --> - Product.template.link.tree + Product.template.link.list product.template.link - - + + - - + + @@ -42,41 +42,45 @@ product.template.link - - - - -
    -
    -
    - +
    +
    +
    -
    + +
    -
    +
    -
    -
    - +
    -
    + +
    -
    +
    @@ -93,14 +97,8 @@ - - + + diff --git a/product_template_multi_link/wizards/product_template_linker.xml b/product_template_multi_link/wizards/product_template_linker.xml index d33cfee8b2..f6c0c49e01 100644 --- a/product_template_multi_link/wizards/product_template_linker.xml +++ b/product_template_multi_link/wizards/product_template_linker.xml @@ -26,10 +26,10 @@ colspan="2" options="{'no_open':True, 'no_create':True}" > - + - +