feat: Add pos_shift_close module to manage multi-shift POS sessions by bypassing draft order checks and transferring orders.

This commit is contained in:
Suherdy Yacob 2026-03-20 15:21:15 +07:00
parent f659ed99ad
commit d60b04c690
3 changed files with 38 additions and 0 deletions

14
.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# IDE / Editor configuration
.vscode/
.idea/
*.swp
*~
# Odoo specific
*.pot
*.log

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# POS Shift Close
## Overview
The `pos_shift_close` module customizes the Point of Sale session closing behavior in Odoo 19 to accommodate businesses with multiple shifts (e.g., Morning and Afternoon/Night shifts).
By default, Odoo prevents a POS session from closing if there are still unpaid or draft orders. This module introduces a time-based configuration to bypass this restriction for the Morning shift. When the Afternoon shift opens a new session, all draft orders from the Morning shift are automatically transferred over so they can be processed seamlessly.
## Key Features
1. **Configurable Shift Cutoff Time**: You can set a "Morning Shift End Time" (in float hours, e.g., `15.0` for `3:00 PM`) via the POS Configuration menu.
2. **Morning Shift Validation Bypass**: If a cashier attempts to close a session *before* the configured cutoff time, the standard Odoo check for draft orders is bypassed.
3. **Automatic Order Transfer**: When the next session (Afternoon shift) is opened for the same POS, the module automatically scans previously closed sessions and moves any remaining draft orders to the newly opened session.
4. **Standard Night Flow Restriction**: If a session is closed *after* the cutoff time (i.e., at the end of the day), the standard Odoo behavior applies, and the session cannot be closed until all pending orders are either paid or cancelled.
## Setup & Configuration
1. Install the module `pos_shift_close` on your Odoo 19 instance.
2. Go to **Point of Sale > Configuration > Settings**.
3. Under the **Accounting** section, locate the new **Morning Shift End Time** field.
4. Enter your cutoff time (e.g., `15:00` for 3 PM) and save.
## Technical Details
- **Dependency**: Requires `point_of_sale`.
- **Overrides**: Implements specific overrides in `_check_if_no_draft_orders` and `_set_opening_control_data` inside `pos.session` model.
- Time conversions correctly compare against the user's localized timezone (`self.env.user.tz`).

View File

@ -8,6 +8,7 @@ This module allows cashiers on the morning shift to close the POS session even i
Those pending orders will automatically be moved to the next session when it is opened. Those pending orders will automatically be moved to the next session when it is opened.
The afternoon/evening shift will maintain the standard Odoo behavior (blocking closure if pending orders exist). The afternoon/evening shift will maintain the standard Odoo behavior (blocking closure if pending orders exist).
""", """,
'author': "Suherdy Yacob",
'depends': ['point_of_sale'], 'depends': ['point_of_sale'],
'data': [ 'data': [
'views/res_config_settings_views.xml', 'views/res_config_settings_views.xml',