Use party lang Function field to set language for taxes and chat

This commit is contained in:
Cédric Krier
2026-03-06 10:50:48 +01:00
parent 5851c97fd6
commit 55da16f6a7
3 changed files with 12 additions and 12 deletions
+4 -4
View File
@@ -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
+4 -4
View File
@@ -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
+4 -4
View File
@@ -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