From 6b591cc5fc02f08a4fd6edd990970aec9048ce50 Mon Sep 17 00:00:00 2001 From: Laetitia Da Costa Date: Thu, 20 Feb 2025 14:43:19 +0100 Subject: [PATCH] [FIX]account_move_protect_deleting:check if account.cash.deposit and account.check.deposit models exists --- account_move_protect_deleting/__manifest__.py | 2 +- .../models/account_move.py | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/account_move_protect_deleting/__manifest__.py b/account_move_protect_deleting/__manifest__.py index 4af31d6..030ac76 100644 --- a/account_move_protect_deleting/__manifest__.py +++ b/account_move_protect_deleting/__manifest__.py @@ -3,7 +3,7 @@ { "name": "account_move_protect_deleting", - "version": "16.0.1.0.1", + "version": "16.0.1.0.2", "author": "Elabore", "website": "https://elabore.coop", "maintainer": "Boris Gallet", diff --git a/account_move_protect_deleting/models/account_move.py b/account_move_protect_deleting/models/account_move.py index 97fdf7a..af3601d 100644 --- a/account_move_protect_deleting/models/account_move.py +++ b/account_move_protect_deleting/models/account_move.py @@ -12,16 +12,22 @@ class AccountMove(models.Model): This work the same with Cash deposit """ for rec in self: - # search in account.cash.deposit if account move is this one - for cash_deposit in rec.env['account.cash.deposit'].search([]): - if cash_deposit.move_id == rec: - print (cash_deposit.move_id, rec) - is_cash_deposit = True - # search in account.check.deposit if account move is this one - for check_deposit in rec.env['account.check.deposit'].search([]): - if check_deposit.move_id == rec: - is_check_deposit = True + is_cash_deposit = False + is_check_deposit = False + + # search in account.cash.deposit if account move is this one + if rec.env.get('account.cash.deposit'): + for cash_deposit in rec.env['account.cash.deposit'].search([]): + if cash_deposit.move_id == rec: + print (cash_deposit.move_id, rec) + is_cash_deposit = True + + # # search in account.check.deposit if account move is this one + if rec.env.get('account.check.deposit'): + for check_deposit in rec.env['account.check.deposit'].search([]): + if check_deposit.move_id == rec: + is_check_deposit = True if ( rec.posted_before and