From a6ca15fa9de698e86079f7bd131af90d14c00587 Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Fri, 8 Jul 2022 19:29:02 +0000 Subject: [PATCH] [FIX] hr_gamification: grant badge to employee of another company This is a side-effect of commit [1]. Consider we have access to companies A and B, and current active company is A. Before the mentioned commit we were able to grand a badge to an employee in company B. We should keep that behavior, as long as the current user have also access to company B. [1]:https://github.com/odoo/odoo/commit/b5b105eabd90419a5856e8279e277743c5915fc9 closes odoo/odoo#95757 X-original-commit: 9590b910ccaf92d0466b27ce3c4dda3c567f8676 Signed-off-by: Kevin Baptiste --- addons/hr_gamification/models/gamification.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hr_gamification/models/gamification.py b/addons/hr_gamification/models/gamification.py index 0fc3fcb9440..54443e437b4 100644 --- a/addons/hr_gamification/models/gamification.py +++ b/addons/hr_gamification/models/gamification.py @@ -14,7 +14,8 @@ class GamificationBadgeUser(models.Model): @api.constrains('employee_id') def _check_employee_related_user(self): for badge_user in self: - if badge_user.employee_id not in badge_user.user_id.employee_ids: + if badge_user.employee_id not in badge_user.user_id.\ + with_context(allowed_company_ids=self.env.user.company_ids.ids).employee_ids: raise ValidationError(_('The selected employee does not correspond to the selected user.')) def action_open_badge(self):