[16.0][IMP] membership_extension: remove Member Free membership when Invoice is created#209
[16.0][IMP] membership_extension: remove Member Free membership when Invoice is created#209clebersantz wants to merge 8 commits intoOCA:16.0from
Conversation
|
Hello! Please @BhaveshHeliconia could you kindly review this improvement? 🙏🏼 😄 |
| for partner in line.membership_lines.mapped("partner"): | ||
| partner.write({"free_member": False}) |
There was a problem hiding this comment.
suggestion: Same but simpler and faster:
| for partner in line.membership_lines.mapped("partner"): | |
| partner.write({"free_member": False}) | |
| line.membership_lines.partner.free_member = False |
|
This PR has the |
There was a problem hiding this comment.
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

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

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

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


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




- 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
- Mark partner as free: open the partner and set Free Member = True.
- Create and post an invoice with a membership product for that partner.
- 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.
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.