details:   https://code.tryton.org/tryton/commit/c0625ed0d3bb
branch:    default
user:      Cédric Krier <[email protected]>
date:      Fri Mar 06 10:50:48 2026 +0100
description:
        Use party lang Function field to set language for taxes and chat
diffstat:

 modules/account_invoice/invoice.py |  8 ++++----
 modules/purchase/purchase.py       |  8 ++++----
 modules/sale/sale.py               |  8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diffs (81 lines):

diff -r eb497ccc1e01 -r c0625ed0d3bb modules/account_invoice/invoice.py
--- a/modules/account_invoice/invoice.py        Fri Mar 27 16:48:18 2026 +0100
+++ b/modules/account_invoice/invoice.py        Fri Mar 06 10:50:48 2026 +0100
@@ -1171,11 +1171,11 @@
             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 @@
     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 -r eb497ccc1e01 -r c0625ed0d3bb modules/purchase/purchase.py
--- a/modules/purchase/purchase.py      Fri Mar 27 16:48:18 2026 +0100
+++ b/modules/purchase/purchase.py      Fri Mar 06 10:50:48 2026 +0100
@@ -485,11 +485,11 @@
                 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 @@
     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 -r eb497ccc1e01 -r c0625ed0d3bb modules/sale/sale.py
--- a/modules/sale/sale.py      Fri Mar 27 16:48:18 2026 +0100
+++ b/modules/sale/sale.py      Fri Mar 06 10:50:48 2026 +0100
@@ -605,11 +605,11 @@
                 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 @@
     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

Reply via email to