43 lines
2.7 KiB
ReStructuredText
43 lines
2.7 KiB
ReStructuredText
========================
|
|
POS Lock Sent Products
|
|
========================
|
|
|
|
This module implements a robust security lock in the Odoo 19 Point of Sale system to prevent unauthorized deletion or reduction of order lines that have already been sent to the kitchen (Preparation).
|
|
|
|
Features
|
|
========
|
|
|
|
* **Role-Based Security**: Only users with the "Area Manager" or "Store Manager" (technically "outlet_manager") roles can delete or reduce the quantity of items already sent to the kitchen.
|
|
* **Persistent Locking**: Uses a database-backed field `x_locked_qty` on `pos.order.line` to ensure the lock state persists across browser refreshes, device synchronizations, and session restarts.
|
|
* **Graceful Reduction**: Allows cashiers to freely add and remove "new" quantities on an existing line. For example, if 1 item is sent and 1 is newly added (Total 2), the cashier can safely backspace to reduce the quantity to 1, but cannot drop it below the sent amount.
|
|
* **Backend Checkout Resilience**: Bypasses the default stock validation constraint ("You cannot change a cancelled stock move") during checkout. When a manager deletes or reduces a sent orderline, the picking's corresponding cancelled stock moves are safely ignored during quantity updates, preventing synchronization errors on checkout.
|
|
* **User-Friendly Alerts**: Displays a clear "Action Restricted" popup when an unauthorized deletion attempt is blocked.
|
|
|
|
Technical Details
|
|
=================
|
|
|
|
* **Models Patched**:
|
|
* ``pos.order.line``: Added ``x_locked_qty`` to store the snapshot of the quantity at the moment of kitchen preparation.
|
|
* ``stock.move``: Overrides ``write`` to separate writes on cancelled and active moves, avoiding stock validation exceptions when managers cancel sent quantities.
|
|
* **Javascript Patches**:
|
|
* ``PosStore``: Binds the active ``PosStore`` service globally to `this.models.pos` during server data loading to ensure consistent, reactive cashier role checks across all prototype record layers.
|
|
* ``PosOrderline``: Enforces quantity checks in ``setQuantity`` using both Odoo's native ``mp_qty`` and the custom ``x_locked_qty``.
|
|
* ``PosOrder``: Intercepts ``removeOrderline`` to block full line deletions and captures snapshots during ``updateLastOrderChange``.
|
|
* ``TicketScreen``: Intercepts the UI delete/refund actions using ``getCashier()`` to dynamically enforce supervisor authorization.
|
|
|
|
Dependencies
|
|
============
|
|
|
|
* ``point_of_sale``
|
|
* ``pos_hr``
|
|
* ``pos_employee_role``
|
|
* ``pos_restaurant``
|
|
* ``stock``
|
|
|
|
Installation
|
|
============
|
|
|
|
1. Install the module as usual.
|
|
2. Ensure the "Area Manager" or "Store Manager" roles are configured for supervisors who require bypass authority.
|
|
3. Refresh the POS interface to load the new security logic.
|