[FIX]account_move_protect_deleting:manage recordset

This commit is contained in:
2024-12-03 15:04:25 +01:00
parent d5e0136161
commit d6d39d536d
2 changed files with 20 additions and 20 deletions

View File

@@ -3,7 +3,7 @@
{ {
"name": "account_move_protect_deleting", "name": "account_move_protect_deleting",
"version": "16.0.1.0.0", "version": "16.0.1.0.1",
"author": "Elabore", "author": "Elabore",
"website": "https://elabore.coop", "website": "https://elabore.coop",
"maintainer": "Boris Gallet", "maintainer": "Boris Gallet",

View File

@@ -11,25 +11,25 @@ class AccountMove(models.Model):
when the check deposit is reset to draft. when the check deposit is reset to draft.
This work the same with Cash deposit This work the same with Cash deposit
""" """
for rec in self:
# search in account.cash.deposit if account move is this one # search in account.cash.deposit if account move is this one
for cash_deposit in self.env['account.cash.deposit'].search([]): for cash_deposit in rec.env['account.cash.deposit'].search([]):
if cash_deposit.move_id == self: if cash_deposit.move_id == rec:
print (cash_deposit.move_id, self) print (cash_deposit.move_id, rec)
is_cash_deposit = True is_cash_deposit = True
# search in account.check.deposit if account move is this one # search in account.check.deposit if account move is this one
for check_deposit in self.env['account.check.deposit'].search([]): for check_deposit in rec.env['account.check.deposit'].search([]):
if check_deposit.move_id == self: if check_deposit.move_id == rec:
is_check_deposit = True is_check_deposit = True
if ( if (
self.posted_before and rec.posted_before and
( (
not is_cash_deposit not is_cash_deposit
and not is_check_deposit and not is_check_deposit
) )
): ):
raise UserError(_("" raise UserError(_(""
"You cannot delete this account move because it has been posted." "You cannot delete this account move because it has been posted."
)) ))