Use party lang Function field to set language for taxes and chat
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user