feat: disable numpad sign change and restrict quantity modifications for Ojol discount lines

This commit is contained in:
Suherdy Yacob 2026-06-15 13:36:48 +07:00
parent 42d87e2e77
commit a8e72ba7fb
3 changed files with 49 additions and 0 deletions

View File

@ -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

View File

@ -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;
});
}
});

View File

@ -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);
}
});