From 7f775f0677eab9791d8ba0a70cfeb24859030cef Mon Sep 17 00:00:00 2001 From: Toufik Benjaa Date: Wed, 22 Aug 2018 12:13:31 +0200 Subject: [PATCH] [FIX] hr_expense/holidays: approval issue if manager in different company - When trying to retrieve the manager of an employee who is in a different company, an access right error appears. This commit fixes this issue. --- addons/hr_expense/models/hr_expense.py | 2 +- addons/hr_holidays/models/hr_leave_allocation.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index a0948a43ebc..41b6d534d57 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -651,6 +651,6 @@ class HrExpenseSheet(models.Model): for expense_report in self.filtered(lambda hol: hol.state == 'submit'): self.activity_schedule( 'hr_expense.mail_act_expense_approval', fields.Date.today(), - user_id=expense_report._get_responsible_for_approval().id) + user_id=expense_report.sudo()._get_responsible_for_approval().id) self.filtered(lambda hol: hol.state == 'approve').activity_feedback(['hr_expense.mail_act_expense_approval']) self.filtered(lambda hol: hol.state == 'cancel').activity_unlink(['hr_expense.mail_act_expense_approval']) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index 82d1544acb5..17cfddd53a9 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -340,12 +340,12 @@ class HolidaysAllocation(models.Model): elif allocation.state == 'confirm': allocation.activity_schedule( 'hr_holidays.mail_act_leave_allocation_approval', fields.Date.today(), - user_id=allocation._get_responsible_for_approval().id) + user_id=allocation.sudo()._get_responsible_for_approval().id) elif allocation.state == 'validate1': allocation.activity_feedback(['hr_holidays.mail_act_leave_allocation_approval']) allocation.activity_schedule( 'hr_holidays.mail_act_leave_allocation_second_approval', fields.Date.today(), - user_id=allocation._get_responsible_for_approval().id) + user_id=allocation.sudo()._get_responsible_for_approval().id) elif allocation.state == 'validate': to_do |= allocation elif allocation.state == 'refuse':