From 1f914083562455e30bb40866dd11377da0d3daef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 18 Dec 2020 00:28:25 +0100 Subject: [PATCH] Ensure party_lang on invoice line has always a correct value It is better for modularity to put the invoice parent test in the getter of party_lang than having the test in the PYSON expression. issue9897 review324591011 --- invoice.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/invoice.py b/invoice.py index 9374e2faaa..673d4227d0 100644 --- a/invoice.py +++ b/invoice.py @@ -480,9 +480,8 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): @fields.depends('party') def on_change_with_party_lang(self, name=None): Config = Pool().get('ir.configuration') - if self.party: - if self.party.lang: - return self.party.lang.code + if self.party and self.party.lang: + return self.party.lang.code return Config.get_language() @classmethod @@ -1895,11 +1894,15 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): return self.invoice.state return 'draft' - @fields.depends('party') + @fields.depends('invoice', '_parent_invoice.party', 'party') def on_change_with_party_lang(self, name=None): Config = Pool().get('ir.configuration') - if self.party and self.party.lang: - return self.party.lang.code + if self.invoice and self.invoice.party: + party = self.invoice.party + else: + party = self.party + if party and party.lang: + return party.lang.code return Config.get_language() @fields.depends('unit') @@ -2160,9 +2163,7 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): def view_attributes(cls): return [ ('/form//field[@name="note"]|/form//field[@name="description"]', - 'spell', If(Bool(Eval('_parent_invoice')), - Eval('_parent_invoice', {}).get('party_lang'), - Eval('party_lang')))] + 'spell', Eval('party_lang'))] @classmethod def delete(cls, lines):