# POS Loyalty Safe Coupon Patch This custom Odoo module resolves a core Odoo 19 bug in the POS Loyalty module where standard Odoo code makes unsafe direct reads on `coupon_id.id` of reward lines. 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 Without modifying any core Odoo code, this module dynamically patches: 1. `PosOrder.getLoyaltyPoints()` 2. `OrderPaymentValidation.validateOrder()` 3. `PosStore.postProcessLoyalty()` During their respective execution, it temporarily mocks any missing `coupon_id` references with `{ id: 0 }`. It also wraps `this.data.call` during `postProcessLoyalty` to ensure dummy coupon records with ID `0` are filtered out before being communicated back to the Odoo backend server. After execution, the original `undefined` state of the coupon is safely restored. This ensures zero side effects, maximum stability, and clean compatibility with standard/custom addons.