1.7 KiB
POS Loyalty Safe Coupon Patch
This custom Odoo module resolves critical Point of Sale (POS) Loyalty bugs in Odoo 19 that cause the POS UI to crash or render as a blank screen.
Unsafe Coupon Access Fix
When an order is restored (e.g., during table switching in a restaurant) and references a coupon that is not yet fully loaded in the local client registry, Odoo leaves coupon_id as undefined. Accessing .id on this undefined object crashes the POS UI.
How it works:
- Dynamically patches
PosOrder.getLoyaltyPoints(),OrderPaymentValidation.validateOrder(), andPosStore.postProcessLoyalty(). - Temporarily mocks any missing
coupon_idreferences with{ id: 0 }. - Intercepts
this.data.callduringpostProcessLoyaltyto strip out dummy coupon records with ID0before communicating with the backend.
Invalid/Archived Rewards & program_id Fix
During startup or draft order restoration, if an existing order contains a reward line whose corresponding reward_id or reward_id.program_id is missing or archived (and therefore not loaded in the client registry), Odoo attempts to read program_type from it. This triggers a TypeError: Cannot read properties of undefined (reading 'program_id') or (reading 'program_type') and leaves a blank screen.
How it works:
- Dynamically patches
PosOrder._updateRewardLines()andPosStore.orderUpdateLoyaltyPrograms(). - Automatically filters and deletes reward lines that are missing a valid
reward_idor its associatedprogram_id. - Restores non-corrupted order lines, safely healing the order state and allowing the POS session to load successfully.
This ensures zero side effects, maximum stability, and clean compatibility with standard/custom addons.