diff --git a/addons/laundry_management/static/src/js/control_buttons_patch.js b/addons/laundry_management/static/src/js/control_buttons_patch.js new file mode 100644 index 0000000..1c44e29 --- /dev/null +++ b/addons/laundry_management/static/src/js/control_buttons_patch.js @@ -0,0 +1,35 @@ +/** @odoo-module + * + * ControlButtons patch — wires the two custom POS quick-action buttons + * declared in static/src/xml/control_buttons.xml to the PosStore methods + * that already exist in pos_store_patch.js: + * + * onClickSettleDues → pos.settleLaundryDues() + * onClickViewLaundryOrders → pos.viewLaundryOrders() + * + * Without this bridge, OWL throws + * "Invalid handler (expected a function, received: 'undefined')" + * at click time because the template references methods on the + * ControlButtons component that don't otherwise exist. + * + * Each handler closes the parent ControlButtons modal (props.close) + * after dispatching, mirroring core's behavior for its own buttons. + */ +import { patch } from "@web/core/utils/patch"; +import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons"; + +patch(ControlButtons.prototype, { + onClickSettleDues() { + this.pos.settleLaundryDues(); + if (this.props.close) { + this.props.close(); + } + }, + + onClickViewLaundryOrders() { + this.pos.viewLaundryOrders(); + if (this.props.close) { + this.props.close(); + } + }, +});