From 3bc330a323405a59e73cf60c6aeaa0b50247e6b4 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 13 Nov 2019 13:04:16 +0000 Subject: [PATCH] [FIX] sale_stock: canceled invoice - Create a Sale Order with a product - Confirm and deliver the product, create an invoice. - Cancel that invoice, go back to the SO. - Recreate the invoice, you have 2 of them (one cancelled). - Post the second, and try 'Send and print' and 'Preview'. A traceback is raised. The traceback arises because we sort on the `invoice_date`, which is `False` for a canceled invoice. Actually, we should not take into account canceled invoices. opw-2119870 closes odoo/odoo#40215 X-original-commit: 6f304973785669f1c3b297c96eb8be7de7242ebe Signed-off-by: Nicolas Martinelli (nim) --- addons/sale_stock/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_stock/models/account_move.py b/addons/sale_stock/models/account_move.py index 56d38a1c995..ad1b3202f66 100644 --- a/addons/sale_stock/models/account_move.py +++ b/addons/sale_stock/models/account_move.py @@ -32,7 +32,7 @@ class AccountMove(models.Model): # Get the other customer invoices and refunds. ordered_invoice_ids = sale_orders.mapped('invoice_ids')\ - .filtered(lambda i: i.state != 'draft')\ + .filtered(lambda i: i.state not in ['draft', 'cancel'])\ .sorted(lambda i: (i.invoice_date, i.id)) # Get the position of self in other customer invoices and refunds.