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()