From c8ff9d7c46d63b64b8dadda7d23e81c9a8a1d824 Mon Sep 17 00:00:00 2001 From: Robin Heinz Date: Thu, 12 Nov 2020 10:23:02 +0000 Subject: [PATCH] [FIX] point_of_sale: Disallow to close set closing control when orders in draft Before, we ended stuck while using cash control and had order in draft. While in the closing control state, we could go back to the pos to end the order but it was needed to close the session. Now we force all the orders to be done before changing the state of the session. X-original-commit: 55bd39a9854ed446d45033a3992aab0938d27a86 --- addons/point_of_sale/models/pos_session.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 12c25c1da79..7098f11bc2d 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -269,6 +269,8 @@ class PosSession(models.Model): def action_pos_session_closing_control(self, balancing_account=False, amount_to_balance=0): self._check_pos_session_balance() for session in self: + if any(order.state == 'draft' for order in session.order_ids): + raise UserError(_("You cannot close the POS when orders are still in draft")) if session.state == 'closed': raise UserError(_('This session is already closed.')) session.write({'state': 'closing_control', 'stop_at': fields.Datetime.now()})