Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] membership_extension: No return on super call #159

Conversation

hhgabelgaard
Copy link
Contributor

With the return we only got the state computed for the first line in self

With the return we only got the state computed for the first line in self
@@ -43,6 +43,8 @@ def _onchange_membership_date(self):
self.date_to = date_to

def _compute_state(self):
# Compute methods should not return
# pylint: disable=missing-return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, just return True at the end.

@@ -52,7 +54,7 @@ def _compute_state(self):
):
line.state = "canceled"
else:
return super(MembershipLine, line)._compute_state()
super(MembershipLine, line)._compute_state()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more performant way would be to avoid splitting the super line by line. Something like:

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")
for line in no_invoice_lines:
    line.state = line.state or "none"
cancelled_lines.state = "cancelled"
return super(MembershipLine, (self - no_invoice_lines - cancelled_lines)._compute_state()

@pedrobaeza
Copy link
Member

Superseded by #163

@pedrobaeza pedrobaeza closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants