details:   
https://code.tryton.org/communication/authentication_none/commit/1bee597854f7
branch:    default
user:      Cédric Krier <[email protected]>
date:      Fri May 02 00:59:09 2025 +0200
description:
        Remove user's language preference

        Instead we rely on the client language.
diffstat:

 res.py |  16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diffs (30 lines):

diff -r 45cf263fbb84 -r 1bee597854f7 res.py
--- a/res.py    Sat Nov 18 23:16:00 2023 +0100
+++ b/res.py    Fri May 02 00:59:09 2025 +0200
@@ -2,6 +2,7 @@
 # copyright notices and license terms.
 
 from trytond.pool import PoolMeta
+from trytond.transaction import Transaction
 
 
 class User(metaclass=PoolMeta):
@@ -12,3 +13,18 @@
         user_id, _, _ = cls._get_login(login)
         if user_id:
             return user_id
+
+    @classmethod
+    def _get_preferences(cls, user, context_only=False):
+        preferences = super()._get_preferences(user, context_only=context_only)
+        preferences['language'] = Transaction().context.get('language')
+        preferences.pop('language_direction', None)
+        preferences.pop('locale', None)
+        return preferences
+
+    @classmethod
+    def get_preferences_fields_view(cls):
+        result = super().get_preferences_fields_view()
+        if 'language' in result['fields']:
+            result['fields']['language']['readonly'] = True
+        return result

Reply via email to