Skip to content
Snippets Groups Projects
Unverified Commit f8540501 authored by Martin Trigaux's avatar Martin Trigaux
Browse files

[FIX] hr_expense: verify the constrain server side too

The groups were set only on the view which does not prevent abuses.
The fact that users can bypass the groups on the view is not critical as the
changes are logged but this should be improved nevertheless.

In master, proper record rules should be set.

Closes #20427
parent a63ecee4
No related branches found
No related tags found
No related merge requests found
......@@ -524,6 +524,8 @@ class HrExpenseSheet(models.Model):
@api.multi
def refuse_expenses(self, reason):
if not self.user_has_groups('hr_expense.group_hr_expense_user'):
raise UserError(_("Only HR Officers can refuse expenses"))
self.write({'state': 'cancel'})
for sheet in self:
body = (_("Your Expense %s has been refused.<br/><ul class=o_timeline_tracking_value_list><li>Reason<span> : </span><span class=o_timeline_tracking_value>%s</span></li></ul>") % (sheet.name, reason))
......@@ -531,6 +533,8 @@ class HrExpenseSheet(models.Model):
@api.multi
def approve_expense_sheets(self):
if not self.user_has_groups('hr_expense.group_hr_expense_user'):
raise UserError(_("Only HR Officers can approve expenses"))
self.write({'state': 'approve', 'responsible_id': self.env.user.id})
@api.multi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment