diff --git a/hr_timesheet_sheet/models/hr_timesheet_sheet.py b/hr_timesheet_sheet/models/hr_timesheet_sheet.py index 69b79018a..7474c6198 100644 --- a/hr_timesheet_sheet/models/hr_timesheet_sheet.py +++ b/hr_timesheet_sheet/models/hr_timesheet_sheet.py @@ -392,10 +392,10 @@ def unlink(self): return super().unlink() def _timesheet_subscribe_users(self): - for sheet in self: - if sheet.employee_id.parent_id.user_id: - self.message_subscribe_users( - user_ids=[sheet.employee_id.parent_id.user_id.id]) + for sheet in self.sudo(): + manager = sheet.employee_id.parent_id.user_id.partner_id + if manager: + self.message_subscribe(partner_ids=manager.ids) @api.multi def action_timesheet_draft(self): diff --git a/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py b/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py index 761f0e702..872b31ab5 100644 --- a/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py +++ b/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py @@ -62,9 +62,16 @@ def setUp(self): 'company_ids': [(4, self.company_2.id)], }) + employee_manager = self.employee_model.create({ + 'name': "Test Manager", + 'user_id': self.user_2.id, + 'company_id': self.user.company_id.id, + }) + self.employee = self.employee_model.create({ 'name': "Test User", 'user_id': self.user.id, + 'parent_id': employee_manager.id, 'company_id': self.user.company_id.id, })