details:   https://code.tryton.org/tryton/commit/b1b42718dbe1
branch:    7.8
user:      Cédric Krier <[email protected]>
date:      Thu Dec 18 21:24:26 2025 +0100
description:
        Ensure get_preferences_fields_view modifies mutable field definitions

        Closes #14433
        (grafted from c90d3613f07e1bfdee2278e8e93ed9c7387d61ad)
diffstat:

 trytond/trytond/res/user.py |  28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)

diffs (66 lines):

diff -r af20060cb27b -r b1b42718dbe1 trytond/trytond/res/user.py
--- a/trytond/trytond/res/user.py       Thu Dec 18 19:18:12 2025 +0100
+++ b/trytond/trytond/res/user.py       Thu Dec 18 21:24:26 2025 +0100
@@ -2,7 +2,6 @@
 # this repository contains the full copyright notices and license terms.
 "User"
 
-import copy
 import datetime
 import hashlib
 import logging
@@ -573,13 +572,12 @@
         Action = pool.get('ir.action')
 
         view_id = ModelData.get_id('res', 'user_view_form_preferences')
-        res = cls.fields_view_get(view_id=view_id)
-        res = copy.deepcopy(res)
-        for field in res['fields']:
-            if field not in ('groups', 'language_direction'):
-                res['fields'][field]['readonly'] = False
-            else:
-                res['fields'][field]['readonly'] = True
+        result = dict(cls.fields_view_get(view_id=view_id))
+        result['fields'] = dict(result['fields'])
+        for name, definition in result['fields'].items():
+            definition = dict(definition)
+            result['fields'][name] = definition
+            definition['readonly'] = name in {'groups', 'language_direction'}
 
         def convert2selection(definition, name):
             del definition[name]['relation']
@@ -589,27 +587,27 @@
             definition[name]['selection'] = selection
             return selection
 
-        if 'language' in res['fields']:
-            selection = convert2selection(res['fields'], 'language')
+        if 'language' in result['fields']:
+            selection = convert2selection(result['fields'], 'language')
             langs = Lang.search(cls.language.domain)
             lang_ids = [l.id for l in langs]
             with Transaction().set_context(translate_name=True):
                 for lang in Lang.browse(lang_ids):
                     selection.append((lang.code, lang.name))
-        if 'action' in res['fields']:
-            selection = convert2selection(res['fields'], 'action')
+        if 'action' in result['fields']:
+            selection = convert2selection(result['fields'], 'action')
             selection.append((None, ''))
             actions = Action.search([])
             for action in actions:
                 selection.append((action.id, action.rec_name))
-        if 'menu' in res['fields']:
-            selection = convert2selection(res['fields'], 'menu')
+        if 'menu' in result['fields']:
+            selection = convert2selection(result['fields'], 'menu')
             actions = Action.search([
                     ('usage', '=', 'menu'),
                     ])
             for action in actions:
                 selection.append((action.id, action.rec_name))
-        return res
+        return result
 
     @classmethod
     def get_groups(cls):

Reply via email to