From a8e72ba7fb916f1c3a77c850c88421f2b19b343e Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 15 Jun 2026 13:36:48 +0700 Subject: [PATCH] feat: disable numpad sign change and restrict quantity modifications for Ojol discount lines --- README.md | 2 ++ .../src/app/components/numpad/numpad_patch.js | 18 ++++++++++++ .../order_summary/order_summary_patch.js | 29 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 static/src/app/components/numpad/numpad_patch.js create mode 100644 static/src/app/screens/product_screen/order_summary/order_summary_patch.js diff --git a/README.md b/README.md index 9c9a62e..fc456bb 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ This Odoo 19 module enhances the security and auditability of the Point of Sale - **Incremental Printing on Send**: When additional items are added to an already sent order, the automatic print on "Send" is filtered to print *only the newly added (additional) items*, preventing duplicate printing of already served items. - **Unlock Register PIN/Selection Bypass**: Bypasses the PIN prompt and employee selection when unlocking the register. It unlocks directly with the current/last cashier. Note that opening the register (new session) still requires PIN entry. - **Stay on Current Order on Send**: Retains the POS UI on the current table/order screen after clicking "Send" rather than returning to the Floor Screen (table view). +- **Disable Numpad Sign Change**: Disables the "+/-" button on the POS numpad to prevent manual negative price input or quantity negation. +- **Lock Ojol Discount Quantity**: Blocks quantity changes (via numpad and keyboard) and configuration edits (via long press) on the "Diskon Ojol" product lines on POS orders. ## Dependencies diff --git a/static/src/app/components/numpad/numpad_patch.js b/static/src/app/components/numpad/numpad_patch.js new file mode 100644 index 0000000..9ba0483 --- /dev/null +++ b/static/src/app/components/numpad/numpad_patch.js @@ -0,0 +1,18 @@ +/** @odoo-module */ + +import { Numpad } from "@point_of_sale/app/components/numpad/numpad"; +import { patch } from "@web/core/utils/patch"; +import { localization } from "@web/core/l10n/localization"; + +patch(Numpad.prototype, { + get buttons() { + return super.buttons.map((btn) => { + const btnObj = typeof btn === "object" ? { ...btn } : { value: btn }; + if (btnObj.value === "-" || btnObj.value === "." || btnObj.value === "," || btnObj.value === localization.decimalPoint) { + btnObj.disabled = true; + } + return btnObj; + }); + } +}); + diff --git a/static/src/app/screens/product_screen/order_summary/order_summary_patch.js b/static/src/app/screens/product_screen/order_summary/order_summary_patch.js new file mode 100644 index 0000000..0018559 --- /dev/null +++ b/static/src/app/screens/product_screen/order_summary/order_summary_patch.js @@ -0,0 +1,29 @@ +/** @odoo-module */ + +import { OrderSummary } from "@point_of_sale/app/screens/product_screen/order_summary/order_summary"; +import { patch } from "@web/core/utils/patch"; +import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; +import { _t } from "@web/core/l10n/translation"; + +patch(OrderSummary.prototype, { + async updateSelectedOrderline({ buffer, key }) { + const order = this.pos.getOrder(); + const selectedLine = order ? order.getSelectedOrderline() : null; + if (selectedLine && selectedLine.is_ojol_discount && this.pos.numpadMode === "quantity") { + this.numberBuffer.reset(); + this.dialog.add(AlertDialog, { + title: _t("Cannot change quantity"), + body: _t("The quantity of the Ojol discount line cannot be modified."), + }); + return; + } + return super.updateSelectedOrderline(...arguments); + }, + + async onOrderlineLongPress(ev, orderline) { + if (orderline && orderline.is_ojol_discount) { + return; + } + return super.onOrderlineLongPress(...arguments); + } +});