[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
This commit is contained in:
committed by
Nicolas Martinelli
parent
518ed13602
commit
8baee81c79
@@ -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.'))
|
||||
raise ValidationError(_('You cannot report expenses with different payment modes.'))
|
||||
|
||||
Reference in New Issue
Block a user