diff --git a/README.md b/README.md index 87341f4..25f94f0 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ By default, Odoo prevents a POS session from closing if there are still unpaid o 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. +5. **Session Closure Redirection Fix**: Prevents Odoo from automatically creating and opening a new session immediately after a successful closure by cleanly redirecting the browser back to the backend POS dashboard. ## Setup & Configuration 1. Install the module `pos_shift_close` on your Odoo 19 instance. @@ -19,5 +20,6 @@ By default, Odoo prevents a POS session from closing if there are still unpaid o ## 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. +- **Overrides (Python Models)**: Implements specific overrides in `_check_if_no_draft_orders` and `_set_opening_control_data` inside the `pos.session` model. +- **Overrides (Controllers)**: Inherits standard Odoo's `PosController` and overrides the `pos_web` method/route to intercept direct `/pos/ui/` loads. If there is no active session (`has_active_session` is `False`) and the request is not from backend dashboard (`from_backend` is `False`), the user is redirected back to the backend. - Time conversions correctly compare against the user's localized timezone (`self.env.user.tz`). diff --git a/__init__.py b/__init__.py index 0650744..f7209b1 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +1,2 @@ from . import models +from . import controllers diff --git a/controllers/__init__.py b/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/controllers/main.py b/controllers/main.py new file mode 100644 index 0000000..73e426f --- /dev/null +++ b/controllers/main.py @@ -0,0 +1,13 @@ +from odoo import http +from odoo.http import request +from odoo.addons.point_of_sale.controllers.main import PosController + +class PosControllerInherit(PosController): + + @http.route(["/pos/ui/", "/pos/ui//"], auth="user", type='http') + def pos_web(self, config_id=False, from_backend=False, subpath=None, **k): + if config_id: + pos_config = request.env['pos.config'].sudo().browse(int(config_id)) + if pos_config.exists() and not pos_config.has_active_session and not from_backend: + return request.redirect('/odoo/action-point_of_sale.action_client_pos_menu') + return super().pos_web(config_id=config_id, from_backend=from_backend, subpath=subpath, **k)