Skip to content

Commit

Permalink
Merge PR #182 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 17, 2024
2 parents 5893f5e + b2a7df5 commit eec7d58
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions membership_extension/models/membership_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ def _onchange_membership_date(self):
self.date_to = date_to

def _compute_state(self):
# pylint: disable=missing-return
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()
no_invoice_lines = self.filtered(
lambda line: isinstance(line.id, models.NewId)
or not line.account_invoice_id
)
cancelled_lines = self.filtered(
lambda line: line.account_invoice_id.state == "posted"
and line.account_invoice_id.payment_state == "reversed"
)
cancelled_lines.state = "canceled"
for line in no_invoice_lines:
line.state = line.state or "none"
return super(
MembershipLine, self - no_invoice_lines - cancelled_lines
)._compute_state()

# Empty method _inverse_state
def _inverse_state(self):
Expand Down

0 comments on commit eec7d58

Please sign in to comment.