From 817ff2d71808c3d8c4f89ad2b5b6eacebf567d48 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 2 Jun 2020 11:08:49 +0000 Subject: [PATCH] [FIX] point_of_sale: unable to close on cash control Validating the cash register is not needed at this point because it is already validated in _reconcile_account_move_lines. --- addons/point_of_sale/models/pos_session.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 8e058ec8712..f1fb4d0bdc7 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -311,10 +311,6 @@ class PosSession(models.Model): # Set the uninvoiced orders' state to 'done' self.env['pos.order'].search([('session_id', '=', self.id), ('state', '=', 'paid')]).write({'state': 'done'}) else: - # The cash register needs to be confirmed for cash diffs - # made thru cash in/out when sesion is in cash_control. - if self.config_id.cash_control: - self.cash_register_id.button_validate() self.move_id.unlink() self.write({'state': 'closed'}) return { @@ -644,7 +640,6 @@ class PosSession(models.Model): if not self.config_id.cash_control: statement.write({'balance_end_real': statement.balance_end}) statement.button_post() - statement.button_validate() all_lines = ( split_cash_statement_lines[statement].mapped('move_id.line_ids').filtered(lambda aml: aml.account_id.internal_type == 'receivable') | combine_cash_statement_lines[statement].mapped('move_id.line_ids').filtered(lambda aml: aml.account_id.internal_type == 'receivable') @@ -655,6 +650,17 @@ class PosSession(models.Model): lines_by_account = [all_lines.filtered(lambda l: l.account_id == account) for account in accounts] for lines in lines_by_account: lines.reconcile() + # We try to validate the statement after the reconciliation is done + # because validating the statement requires each statement line to be + # reconciled. + # Furthermore, if the validation failed, which is caused by unreconciled + # cash difference statement line, we just ignore that. Leaving the statement + # not yet validated. Manual reconciliation and validation should be made + # by the user in the accounting app. + try: + statement.button_validate() + except UserError: + pass # reconcile invoice receivable lines for account_id in order_account_move_receivable_lines: