Remove foreign-key on create_uid and write_uid
Instead prevent delete of any user to keep logging information. issue4925 review24301002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Remove foreign-key on create_uid and write_uid
|
||||
* Prevent deletion of any user
|
||||
* Manage PostgreSQL schema
|
||||
* Remove colors attribute on tree view
|
||||
* Remove style on Report
|
||||
|
||||
@@ -188,7 +188,11 @@ class ModelSQL(ModelStorage):
|
||||
ref = field.model_name.replace('.', '_')
|
||||
else:
|
||||
ref = pool.get(field.model_name)._table
|
||||
table.add_fk(field_name, ref, field.ondelete)
|
||||
if field_name in ['create_uid', 'write_uid']:
|
||||
# migration from 3.6
|
||||
table.drop_fk(field_name)
|
||||
else:
|
||||
table.add_fk(field_name, ref, field.ondelete)
|
||||
|
||||
table.index_action(
|
||||
field_name, action=field.select and 'add' or 'remove')
|
||||
|
||||
+6
-11
@@ -103,12 +103,11 @@ class User(ModelSQL, ModelView):
|
||||
'groups',
|
||||
]
|
||||
cls._error_messages.update({
|
||||
'rm_root': ('You can not remove the root user\n'
|
||||
'as it is used internally for resources\n'
|
||||
'created by the system '
|
||||
'(updates, module installation, ...)'),
|
||||
'wrong_password': 'Wrong password!',
|
||||
})
|
||||
'delete_forbidden': ('Users can not be deleted '
|
||||
'for logging purpose.\n'
|
||||
'Instead you must inactivate them.'),
|
||||
'wrong_password': 'Wrong password!',
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
@@ -267,11 +266,7 @@ class User(ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def delete(cls, users):
|
||||
if [u.id for u in users if u.id == 0]:
|
||||
cls.raise_user_error('rm_root')
|
||||
super(User, cls).delete(users)
|
||||
# Restart the cache for _get_login
|
||||
cls._get_login_cache.clear()
|
||||
cls.raise_user_error('delete_forbidden')
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
|
||||
Reference in New Issue
Block a user