Skip to content
Snippets Groups Projects
Commit 7416340e authored by alt-odoo's avatar alt-odoo
Browse files

[FIX] point_of_sale: prevent deletion of POS bank statement


Nothing prevents to delete a bank statement linked to an open pos session,
which leads to a KeyError when validating and posting entries at closure.

closes odoo/odoo#44229

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 31890c4e
Branches
Tags
No related merge requests found
......@@ -5044,6 +5044,12 @@ msgstr ""
msgid "You cannot create a session before the accounting lock date."
msgstr ""
#. module: point_of_sale
#: code:addons/point_of_sale/models/account_bank_statement.py:0
#, python-format
msgid "You cannot delete a bank statement used in an open Point of Sale session."
msgstr ""
#. module: point_of_sale
#: code:addons/point_of_sale/models/product.py:0
#: code:addons/point_of_sale/models/product.py:0
......
......@@ -17,6 +17,11 @@ class AccountBankStatement(models.Model):
raise UserError(_("You can't validate a bank statement that is used in an opened Session of a Point of Sale."))
return super( AccountBankStatement, self).check_confirm_bank()
def unlink(self):
for bs in self:
if bs.pos_session_id:
raise UserError(_("You cannot delete a bank statement used in an open Point of Sale session."))
return super( AccountBankStatement, self).unlink()
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment