summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/hr_timesheet/models/hr_timesheet.py2
-rw-r--r--addons/hr_timesheet/tests/test_timesheet.py5
2 files changed, 3 insertions, 4 deletions
diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py
index 50fd2bce355..bd4338673c1 100644
--- a/addons/hr_timesheet/models/hr_timesheet.py
+++ b/addons/hr_timesheet/models/hr_timesheet.py
@@ -94,7 +94,7 @@ class AccountAnalyticLine(models.Model):
def write(self, values):
# If it's a basic user then check if the timesheet is his own.
- if not self.user_has_groups('hr_timesheet.group_hr_timesheet_approver') and any(self.env.user.id != analytic_line.user_id.id for analytic_line in self):
+ if not (self.user_has_groups('hr_timesheet.group_hr_timesheet_approver') or self.env.su) and any(self.env.user.id != analytic_line.user_id.id for analytic_line in self):
raise AccessError(_("You cannot access timesheets that are not yours."))
values = self._timesheet_preprocess(values)
diff --git a/addons/hr_timesheet/tests/test_timesheet.py b/addons/hr_timesheet/tests/test_timesheet.py
index 64e7f13d2af..4113b052ea0 100644
--- a/addons/hr_timesheet/tests/test_timesheet.py
+++ b/addons/hr_timesheet/tests/test_timesheet.py
@@ -267,10 +267,9 @@ class TestTimesheet(TestCommonTimesheet):
})
timesheets = timesheet_1 + timesheet_2
- # increase unit_amount to trigger amount recomputation
with self.assertRaises(AccessError):
- # because the employee 1 is the sudo and he doesn't have the access right to update timesheet of employee 2
- timesheets.sudo().write({
+ # should raise since employee 1 doesn't have the access rights to update employee's 2 timesheet
+ timesheets.with_user(self.empl_employee.user_id).write({
'unit_amount': 2,
})