Skip to content

Commit 8a4f327

Browse files
[MIG] product_set: Migration to 17.0
1 parent c5f12be commit 8a4f327

File tree

12 files changed

+32
-41
lines changed

12 files changed

+32
-41
lines changed

product_set/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Contributors
8383

8484
- Pilar Vargas
8585

86+
- Nils Coenen <nils.coenen@nico-solutions.de>
87+
8688
Other credits
8789
-------------
8890

product_set/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"category": "Sale",
77
"license": "AGPL-3",
88
"author": "Anybox, Odoo Community Association (OCA)",
9-
"version": "16.0.3.0.0",
9+
"version": "17.0.1.0.0",
1010
"website": "https://github.com/OCA/product-attribute",
1111
"depends": ["product"],
1212
"data": [

product_set/models/product_set.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2015 Anybox S.A.S
22
# Copyright 2016-2018 Camptocamp SA
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4-
from odoo import fields, models
4+
from odoo import api, fields, models
55

66

77
class ProductSet(models.Model):
@@ -32,14 +32,17 @@ class ProductSet(models.Model):
3232
"it's going to be available for all of them.",
3333
)
3434

35-
def name_get(self):
36-
return [(rec.id, rec._name_get()) for rec in self]
35+
display_name = fields.Char(
36+
compute="_compute_display_name", string="Display Name", store=True
37+
)
3738

38-
def _name_get(self):
39-
parts = []
40-
if self.ref:
41-
parts.append("[%s]" % self.ref)
42-
parts.append(self.name)
43-
if self.partner_id:
44-
parts.append("@ %s" % self.partner_id.name)
45-
return " ".join(parts)
39+
@api.depends("name", "ref", "partner_id.name")
40+
def _compute_display_name(self):
41+
for rec in self:
42+
parts = []
43+
if rec.ref:
44+
parts.append("[%s]" % rec.ref)
45+
parts.append(rec.name or "")
46+
if rec.partner_id and rec.partner_id.name:
47+
parts.append("@ %s" % rec.partner_id.name)
48+
rec.display_name = " ".join(map(str, parts))

product_set/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
- Manuel Regidor \<<manuel.regidor@sygel.es>\>
99
- [Tecnativa](https://www.tecnativa.com):
1010
- Pilar Vargas
11+
- Nils Coenen \<<nils.coenen@nico-solutions.de>\>

product_set/readme/CONTRIBUTORS.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

product_set/readme/CREDITS.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

product_set/readme/DESCRIPTION.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.

product_set/readme/USAGE.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

product_set/static/description/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
427427
<li>Pilar Vargas</li>
428428
</ul>
429429
</li>
430+
<li>Nils Coenen &lt;<a class="reference external" href="mailto:nils.coenen&#64;nico-solutions.de">nils.coenen&#64;nico-solutions.de</a>&gt;</li>
430431
</ul>
431432
</div>
432433
<div class="section" id="other-credits">

product_set/tests/test_product_set.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ def test_name(self):
1818
# no ref
1919
product_set.name = "Foo"
2020
product_set.ref = ""
21-
self.assertEqual(product_set.name_get(), [(product_set.id, "Foo")])
21+
self.assertEqual(
22+
product_set.read(["display_name"]),
23+
[{"id": product_set.id, "display_name": "Foo"}],
24+
)
2225
# with ref
2326
product_set.ref = "123"
24-
self.assertEqual(product_set.name_get(), [(product_set.id, "[123] Foo")])
27+
self.assertEqual(
28+
product_set.read(["display_name"]),
29+
[{"id": product_set.id, "display_name": "[123] Foo"}],
30+
)
2531
# with partner
2632
partner = self.env.ref("base.res_partner_1")
2733
product_set.partner_id = partner
2834
self.assertEqual(
29-
product_set.name_get(), [(product_set.id, "[123] Foo @ %s" % partner.name)]
35+
product_set.read(["display_name"]),
36+
[{"id": product_set.id, "display_name": "[123] Foo @ %s" % partner.name}],
3037
)

0 commit comments

Comments
 (0)