[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
This commit is contained in:
Lucas Perais (lpe)
2017-06-14 16:12:03 +02:00
parent 62fec71568
commit e27a3b185e
+9 -3
View File
@@ -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