Skip to content

Commit

Permalink
[IMP] Expense, Timesheets: toast feedback to user
Browse files Browse the repository at this point in the history
Display notification to give feedback to user.
And reload the view with the params "next".

closes odoo#59274

Taskid: 2344276
Related: odoo/enterprise#13846
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
  • Loading branch information
TomDevK committed Oct 21, 2020
1 parent 1314abb commit bd33f28
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions addons/hr_expense/models/hr_expense.py
Expand Up @@ -972,9 +972,26 @@ def approve_expense_sheets(self):
if not self.env.user in current_managers and not self.user_has_groups('hr_expense.group_hr_expense_user') and self.employee_id.expense_manager_id != self.env.user:
raise UserError(_("You can only approve your department expenses"))

responsible_id = self.user_id.id or self.env.user.id
self.write({'state': 'approve', 'user_id': responsible_id})
responsible_id = self.user_id.id or self.env.user.id
notification = {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('There are no expense reports to approve.'),
'type': 'warning',
'sticky': False, #True/False will display for few seconds if false
},
}
sheet_to_approve = self.filtered(lambda s: s.state in ['submit', 'draft'])
if sheet_to_approve:
notification['params'].update({
'title': _('The expense reports were successfully approved.'),
'type': 'success',
'next': {'type': 'ir.actions.act_window_close'},
})
sheet_to_approve.write({'state': 'approve', 'user_id': responsible_id})
self.activity_update()
return notification

def paid_expense_sheets(self):
self.write({'state': 'done'})
Expand Down

0 comments on commit bd33f28

Please sign in to comment.