2.0 KiB
2.0 KiB
POS Loyalty Usage Limit
Overview
This custom Odoo 19 module enhances the Point of Sale (POS) Loyalty and Promotions system by introducing redemption usage limits on individual loyalty cards. It allows administrators to restrict how many times a customer can use their loyalty card to redeem rewards within a specific time period (per day, per month, or per year).
Features
- Flexible Limits: Set usage limits to be enforced per day, per month, or per year.
- Card-Level Configuration: The limit configuration is set individually on each
loyalty.card, allowing some VIP cards to be unlimited while standard cards are restricted. - Smart POS UI Filtering: In the POS interface, if a card has reached its limit, the "Reward" button is automatically hidden, preventing cashiers from attempting invalid redemptions.
- Offline/Online Synchronization: The frontend logic seamlessly blends backend historical usage data with current un-synced POS session data to calculate real-time usage.
- Strict Backend Validation: A secure RPC validation check runs at checkout, preventing users from bypassing the limits by using the same card concurrently across multiple active POS sessions.
Configuration
- Navigate to Sales > Products > Discount & Loyalty and open a loyalty program.
- Click on the Cards smart button or directly navigate to a specific Loyalty Card.
- Check the Limit boolean checkbox to enable the restriction.
- Specify the Limit Count (e.g.,
1). - Choose the Limit Period (
Per Day,Per Month, orPer Year). - If the Limit checkbox is left unchecked, the loyalty card can be used indefinitely.
Technical Details
- Backend Validation: Overrides
validate_coupon_programsinpos.orderto ensure real-time limit adherence when processing payments. - Frontend Filtering: Patches
getClaimableRewardsinPosOrder.prototypeto hide unavailable rewards proactively. - Usage Tracking: Computes period usage counts by scanning the
loyalty.historyrecords dynamically.