[FIX] point_of_sale: prevent closing the same session twice
- Create a POS session - Sell some items - Close the session, go to the closing page - Duplicate the browser tab - Close the session in tab 1 - Close the session in tab 2 The journal entries are created twice. There should be a server check before closing the session. opw-2379278 closes odoo/odoo#61860 X-original-commit: 0ba535c5123fecb410fa7546b5bb39a52884ca40 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -4977,6 +4977,13 @@ msgid ""
|
||||
"customize the reference numbers of your orders."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#: code:addons/point_of_sale/models/pos_session.py:0
|
||||
#: code:addons/point_of_sale/models/pos_session.py:0
|
||||
#, python-format
|
||||
msgid "This session is already closed."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#: model_terms:ir.ui.view,arch_db:point_of_sale.res_config_settings_view_form
|
||||
msgid "This tax is applied to any new product created in the catalog."
|
||||
|
||||
@@ -259,6 +259,8 @@ class PosSession(models.Model):
|
||||
def action_pos_session_closing_control(self):
|
||||
self._check_pos_session_balance()
|
||||
for session in self:
|
||||
if session.state == 'closed':
|
||||
raise UserError(_('This session is already closed.'))
|
||||
session.write({'state': 'closing_control', 'stop_at': fields.Datetime.now()})
|
||||
if not session.config_id.cash_control:
|
||||
session.action_pos_session_close()
|
||||
@@ -297,6 +299,8 @@ class PosSession(models.Model):
|
||||
self.cash_real_transaction = self.cash_register_total_entry_encoding
|
||||
self.cash_real_expected = self.cash_register_balance_end
|
||||
self.cash_real_difference = self.cash_register_difference
|
||||
if self.state == 'closed':
|
||||
raise UserError(_('This session is already closed.'))
|
||||
self._check_if_no_draft_orders()
|
||||
if self.update_stock_at_closing:
|
||||
self._create_picking_at_end_of_session()
|
||||
|
||||
Reference in New Issue
Block a user