From 40d4fe61ac337bb3cdce29debe10ea8a7156afa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 8 Mar 2024 12:29:03 +0100 Subject: [PATCH] Set invoice line state to paid when invoice is cancelled with cancel move Such invoice line should be considered as booked for example to compute the invoiced quantity of stock move. Closes #13085 --- modules/account_invoice/invoice.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 889cd13131..7f85767dda 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -2428,8 +2428,12 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): @fields.depends('invoice', '_parent_invoice.state') def on_change_with_invoice_state(self, name=None): if self.invoice: - return self.invoice.state - return 'draft' + state = self.invoice.state + if state == 'cancelled' and self.invoice.cancel_move: + state = 'paid' + else: + state = 'draft' + return state @fields.depends('invoice', '_parent_invoice.party', 'party') def on_change_with_party_lang(self, name=None):