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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion membership_extension/models/membership_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

for line in self:
if isinstance(line.id, models.NewId) or not line.account_invoice_id:
line.state = line.state or "none"
Expand All @@ -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()


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