From 2179401726673be78975e87b80a09fbd89f108f3 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Thu, 28 Jul 2022 08:33:32 +0000 Subject: [PATCH] [FIX] sale_loyalty: fix invalid invoice status The invoice status was badly computed since the loyalty refactor due to the use of the wrong value when comparing to the previous state. (to_invoice instead of to invoice) TaskId-2936708 closes odoo/odoo#97002 X-original-commit: e88dcd26eebf0e527929a0c48e259895822cf23e Signed-off-by: William Braeckman (wbr) --- addons/sale_loyalty/models/sale_order.py | 2 +- addons/sale_loyalty/tests/test_sale_invoicing.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/sale_loyalty/models/sale_order.py b/addons/sale_loyalty/models/sale_order.py index 6acb431ca4d..94f8f4c74c3 100644 --- a/addons/sale_loyalty/models/sale_order.py +++ b/addons/sale_loyalty/models/sale_order.py @@ -413,7 +413,7 @@ class SaleOrder(models.Model): # if the created invoice will only contain the promotion line super()._get_invoice_status() for order in self: - if order.invoice_status != 'to_invoice': + if order.invoice_status != 'to invoice': continue if not any(not line.is_reward_line and line.invoice_status == 'to invoice' for line in order.order_line): order.invoice_status = 'no' diff --git a/addons/sale_loyalty/tests/test_sale_invoicing.py b/addons/sale_loyalty/tests/test_sale_invoicing.py index 40a4e083faa..d09a7ac553e 100644 --- a/addons/sale_loyalty/tests/test_sale_invoicing.py +++ b/addons/sale_loyalty/tests/test_sale_invoicing.py @@ -49,12 +49,16 @@ class TestSaleInvoicing(TestSaleCouponCommon): invoiceable_lines = order._get_invoiceable_lines() # Product was not delivered, we cannot invoice # the product line nor the promotion line + order._get_invoice_status() + self.assertEqual(order.invoice_status, 'no') self.assertEqual(len(invoiceable_lines), 0) with self.assertRaises(UserError): order._create_invoices() order.order_line[0].qty_delivered = 1 # Product is delivered, the two lines can be invoiced. + order._get_invoice_status() + self.assertEqual(order.invoice_status, 'to invoice') invoiceable_lines = order._get_invoiceable_lines() self.assertEqual(order.order_line, invoiceable_lines) account_move = order._create_invoices()