From b463c956b414f483a9e5f9b20bd08b97b435fe8e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 11 Mar 2020 10:02:10 +0000 Subject: [PATCH] [FIX] purchase: invoice status 1. Create a product A with 'Control Policy' set to 'On received quantities' 2. Create a PO for 10 units => status is `no` 3. Validate the PO => status is `no` 4. Receive 5 units => status is `to invoice` 5. Invoice 5 units => status is `invoiced` 6. Receive the remaining quantity => status is `to invoice` 7. Invoice the remaining quantity => status is `invoiced` There is an inconsistency between steps 3 and 5: there is pending material to receive, but the status is different. This is due to the fact the `order.invoice_ids` is checked, while it shouldn't affect the computation of the status. The status should be `no` in steps 3 and 5. opw-2206447 closes odoo/odoo#47802 X-original-commit: 15330712d2ea3c16c57e01c236c783a6febd1376 Signed-off-by: Nicolas Martinelli (nim) --- addons/purchase/models/purchase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 194407a7567..57e39572fa4 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -41,7 +41,11 @@ class PurchaseOrder(models.Model): if any(float_compare(line.qty_invoiced, line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received, precision_digits=precision) == -1 for line in order.order_line): order.invoice_status = 'to invoice' - elif all(float_compare(line.qty_invoiced, line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received, precision_digits=precision) >= 0 for line in order.order_line) and order.invoice_ids: + elif all( + (line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received) + and float_compare(line.qty_invoiced, line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received, precision_digits=precision) >= 0 + for line in order.order_line + ): order.invoice_status = 'invoiced' else: order.invoice_status = 'no'