From 918a5f2cc022994ee08bead25dd79072bf3fba87 Mon Sep 17 00:00:00 2001 From: Florent de Labarre Date: Fri, 27 Mar 2020 14:11:17 +0000 Subject: [PATCH] [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) --- addons/hr_expense/models/hr_expense.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index cb4f6c450c2..70832b2af28 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -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']