From e27a3b185e449139660f43fea34de9a79dc66f2c Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 6 Jun 2017 14:41:58 +0200 Subject: [PATCH] [FIX] point_of_sale: recompute bank statement balance before validating session Before this commit, the return flow in the pos would not work if closing the pos session intervened before the return payment registration. The balance of the the statements was not updated before going to the validate step. After this commit, we force the recomputing of the relevant fields (i.e. balance_end_real), to reflect reality and permitting validatioon afterwards OPW 743763 Closes #17438 --- addons/point_of_sale/models/pos_session.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index c59da953235..1efa9c90c79 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -239,16 +239,22 @@ class PosSession(models.Model): @api.multi def action_pos_session_closing_control(self): + self._check_pos_session_balance() for session in self: - for statement in session.statement_ids: - if (statement != session.cash_register_id) and (statement.balance_end != statement.balance_end_real): - statement.write({'balance_end_real': statement.balance_end}) session.write({'state': 'closing_control', 'stop_at': fields.Datetime.now()}) if not session.config_id.cash_control: session.action_pos_session_close() + @api.multi + def _check_pos_session_balance(self): + for session in self: + for statement in session.statement_ids: + if (statement != session.cash_register_id) and (statement.balance_end != statement.balance_end_real): + statement.write({'balance_end_real': statement.balance_end}) + @api.multi def action_pos_session_validate(self): + self._check_pos_session_balance() self.action_pos_session_close() @api.multi