From 55da16f6a7df9ccd97c59f4c75beeadda9a160cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 6 Mar 2026 10:50:48 +0100 Subject: [PATCH] Use party lang Function field to set language for taxes and chat --- modules/account_invoice/invoice.py | 8 ++++---- modules/purchase/purchase.py | 8 ++++---- modules/sale/sale.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 9736cb5984..2f3e432569 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -1171,11 +1171,11 @@ class Invoice( today = Date.today() return self.accounting_date or self.invoice_date or today - @fields.depends('party', 'company') + @fields.depends('party_lang', 'company') def _get_tax_context(self): context = {} - if self.party and self.party.lang: - context['language'] = self.party.lang.code + if self.party_lang: + context['language'] = self.party_lang if self.company: context['company'] = self.company.id return context @@ -1572,7 +1572,7 @@ class Invoice( def chat_language(self, audience='internal'): language = super().chat_language(audience=audience) if audience == 'public': - language = self.party.lang.code if self.party.lang else None + language = self.party_lang return language @classmethod diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index 944bdbcffd..3560885333 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -485,11 +485,11 @@ class Purchase( return self.party.lang.code return Config.get_language() - @fields.depends('party', 'company') + @fields.depends('party_lang', 'company') def _get_tax_context(self): context = {} - if self.party and self.party.lang: - context['language'] = self.party.lang.code + if self.party_lang: + context['language'] = self.party_lang if self.company: context['company'] = self.company.id return context @@ -736,7 +736,7 @@ class Purchase( def chat_language(self, audience='internal'): language = super().chat_language(audience=audience) if audience == 'public': - language = self.party.lang.code if self.party.lang else None + language = self.party_lang return language @classmethod diff --git a/modules/sale/sale.py b/modules/sale/sale.py index bffe790e89..a636ec7cf5 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -605,11 +605,11 @@ class Sale( if self.party.sale_shipment_method: self.shipment_method = self.party.sale_shipment_method - @fields.depends('party', 'company') + @fields.depends('party_lang', 'company') def _get_tax_context(self): context = {} - if self.party and self.party.lang: - context['language'] = self.party.lang.code + if self.party_lang: + context['language'] = self.party_lang if self.company: context['company'] = self.company.id return context @@ -875,7 +875,7 @@ class Sale( def chat_language(self, audience='internal'): language = super().chat_language(audience=audience) if audience == 'public': - language = self.party.lang.code if self.party.lang else None + language = self.party_lang return language @classmethod