Skip to content

Commit a262683

Browse files
committed
Merge PR #2030 into 17.0
Signed-off-by AaronHForgeFlow
2 parents 1d85bf0 + 61ac872 commit a262683

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Copyright 2019-2020 ForgeFlow S.L.
22
# (https://www.forgeflow.com)
33
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
4-
from odoo import models
4+
from odoo import api, models
55

66

77
class PurchaseOrderLine(models.Model):
88
_inherit = "purchase.order.line"
99

10-
def name_get(self):
11-
result = []
12-
orig_name = dict(super().name_get())
10+
@api.depends("name", "order_id.name", "order_id.state")
11+
@api.depends_context("po_line_info")
12+
def _compute_display_name(self):
13+
if not self.env.context.get("po_line_info", False):
14+
return super()._compute_display_name()
1315
for line in self:
14-
name = orig_name[line.id]
15-
if self.env.context.get("po_line_info", False):
16-
name = f"[{line.order_id.name}] {name} ({line.order_id.state})"
17-
result.append((line.id, name))
18-
return result
16+
line.display_name = (
17+
f"[{line.order_id.name}] {line.name} ({line.order_id.state})"
18+
)

0 commit comments

Comments
 (0)