From 1bc13cc317118777d0ea54070c76d1557e540227 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 8 Jan 2024 18:49:34 +0100 Subject: [PATCH] [FIX] membership_extension: Don't return early + remove condition - Don't return before consuming whole recordset. - The 'cancelled' state is no covered upstream through 'reverse_entry_id'. --- membership_extension/models/membership_line.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/membership_extension/models/membership_line.py b/membership_extension/models/membership_line.py index 18646c40b..0aef1b046 100644 --- a/membership_extension/models/membership_line.py +++ b/membership_extension/models/membership_line.py @@ -43,16 +43,14 @@ def _onchange_membership_date(self): self.date_to = date_to def _compute_state(self): - for line in self: - if isinstance(line.id, models.NewId) or not line.account_invoice_id: - line.state = line.state or "none" - elif ( - line.account_invoice_id.state == "posted" - and line.account_invoice_id.payment_state == "reversed" - ): - line.state = "canceled" - else: - return super(MembershipLine, line)._compute_state() + """Allow to keep the current manual state if no linked invoice.""" + no_invoice_lines = self.filtered( + lambda line: isinstance(line.id, models.NewId) + or not line.account_invoice_id + ) + for line in no_invoice_lines: + line.state = line.state or "none" + return super(MembershipLine, self - no_invoice_lines)._compute_state() # Empty method _inverse_state def _inverse_state(self):