[FIX] hr_expense: unit_amount erase when set product_id

When an expense is create from email, if the product is not set, when you want set the product it is erase the unit price.

closes odoo/odoo#50397

X-original-commit: 74736914bb4d39947523f3dcd5e9d9455f4ee768
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Florent de Labarre
2020-04-30 10:03:41 +00:00
committed by Yannick Tivisse
parent a5e70e6fdc
commit 918a5f2cc0
+2 -1
View File
@@ -162,7 +162,8 @@ class HrExpense(models.Model):
for expense in self.filtered('product_id'):
expense = expense.with_company(expense.company_id)
expense.name = expense.name or expense.product_id.display_name
expense.unit_amount = expense.product_id.price_compute('standard_price')[expense.product_id.id]
if not expense.attachment_number or (expense.attachment_number and not expense.unit_amount):
expense.unit_amount = expense.product_id.price_compute('standard_price')[expense.product_id.id]
expense.product_uom_id = expense.product_id.uom_id
expense.tax_ids = expense.product_id.supplier_taxes_id.filtered(lambda tax: tax.company_id == expense.company_id) # taxes only from the same company
account = expense.product_id.product_tmpl_id._get_product_accounts()['expense']