changeset 69542fdb6e0f in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=69542fdb6e0f
description:
        Allow to update admin user

        issue9700
        review296511002
diffstat:

 trytond/res/user.py  |  13 ++++++++++++-
 trytond/res/user.xml |   5 +++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diffs (57 lines):

diff -r 2cae457fef6f -r 69542fdb6e0f trytond/res/user.py
--- a/trytond/res/user.py       Mon Oct 12 12:59:15 2020 +0200
+++ b/trytond/res/user.py       Mon Oct 12 12:59:44 2020 +0200
@@ -189,6 +189,9 @@
 
     @classmethod
     def __register__(cls, module_name):
+        pool = Pool()
+        ModelData = pool.get('ir.model.data')
+        model_data = ModelData.__table__()
         cursor = Transaction().connection.cursor()
         super(User, cls).__register__(module_name)
         table = cls.__table_handler__(module_name)
@@ -207,6 +210,13 @@
         # Migration from 4.2: Remove required on name
         table.not_null_action('name', action='remove')
 
+        # Migration from 5.6: Set noupdate to admin
+        cursor.execute(*model_data.update(
+                [model_data.noupdate], [True],
+                where=(model_data.model == cls.__name__)
+                & (model_data.module == 'res')
+                & (model_data.fs_id == 'user_admin')))
+
     @staticmethod
     def default_menu():
         pool = Pool()
@@ -458,7 +468,8 @@
                             getattr(user, field).rec_name
             elif cls._fields[field]._type in ('one2many', 'many2many'):
                 res[field] = [x.id for x in getattr(user, field)]
-                if field == 'actions' and user.login == 'admin':
+                admin_id = ModelData.get_id('res.user_admin')
+                if field == 'actions' and user.id == admin_id:
                     config_wizard_id = ModelData.get_id('ir',
                         'act_module_config_wizard')
                     action_id = Action.get_action_id(config_wizard_id)
diff -r 2cae457fef6f -r 69542fdb6e0f trytond/res/user.xml
--- a/trytond/res/user.xml      Mon Oct 12 12:59:15 2020 +0200
+++ b/trytond/res/user.xml      Mon Oct 12 12:59:44 2020 +0200
@@ -2,13 +2,14 @@
 <!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
 this repository contains the full copyright notices and license terms. -->
 <tryton>
-    <data>
+    <data noupdate="1">
         <record model="res.user" id="user_admin">
             <field name="login">admin</field>
             <field name="name">Administrator</field>
-            <field name="signature">Administrator</field>
             <field name="menu" ref="ir.act_menu_tree"/>
         </record>
+    </data>
+    <data>
         <record model="res.user-res.group" id="user_admin_group_admin">
             <field name="user" ref="user_admin"/>
             <field name="group" ref="group_admin"/>

Reply via email to