Skip to main content
The discount system supports item-level and check-level discounts with configurable presets, manual entry, comps (100% discount), role-based access control, and manager override for restricted users.

Discount types

Presets are configured in the Odoo backend (nu.pos.discount.preset): Each preset has an applies_to field: item, check, or both.

Comp

A comp is a 100% discount applied directly (no modal). Triggered from the “Comp Item” tile in the item detail panel. If the user’s max_discount is below 100, a manager override is required.

Access control

1

Permission check

User clicks discount/comp. System checks canPerformAction(role, "discount", permissions).
2

Allowed

Proceed to DiscountModal (or apply comp directly for 100% discount).
3

Denied

Open ManagerOverrideModal for PIN approval by an authorized manager.

Max discount enforcement

Each user has a max_discount value from their PosUser record:
  • 0 = unlimited (no cap)
  • > 0 = maximum percentage this user can apply
The DiscountModal clamps input to maxDiscount. When a manager approves via override, their own max_discount is used. In the override modal, managers with insufficient max_discount are shown grayed out.

Data flow

Item discount

Check discount

Stacking

Item and check discounts compose multiplicatively: 10% item + 20% check = 28% total, not 30%.

Reducer actions

Audit trail

Both ItemDiscountState and CheckDiscountState store:
  • appliedByUserId / appliedByName — who applied the discount
  • approvedByUserId / approvedByName — manager who approved (if override was needed)
  • presetId / presetName — which preset was used (if any)

Hub sync

discountState and checkDiscount flow through the snapshot pipeline:
  • buildSnapshot() includes them on items and orders
  • rebuildOrderFromSnapshot() restores them

Backend addon

nu_pos_discounts/ — Odoo 12 addon. Extends _get_bootstrap_extra() to include discount_presets array:

i18n

Translations in the discounts namespace (src/i18n/locales/{en,es}.json).

Testing

  • models.test.ts — Parsing, preset filtering
  • services.test.tscomputeDiscountPct, distributeCheckDiscount, composeDiscountPct