diff --git a/product_set/README.rst b/product_set/README.rst index d2372815cbbe..71eaa076e814 100644 --- a/product_set/README.rst +++ b/product_set/README.rst @@ -83,6 +83,8 @@ Contributors - Pilar Vargas +- Nils Coenen + Other credits ------------- diff --git a/product_set/__manifest__.py b/product_set/__manifest__.py index b001d5e439e4..6296729d7c32 100644 --- a/product_set/__manifest__.py +++ b/product_set/__manifest__.py @@ -6,7 +6,7 @@ "category": "Sale", "license": "AGPL-3", "author": "Anybox, Odoo Community Association (OCA)", - "version": "16.0.3.0.0", + "version": "17.0.1.0.0", "website": "https://github.com/OCA/product-attribute", "depends": ["product"], "data": [ diff --git a/product_set/models/product_set.py b/product_set/models/product_set.py index d3c419418b83..d04f5834fae5 100644 --- a/product_set/models/product_set.py +++ b/product_set/models/product_set.py @@ -1,14 +1,14 @@ # Copyright 2015 Anybox S.A.S # Copyright 2016-2018 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class ProductSet(models.Model): _name = "product.set" _description = "Product set" - name = fields.Char(help="Product set name", required=True) + name = fields.Char(help="Product set name", required=True, translate=True) active = fields.Boolean(default=True) ref = fields.Char( string="Internal Reference", help="Product set internal reference", copy=False @@ -32,14 +32,17 @@ class ProductSet(models.Model): "it's going to be available for all of them.", ) - def name_get(self): - return [(rec.id, rec._name_get()) for rec in self] + display_name = fields.Char( + compute="_compute_display_name", string="Display Name", store=False, translate=True + ) - def _name_get(self): - parts = [] - if self.ref: - parts.append("[%s]" % self.ref) - parts.append(self.name) - if self.partner_id: - parts.append("@ %s" % self.partner_id.name) - return " ".join(parts) + @api.depends("name", "ref", "partner_id.name") + def _compute_display_name(self): + for rec in self: + parts = [] + if rec.ref: + parts.append("[%s]" % rec.ref) + parts.append(rec.name or "") + if rec.partner_id and rec.partner_id.name: + parts.append("@ %s" % rec.partner_id.name) + rec.display_name = " ".join(map(str, parts)) diff --git a/product_set/readme/CONTRIBUTORS.md b/product_set/readme/CONTRIBUTORS.md index 43078e177ca7..fcb48d011e7d 100644 --- a/product_set/readme/CONTRIBUTORS.md +++ b/product_set/readme/CONTRIBUTORS.md @@ -8,3 +8,4 @@ - Manuel Regidor \<\> - [Tecnativa](https://www.tecnativa.com): - Pilar Vargas +- Nils Coenen \<\> diff --git a/product_set/static/description/index.html b/product_set/static/description/index.html index 2ba709797f12..c71bfded1e67 100644 --- a/product_set/static/description/index.html +++ b/product_set/static/description/index.html @@ -427,6 +427,7 @@

Contributors

  • Pilar Vargas
  • +
  • Nils Coenen <nils.coenen@nico-solutions.de>
  • diff --git a/product_set/tests/test_product_set.py b/product_set/tests/test_product_set.py index 065ccfb1dc7e..a1a28e9a3f04 100644 --- a/product_set/tests/test_product_set.py +++ b/product_set/tests/test_product_set.py @@ -18,13 +18,20 @@ def test_name(self): # no ref product_set.name = "Foo" product_set.ref = "" - self.assertEqual(product_set.name_get(), [(product_set.id, "Foo")]) + self.assertEqual( + product_set.read(["display_name"]), + [{"id": product_set.id, "display_name": "Foo"}], + ) # with ref product_set.ref = "123" - self.assertEqual(product_set.name_get(), [(product_set.id, "[123] Foo")]) + self.assertEqual( + product_set.read(["display_name"]), + [{"id": product_set.id, "display_name": "[123] Foo"}], + ) # with partner partner = self.env.ref("base.res_partner_1") product_set.partner_id = partner self.assertEqual( - product_set.name_get(), [(product_set.id, "[123] Foo @ %s" % partner.name)] + product_set.read(["display_name"]), + [{"id": product_set.id, "display_name": "[123] Foo @ %s" % partner.name}], ) diff --git a/product_set/views/product_set.xml b/product_set/views/product_set.xml index 4d935ee09fb4..079b6d6ec14c 100644 --- a/product_set/views/product_set.xml +++ b/product_set/views/product_set.xml @@ -24,7 +24,7 @@ name="web_ribbon" title="Archived" bg_color="bg-danger" - attrs="{'invisible': [('active', '=', True)]}" + invisible="active" />
    @@ -48,10 +48,7 @@ > - + diff --git a/product_set/wizard/product_set_wizard.py b/product_set/wizard/product_set_wizard.py index 5630a71487b3..b492da0db09c 100644 --- a/product_set/wizard/product_set_wizard.py +++ b/product_set/wizard/product_set_wizard.py @@ -34,8 +34,7 @@ def _compute_product_set_line_ids(self): def _get_lines(self): # hook here to take control on used lines - for set_line in self.product_set_line_ids: - yield set_line + yield from self.product_set_line_ids def _check_partner(self): """This method may be extended in other modules that use product_set as a base."""