[FIX] hr_expense: create expense from email with taxes

Have an expense product with a supplier tax on it

Write an email to be caught by the thread model to create an expense for that product

Before this commit, the tax was not set up on the expense

After this commit, it is

OPW 1908596

closes odoo/odoo#29061
This commit is contained in:
Lucas Perais (lpe)
2018-11-27 11:00:55 +00:00
parent 23313583b2
commit b1828c01d8
2 changed files with 21 additions and 0 deletions
+1
View File
@@ -395,6 +395,7 @@ class HrExpense(models.Model):
'employee_id': employee.id,
'product_id': product.id,
'product_uom_id': product.uom_id.id,
'tax_ids': [(4, tax.id, False) for tax in product.supplier_taxes_id],
'quantity': 1,
'unit_amount': price,
'company_id': employee.company_id.id,
+20
View File
@@ -87,3 +87,23 @@ class TestCheckJournalEntry(TransactionCase):
self.assertAlmostEquals(line.debit, 636.36)
else:
self.assertAlmostEquals(line.debit, 63.64)
def test_expense_from_email(self):
user_demo = self.env.ref('base.user_demo')
self.tax.price_include = False
message_parsed = {
'message_id': 'the-world-is-a-ghetto',
'subject': '[AT] 9876',
'email_from': 'demo@yourcompany.example.com',
'to': 'catchall@yourcompany.com',
'body': "Don't you know, that for me, and for you",
'attachments': [],
}
expense = self.env['hr.expense'].message_new(message_parsed)
self.assertEquals(expense.product_id, self.product)
self.assertEquals(expense.tax_ids.ids, [self.tax.id])
self.assertEquals(expense.total_amount, 10863.60)
self.assertTrue(expense.employee_id in user_demo.employee_ids)