From 8baee81c7990d8f2b574bdd566b7b9cb8b5a63cb Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 30 Apr 2018 11:30:37 +0200 Subject: [PATCH] [FIX] hr_expense: account on expense - Set a specific expense account on an expense product - Send an email to the expense alias The specific expense account is not used; a default account is used instead. opw-1838174 --- addons/hr_expense/models/hr_expense.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 0dbdd5c1c68..7031aec788b 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -372,6 +372,7 @@ class HrExpense(models.Model): expense_description = expense_description.replace(product_code.group(), '') products = self.env['product.product'].search([('default_code', 'ilike', product_code.group(1))]) or default_product product = products.filtered(lambda p: p.default_code == product_code.group(1)) or products[0] + account = product.product_tmpl_id._get_product_accounts()['expense'] pattern = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' # Match the last occurence of a float in the string @@ -398,6 +399,8 @@ class HrExpense(models.Model): 'unit_amount': price, 'company_id': employee.company_id.id, }) + if account: + custom_values['account_id'] = account.id return super(HrExpense, self).message_new(msg_dict, custom_values) class HrExpenseSheet(models.Model): @@ -600,4 +603,4 @@ class HrExpenseSheet(models.Model): def _check_payment_mode(self): payment_mode = set(self.expense_line_ids.mapped('payment_mode')) if len(payment_mode) > 1: - raise ValidationError(_('You cannot report expenses with different payment modes.')) \ No newline at end of file + raise ValidationError(_('You cannot report expenses with different payment modes.'))