Skip to content

[16.0][IMP] membership_extension: remove Member Free membership when Invoice is created#209

Open
clebersantz wants to merge 8 commits intoOCA:16.0from
santzit:16.0-free_member
Open

[16.0][IMP] membership_extension: remove Member Free membership when Invoice is created#209
clebersantz wants to merge 8 commits intoOCA:16.0from
santzit:16.0-free_member

Conversation

@clebersantz
Copy link
Copy Markdown

Fixes #208

Describe the solution you'd like
When an Member is created, it is marked as a Free Member. But, when an Invoice is created, the Membership Line status is change to 'waiting', 'invoiced' and after 'paid', but the Member is still marked as an Free Member.

Describe alternatives you've considered
When an Invoice is created for a Membership product, and the status of the Membership Line is changed to 'waiting', set the Member free_member = False.
This feature make sense to me because, when we create a Invoice to the Member he is not a Free Member anymore and we need to track his invoice/payment for now on.

With this in mind, we need to extend the Partner Membership view as well, to consider Members on kanban list with state 'waiting' too.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @rafaelbn, @yajo,
some modules you are maintaining are being modified, check this out!

@clebersantz
Copy link
Copy Markdown
Author

Hi @rafaelbn, @yajo.

Please take an look at this PR. This change membership free member to an waiting/paid member after invoice creation.

@rafaelbn
Copy link
Copy Markdown
Member

Hello! Please @BhaveshHeliconia could you kindly review this improvement? 🙏🏼 😄

Comment on lines +21 to +22
for partner in line.membership_lines.mapped("partner"):
partner.write({"free_member": False})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: Same but simpler and faster:

Suggested change
for partner in line.membership_lines.mapped("partner"):
partner.write({"free_member": False})
line.membership_lines.partner.free_member = False

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Copy Markdown

@fcvalgar fcvalgar left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this contribution and the time invested. I’m kindly requesting changes before we can approve: after issuing a customer refund the partner does not recover the free flag and the membership ends in canceled. Below are the checks I ran with demo data and their outcomes.

Test 1: Creating a customer invoice with a membership product puts the partner’s membership lines in waiting status – OK
image

Test 2: If the partner was marked as free member, creating a membership invoice automatically unsets free_member – OK
image

Test 3: The “Members” filter in Contacts includes partners in waiting, showing newly invoiced members – OK
image

Test 4: A customer invoice without membership products does not change membership status or free_member – OK
image
image

Test 5: A customer credit note (refund) does not trigger the waiting transition or free_member changes – Not OK
image
image
image
image

  • Scenario & Setup

Partner initially has free_member = True.

A customer invoice (out_invoice) with a membership product is created and posted.

Module logic sets partner’s membership to waiting and flips free_member to False (as intended).

A credit note (reversal) is then created for that invoice and posted.

  • Steps to Reproduce
  1. Mark partner as free: open the partner and set Free Member = True.
  2. Create and post an invoice with a membership product for that partner.
  3. From the invoice, click Reverse (or create a customer credit note referencing it) and post the credit note.
  • Expected Result

The refund should not degrade the partner’s membership to an invalid terminal state.

If the refunded invoice was the only paid/open membership obligation, the partner should recover the previous status (here: free_member = True, membership state back to free).

If there are other open/paid membership obligations, the system should not restore free_member, and the state should reflect those obligations—never leave it stranded as canceled.

  • Actual Result

Partner’s membership lines end in canceled.

free_member remains False (the “free” flag is not restored).

The partner is no longer counted as free nor properly reverted to their prior state.

  • Impact

Associations issuing rectificativas for admin or billing reasons may inadvertently “lose” free members.

Dashboards and filters (e.g., “Members”) under-report free members; follow-up processes (renewals/comms) are skewed.

Test 6: Registering payment for the membership invoice moves the member from waiting to paid by the standard flow – OK

Test 7: After invoicing, the partner appears under Contacts with the Members filter thanks to waiting being included – OK

When you have a chance, could you please address the following so we can revalidate?
• On refund, restore the prior state (set free_member back to True when applicable) and avoid leaving membership in canceled.
• Consider adding automated tests covering full/partial refunds, multiple obligations, and administrative cancellation.

Thanks again for the effort—happy to retest as soon as updates are pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants