diff --git a/addons/hr_expense/__manifest__.py b/addons/hr_expense/__manifest__.py index e6fc131ba8a..77bea25f140 100644 --- a/addons/hr_expense/__manifest__.py +++ b/addons/hr_expense/__manifest__.py @@ -32,8 +32,8 @@ This module also uses analytic accounting and is compatible with the invoice on 'security/ir.model.access.csv', 'data/hr_expense_data.xml', 'data/hr_expense_sequence.xml', - 'wizard/hr_expense_refuse_reason.xml', - 'wizard/hr_expense_register_payment.xml', + 'wizard/hr_expense_refuse_reason_views.xml', + 'wizard/hr_expense_sheet_register_payment.xml', 'views/hr_expense_views.xml', 'security/ir_rule.xml', 'report/report_expense_sheet.xml', diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index a5a26185b50..d30810eeb1e 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -44,6 +44,7 @@ class HrExpense(models.Model): help="Status of the expense.") sheet_id = fields.Many2one('hr.expense.sheet', string="Expense Report", readonly=True, copy=False) reference = fields.Char(string="Bill Reference") + is_refused = fields.Boolean(string="Explicitely Refused by manager or acccountant", readonly=True, copy=False) @api.depends('sheet_id', 'sheet_id.account_move_id', 'sheet_id.state') def _compute_state(self): @@ -307,6 +308,13 @@ class HrExpense(models.Model): res['context'] = {'default_res_model': 'hr.expense', 'default_res_id': self.id} return res + @api.multi + def refuse_expense(self,reason): + self.write({'is_refused': True}) + self.sheet_id.write({'state': 'cancel'}) + self.sheet_id.message_post_with_view('hr_expense.hr_expense_template_refuse_reason', + values={'reason': reason, 'is_sheet':False, 'name':self.name}) + @api.model def get_empty_list_help(self, help_message): if help_message: @@ -392,7 +400,7 @@ class HrExpenseSheet(models.Model): ('done', 'Paid'), ('cancel', 'Refused') ], string='Status', index=True, readonly=True, track_visibility='onchange', copy=False, default='submit', required=True, - help='Expense Report State') + help='Expense Report State') employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'submit': [('readonly', False)]}, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)) address_id = fields.Many2one('res.partner', string="Employee Home Address") payment_mode = fields.Selection([("own_account", "Employee (to reimburse)"), ("company_account", "Company")], related='expense_line_ids.payment_mode', default='own_account', readonly=True, string="Payment By") @@ -512,11 +520,11 @@ class HrExpenseSheet(models.Model): self.attachment_number = sum(self.expense_line_ids.mapped('attachment_number')) @api.multi - def refuse_expenses(self, reason): + def refuse_sheet(self, reason): self.write({'state': 'cancel'}) for sheet in self: - body = (_("Your Expense %s has been refused.
") % (sheet.name, reason)) - sheet.message_post(body=body) + sheet.message_post_with_view('hr_expense.hr_expense_template_refuse_reason', + values={'reason': reason ,'is_sheet':True ,'name':self.name}) @api.multi def approve_expense_sheets(self): @@ -528,6 +536,7 @@ class HrExpenseSheet(models.Model): @api.multi def reset_expense_sheets(self): + self.mapped('expense_line_ids').write({'is_refused': False}) return self.write({'state': 'submit'}) @api.multi diff --git a/addons/hr_expense/security/ir_rule.xml b/addons/hr_expense/security/ir_rule.xml index e86d91211d8..7148e828231 100644 --- a/addons/hr_expense/security/ir_rule.xml +++ b/addons/hr_expense/security/ir_rule.xml @@ -6,7 +6,10 @@ Manager Expense [(1, '=', 1)] - + Employee Expense diff --git a/addons/hr_expense/views/hr_expense.xml b/addons/hr_expense/views/hr_expense.xml index 03d0900c00a..d6b3e3ce828 100644 --- a/addons/hr_expense/views/hr_expense.xml +++ b/addons/hr_expense/views/hr_expense.xml @@ -7,5 +7,11 @@ + diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 362c37f1fc1..fe09c69d18c 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -225,26 +225,6 @@ - - Refused Expenses - hr.expense - tree,kanban,form,graph,pivot - - [('employee_id.user_id', '=', uid)] - {'search_default_refused': 1} - -

- The steps to process expenses are: -

    -
  1. You record expenses,
  2. -
  3. Periodically, you submit expenses report to your manager,
  4. -
  5. Once approved, your expense report, goes to the accounting,
  6. -
  7. The accountant validates entries and reimburse you.
  8. -
-

-
-
- product.template.expense.form product.template @@ -387,7 +367,7 @@ hr.expense.sheet.tree hr.expense.sheet - + @@ -407,11 +387,10 @@
@@ -443,8 +422,8 @@ - - + + @@ -455,6 +434,8 @@