46 lines
3.5 KiB
ReStructuredText
46 lines
3.5 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.
|
|
* **Chatter Cancellation Logs**: Structurally logs all supervisor-approved sent product deletions, quantity reductions, and entire order cancellations directly to the backend order's chatter thread.
|
|
* **Role-Aware Logging**: Overrides Odoo's native hardcoded "Cashier [Name]" log format to dynamically resolve and print the employee's actual POS Role (e.g. `Outlet Manager Suherdy Yacob` or `Area Manager Suherdy Yacob`), keeping tracking records fully accurate.
|
|
|
|
Technical Details
|
|
=================
|
|
|
|
* **Models Patched**:
|
|
* ``pos.order``: Added ``x_logged_cancellations`` text field for offline-resilient, deduplicated chatter logging. Intercepts incoming order syncing via ``_process_order`` to write structured HTML cancellation logs to chatter. Overrides Odoo's native ``_prepare_pos_log`` to display dynamic POS roles in place of hardcoded "Cashier" strings.
|
|
* ``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, enforces cashier role bypass checks, and patches ``deleteOrders`` to inject the cashier's employee ID into the context of backend order cancellation RPC calls.
|
|
* ``PosOrderline``: Enforces quantity checks, and logs supervisor-approved quantity reductions under ``x_cancelled_lines``.
|
|
* ``PosOrder``: Tracks supervisor-approved full kitchen item deletions under ``x_cancelled_lines``, and serializes this logging queue to the backend.
|
|
* ``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.
|