[FIX] hr_expense: wrong company account when creating from mail

In a multicompany environment, when a expense is created from the
expense email alias, the expense account is computed with SUPERUSER
context, so depending on the SUPERUSER set company, we could get
a mismatch of expense and employee's company and the account one, wich
causes a subsequent error when trying to post the expense.

closes odoo/odoo#65413

X-original-commit: da758c44b19a9339f0c0b1b6a74c11e3e5491a64
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Co-authored-by: simongoffin <sig@odoo.com>
This commit is contained in:
david
2021-02-02 13:30:55 +00:00
committed by Goffin Simon
co-authored by simongoffin
parent de58031589
commit 1843a1ae4d
+4
View File
@@ -667,6 +667,10 @@ Or send your receipts at <a href="mailto:%(email)s?subject=Lunch%%20with%%20cust
if not company: # ultimate fallback, since company_id is required on expense
company = self.env.company
# The expenses alias is the same for all companies, we need to set the proper context
# To select the product account
self = self.with_company(company)
product, price, currency_id, expense_description = self._parse_expense_subject(expense_description, currencies)
vals = {
'employee_id': employee.id,