[FIX] hr_holidays: don't remove nothing on new user creation
This commit avoids potential concurrent updates if you create 2 users simultaneously. The method is called by an override of the method create from res.users. In production, we have concurrent update because it writes to the group no matter if someone is to remove or not. And orm will do a query in all cases to update the write_date, ... Now we only execute a query if somebody need to be removed. closes odoo/odoo#111031 X-original-commit: 5a0cf8bc8a9747e18eca5ddd3f135eb0cfcfd13d Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -70,8 +70,10 @@ class User(models.Model):
|
||||
['leave_manager_id'],
|
||||
['leave_manager_id'])
|
||||
responsibles_to_remove_ids = set(self.ids) - {x['leave_manager_id'][0] for x in res}
|
||||
approver_group.write({
|
||||
'users': [(3, manager_id) for manager_id in responsibles_to_remove_ids]})
|
||||
if responsibles_to_remove_ids:
|
||||
approver_group.write({
|
||||
'users': [(3, manager_id) for manager_id in responsibles_to_remove_ids]
|
||||
})
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
|
||||
Reference in New Issue
Block a user