From 6b86fe1fdbcd84a6c5a4727c3487de721918328b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Gonz=C3=A1lez?= Date: Wed, 7 Feb 2024 19:08:16 +0000 Subject: [PATCH] [FIX] website_slides: auto-enroll correctly when editing user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user is modified to grant access to new groups, user is auto-enrolled to all slide courses that have a auto-enroll policy for any of the new groups. However, that auto-enrolling process was not working correctly due to how values to be written to the user are coming. In order to know what are the actual new groups, values need to be pre-processed, which was not being done. This commit fixes the above issue by pre-processing written values before extracting new groups. closes odoo/odoo#153634 X-original-commit: e27be4a81c304c2d749b4417d2184cfed07eddf3 Signed-off-by: Warnon Aurélien (awa) --- addons/website_slides/models/res_users.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/website_slides/models/res_users.py b/addons/website_slides/models/res_users.py index b9042c633bd..d4ff8ac4f6f 100644 --- a/addons/website_slides/models/res_users.py +++ b/addons/website_slides/models/res_users.py @@ -20,9 +20,10 @@ class Users(models.Model): def write(self, vals): """ Trigger automatic subscription based on updated user groups """ res = super(Users, self).write(vals) - if vals.get('groups_id'): - added_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4] - added_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]] + sanitized_vals = self._remove_reified_groups(vals) + if sanitized_vals.get('groups_id'): + added_group_ids = [command[1] for command in sanitized_vals['groups_id'] if command[0] == 4] + added_group_ids += [id for command in sanitized_vals['groups_id'] if command[0] == 6 for id in command[2]] self.env['slide.channel'].sudo().search([('enroll_group_ids', 'in', added_group_ids)])._action_add_members(self.mapped('partner_id')) return res