3.1 KiB
3.1 KiB
POS Loyalty Tax Mode
Custom module for Odoo 19 that adds a Before Tax / After Tax option to the loyalty rule's "per money spent" reward point mode.
Overview
By default, Odoo calculates loyalty reward points based on the total price including tax when the rule is set to "per money spent". This module introduces a configurable dropdown that lets you choose whether points should be calculated on the price before tax or after tax.
Features
- Adds a Tax Option dropdown field on the
loyalty.rulemodel - The dropdown only appears when the reward point mode is set to "per money spent"
- Two options available:
- Before Tax — points are calculated based on the subtotal (tax excluded)
- After Tax — points are calculated based on the total (tax included, default behavior)
- Fully integrated with the POS frontend — the setting syncs to the Point of Sale session automatically
Dependencies
| Module | Technical Name |
|---|---|
| POS Loyalty | pos_loyalty |
| Loyalty | loyalty |
Installation
- Place the
pos_loyalty_tax_modefolder into yourcustomaddons directory - Restart the Odoo server
- Go to Apps → Update Apps List
- Search for "POS Loyalty Tax Mode" and click Install
Configuration
- Navigate to Point of Sale → Configuration → Discount & Loyalty
- Open or create a loyalty program
- In the Rules section, set the grant mode to "per [currency] spent"
- A new Tax Option dropdown will appear — select either Before Tax or After Tax
- Save and close/reopen your POS session to apply the changes
Module Structure
pos_loyalty_tax_mode/
├── __init__.py
├── __manifest__.py
├── readme.md
├── models/
│ ├── __init__.py
│ └── loyalty_rule.py # Extends loyalty.rule with money_reward_point_mode field
├── views/
│ └── loyalty_rule_views.xml # Inherits form & kanban views to show the new field
└── static/
└── src/
└── app/
└── pos_order_patch.js # Patches POS point calculation logic
Technical Details
Backend (models/loyalty_rule.py)
Adds a money_reward_point_mode selection field to loyalty.rule:
| Value | Label | Description |
|---|---|---|
before_tax |
Before Tax | Points based on price excluding tax |
after_tax |
After Tax | Points based on price including tax (default) |
The field is also registered in _load_pos_data_fields so it is available in the POS frontend.
Frontend (static/src/app/pos_order_patch.js)
Patches two methods on PosOrder.prototype:
pointsForPrograms(programs)— Modified to usetotal_excludedortotal_includedbased on the rule'smoney_reward_point_modewhen calculatingorderedProductPaidandpointsPerUnit_getPointsCorrection(program)— Modified to use the correct price (before/after tax) when computing point corrections for free-product rewards
License
LGPL-3