[FIX] l10n_pos_cert: Fixed unlink empty cash register
closes odoo/odoo#75825 X-original-commit: 92aec1c9071473f3b9e3254d1b8dc65845c83595 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
committed by
Laurent Smet
parent
8bf547be1d
commit
d33c3d34fa
@@ -10,8 +10,12 @@ class AccountBankStatement(models.Model):
|
||||
|
||||
@api.ondelete(at_uninstall=True)
|
||||
def _unlink_except_created_by_pos(self):
|
||||
for statement in self.filtered(lambda s: s.company_id._is_accounting_unalterable() and s.journal_id.pos_payment_method_ids):
|
||||
raise UserError(_('You cannot modify anything on a bank statement (name: %s) that was created by point of sale operations.') % (statement.name,))
|
||||
for statement in self:
|
||||
if not statement.company_id._is_accounting_unalterable() or not statement.s.journal_id.pos_payment_method_ids:
|
||||
continue
|
||||
if statement.state != 'open':
|
||||
raise UserError(_('You cannot modify anything on a bank statement (name: %s) that was created by point of sale operations.') % statement.name)
|
||||
return super().unlink()
|
||||
|
||||
|
||||
class AccountBankStatementLine(models.Model):
|
||||
@@ -19,5 +23,10 @@ class AccountBankStatementLine(models.Model):
|
||||
|
||||
@api.ondelete(at_uninstall=True)
|
||||
def _unlink_except_created_by_pos(self):
|
||||
for line in self.filtered(lambda s: s.company_id._is_accounting_unalterable() and s.journal_id.pos_payment_method_ids):
|
||||
raise UserError(_('You cannot modify anything on a bank statement line (name: %s) that was created by point of sale operations.') % (line.name,))
|
||||
for st_line in self:
|
||||
statement = st_line.statement_id
|
||||
if not statement.company_id._is_accounting_unalterable() or not statement.s.journal_id.pos_payment_method_ids:
|
||||
continue
|
||||
if statement.state != 'open':
|
||||
raise UserError(_('You cannot modify anything on a bank statement (name: %s) that was created by point of sale operations.') % statement.name)
|
||||
return super().unlink()
|
||||
|
||||
Reference in New Issue
Block a user