[FIX] hr_expense: fix subtotal for journal items

Steps:
Create a expense with product having no cost and having the
total amount directly added from expense sheet.
then create an innvoice.

Issue:
While adding journal lines in hr expense the amount per unit
was calculated as the total amount of product such as quantity into the
price per unit inside the invoice.

Cause:
expense's total_amount was passed as price_unit instead of expense's unit_amount
and due to that total amount was multiply by qty so wrong value was passed.

Fix:
If unit_amount of product is non-zero then pass the unit amoun for invoice or
pass the total_amount if unit_amount does not exist.

task-3000758

X-original-commit: d47ca52a2cb8eb7146094e7d172f41f6aa3621a2
Part-of: odoo/odoo#102768
This commit is contained in:
Pratik Awasthi
2022-10-08 13:30:23 +02:00
committed by Barad Mahendra
parent 8d535edd9f
commit cdd38f770a
+1 -1
View File
@@ -602,7 +602,7 @@ Or send your receipts at <a href="mailto:%(email)s?subject=Lunch%%20with%%20cust
Command.create({
'name': expense.employee_id.name + ': ' + expense.name.split('\n')[0][:64],
'quantity': expense.quantity or 1,
'price_unit': expense.total_amount,
'price_unit': expense.unit_amount if expense.unit_amount != 0 else expense.total_amount,
'product_id': expense.product_id.id,
'product_uom_id': expense.product_uom_id.id,
'analytic_distribution': expense.analytic_distribution,