From 162eb35de8e3d16ddaafba43fdbdca4c8d36629b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vanhaudenard?= Date: Thu, 24 Jun 2021 11:13:40 +0000 Subject: [PATCH] [FIX] point_of_sale: Warning on posted cash register To reproduce the problem : 1. Install POS and accounting 2. Open a POS session and make a cash payment 3. Go on accounting -> statement of CASH -> click on the POS statement 4. Try to post the statement -> It works 5. Try to close the session -> Only new statements can be posted. Now, a check is performed at the beginning of the closing process and display a useful message to the user if a statement is already posted. OPW-2494806 OPW-2377190 OPW-2448362 OPW-2485830 OPW-2487628 closes odoo/odoo#72806 X-original-commit: 6c0646aa48900933474ee237ab143967e15f4086 Signed-off-by: pimodoo --- addons/point_of_sale/i18n/point_of_sale.pot | 14 ++++++++++++++ addons/point_of_sale/models/pos_session.py | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index 14f672223cf..68059381036 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -4387,6 +4387,20 @@ msgstr "" msgid "Slash" msgstr "" +#. module: point_of_sale +#: model:product.product,name:point_of_sale.small_shelf +#: model:product.template,name:point_of_sale.small_shelf_product_template +msgid "Small Shelf" +msgstr "" + +#. module: point_of_sale +#: code:addons/point_of_sale/models/pos_session.py:0 +#, python-format +msgid "" +"Some Cash Registers are already posted. Please reset them to new in order to close the session.\n" +"Cash Registers: %r" +msgstr "" + #. module: point_of_sale #. openerp-web #: code:addons/point_of_sale/static/src/js/Chrome.js:0 diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 9c57550480f..af1b7ba1fa8 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -177,6 +177,13 @@ class PosSession(models.Model): if (company.period_lock_date and start_date <= company.period_lock_date) or (company.fiscalyear_lock_date and start_date <= company.fiscalyear_lock_date): raise ValidationError(_("You cannot create a session before the accounting lock date.")) + def _check_bank_statement_state(self): + for session in self: + closed_statement_ids = session.statement_ids.filtered(lambda x: x.state != "open") + if closed_statement_ids: + raise UserError(_("Some Cash Registers are already posted. Please reset them to new in order to close the session.\n" + "Cash Registers: %r", list(statement.name for statement in closed_statement_ids))) + @api.model def create(self, values): config_id = values.get('config_id') or self.env.context.get('default_config_id') @@ -277,6 +284,7 @@ class PosSession(models.Model): # Session without cash payment method will not have a cash register. # However, there could be other payment methods, thus, session still # needs to be validated. + self._check_bank_statement_state() if not self.cash_register_id: return self._validate_session(balancing_account, amount_to_balance)