3.1 KiB
3.1 KiB
POS Loyalty Multi-Level
Overview
This custom Odoo 19 module extends the functionalities of the Point of Sale (POS) loyalty module (pos_loyalty). By default, Odoo activates all applicable loyalty programs that meet the criteria when a customer is selected. This module modifies that behavior to support tiered/multi-level membership programs defined via custom fields.
Features
When evaluating loyalty programs for a transaction, this module checks the multi_level_membership flag on running loyalty programs:
- Non-Multi-Level Programs: Any loyalty programs with
multi_level_membershipset toFalse(or undefined) will behave normally. All applicable programs will be activated simultaneously. - Multi-Level Programs: If there are several loyalty programs with
multi_level_membershipset toTrue, the module will restrict activation to only 1 of those programs:- It will first attempt to match the program defined in the customer's
membership_level_idfield. - If the customer does not have a membership level defined, or if the specified membership program criteria is not met, the module falls back to activating the multi-level program with the smallest
minimum_spendvalue.
- It will first attempt to match the program defined in the customer's
- Real-time Membership Updates: Whenever a customer is selected from the POS Partner List, their latest details (specifically their membership level) are fetched instantly from the server. This prevents utilizing an outdated membership tier if changes were made in the backend during an active POS session.
- On-Demand Customer Sync: Provides an "Update Data" button globally accessible in the POS Customer List. Pressing it dynamically fetches any newly registered accounts created during the active POS session straight into the local offline cache without needing to reload or close the POS.
Included Fields
This module installs the following native fields:
loyalty.programModel:multi_level_membership: Booleanminimum_spend: Float
res.partnerModel:membership_level_id: Many2one (Relational reference toloyalty.program)
Technical Details
This module modifies the loading process of the POS session by injecting the new custom fields into the Point of Sale frontend environment directly from the models:
- Extends
_load_pos_data_fieldsinmodels/loyalty_program.pyandmodels/res_partner.py. - Patches
PartnerList.prototype.clickPartnerinstatic/src/app/screens/partner_list_patch.jsto trigger a backenddata.readlookup over the network to instantly refresh the local reactive partner state when selected. - Extends the
point_of_sale.PartnerListXML template instatic/src/app/screens/partner_list_patch.xmlto inject the synchronization button. - Handles the bulk sync in Javascript via
updateCustomerData()utilizing Odoo nativesearchReadto load missing active models locally. - Patches
PosOrder.prototype._programIsApplicableinstatic/src/app/models/pos_order.jsto augment the frontend eligibility checks cleanly and safely using Owlpatch.
License
See the __manifest__.py file for license details.