diff --git a/TODO b/TODO index 7fadb2d973..5f8b084ade 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,6 @@ - Allow to create fields from the client interface - Fix the order of views that inherits (must be the module dependency order) - Improve encoding of default properties -- Use real view in get_preferences_fields_view of res.user - Add on one2many a domain per field of the relation - Use determined action name in workflow like for default value - Add check for index and constraint name lenght (limit 31) diff --git a/trytond/res/user.py b/trytond/res/user.py index 8cdb9c49ef..23f0c4bd2b 100644 --- a/trytond/res/user.py +++ b/trytond/res/user.py @@ -243,51 +243,34 @@ class User(OSV): self.write(cursor, 0, user, values_clean, context=context) def get_preferences_fields_view(self, cursor, user, context=None): + model_data_obj = self.pool.get('ir.model.data') lang_obj = self.pool.get('ir.lang') - res = {} - fields_names = self._preferences_fields + self._context_fields - fields_names.pop(fields_names.index('status_bar')) - fields = self.fields_get(cursor, user, - fields_names=fields_names, context=context) - xml = '' \ - '
' - tree = etree.fromstring(xml) - arch, fields = self._view_look_dom_arch(cursor, - user, tree, 'form', context=context) - for field in fields: + model_data_ids = model_data_obj.search(cursor, user, [ + ('fs_id', '=', 'user_view_form_preferences'), + ('module', '=', 'res'), + ('inherit', '=', False), + ], limit=1, context=context) + model_data = model_data_obj.browse(cursor, user, model_data_ids[0], + context=context) + res = self.fields_view_get(cursor, user, view_id=model_data.db_id, + context=context) + res = copy.deepcopy(res) + for field in res['fields']: if field not in ('groups', 'language_direction'): - fields[field]['readonly'] = False + res['fields'][field]['readonly'] = False else: - fields[field]['readonly'] = True - res['arch'] = arch - if 'language' in fields: - del fields['language']['relation'] - fields['language']['selection'] = [] + res['fields'][field]['readonly'] = True + if 'language' in res['fields']: + del res['fields']['language']['relation'] + res['fields']['language']['selection'] = [] lang_ids = lang_obj.search(cursor, user, ['OR', ('translatable', '=', True), ('code', '=', 'en_US'), ], context=None) for lang in lang_obj.browse(cursor, user, lang_ids, context=context): - fields['language']['selection'].append((lang.code, lang.name)) - res['fields'] = fields + res['fields']['language']['selection'].append( + (lang.code, lang.name)) return res def timezones(self, cursor, user, context=None): diff --git a/trytond/res/user.xml b/trytond/res/user.xml index 319363237e..3d94eed05d 100644 --- a/trytond/res/user.xml +++ b/trytond/res/user.xml @@ -54,6 +54,43 @@ this repository contains the full copyright notices and license terms. --> ]]> +