feat: add dependency on pos_loyalty_multi_level and skip auto-leveling for manual memberships
This commit is contained in:
parent
e286b6c6e6
commit
7631a3e93e
@ -17,7 +17,7 @@ Key Features:
|
||||
4. **Intelligent Point Consolidation**: If a customer changes tiers, the module seamlessly sweeps loyalty points from any of their older tier cards and consolidates them into the new membership card. This happens synchronously to ensure all points are perfectly transferred without race conditions.
|
||||
5. **High Performance**: Evaluates membership instantly without recalculating the entire transaction history by leveraging the `total_spend` field.
|
||||
""",
|
||||
'depends': ['point_of_sale', 'pos_loyalty'],
|
||||
'depends': ['point_of_sale', 'pos_loyalty', 'pos_loyalty_multi_level'],
|
||||
'data': [
|
||||
'views/res_partner_views.xml',
|
||||
],
|
||||
|
||||
@ -30,13 +30,16 @@ class PosOrder(models.Model):
|
||||
"""Internal logic for membership determination, called by background worker."""
|
||||
self.ensure_one()
|
||||
partner = self.partner_id
|
||||
# If the customer has a manual membership level assigned, do not auto-change it.
|
||||
if partner.membership_level_id and partner.membership_level_id.manual_membership:
|
||||
return
|
||||
|
||||
# 1. Get total purchases from the new total_spend field
|
||||
total_purchases = partner.total_spend
|
||||
|
||||
# 2. Get multi-level programs
|
||||
# 2. Get multi-level programs that are not manual-only
|
||||
loyalty_programs = self.env['loyalty.program'].sudo().search(
|
||||
[('multi_level_membership', '=', True)],
|
||||
[('multi_level_membership', '=', True), ('manual_membership', '=', False)],
|
||||
order='minimum_spend asc',
|
||||
)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user