[FIX] sale: fix amount in Sales Report

Simply create an SO with more than 1 Qty and deliver. An untaxed amount
is shown on the SO.
Check in Sales > Reporting > Sales > Pivot view, the Untaxed amount
Invoiced and Untaxed amount to invoice Measures. They show the right
amount.
Make a partial return from the original SO and validate.
Reduce the quantity on the sale order line.

The sales report is not updated with the right untaxed amount to
invoice. This occur because when the sale order line have an increased
qty_ordered a chain of event is triggered which included the
recomputation of the untaxed_amount_to_invoice which does not occur on
decrese.

Adding the product_uom_qty to recompute triggers fix the issue

opw-2213996

closes odoo/odoo#48282

X-original-commit: f8a5366ea650c1a2ac4ad3a42da7da4a34758d60
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2020-03-24 16:22:14 +00:00
parent 4e9179dcfe
commit ab7b3dd40d
+1 -1
View File
@@ -1454,7 +1454,7 @@ class SaleOrderLine(models.Model):
amount_invoiced -= invoice_line.currency_id._convert(invoice_line.price_subtotal, line.currency_id, line.company_id, invoice_date)
line.untaxed_amount_invoiced = amount_invoiced
@api.depends('state', 'price_reduce', 'product_id', 'untaxed_amount_invoiced', 'qty_delivered')
@api.depends('state', 'price_reduce', 'product_id', 'untaxed_amount_invoiced', 'qty_delivered', 'product_uom_qty')
def _compute_untaxed_amount_to_invoice(self):
""" Total of remaining amount to invoice on the sale order line (taxes excl.) as
total_sol - amount already invoiced