From 57d761fc650c8dc624c57913befbb530c4c6e848 Mon Sep 17 00:00:00 2001 From: "JMA (OpenERP)" Date: Tue, 11 May 2010 12:56:42 +0530 Subject: [PATCH] [FIX] Account : Account should not be removed/deactivated if it is linked to any property/partner bzr revid: jma@tinyerp.com-20100511072642-lbai9yw8tnn1kg6z --- addons/account/account.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/account.py b/addons/account/account.py index 17e753b4352..2c29d202b3a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -432,11 +432,17 @@ class account_account(osv.osv): def _check_moves(self, cr, uid, ids, method, context): line_obj = self.pool.get('account.move.line') account_ids = self.search(cr, uid, [('id', 'child_of', ids)]) + if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): if method == 'write': raise osv.except_osv(_('Error !'), _('You cannot deactivate an account that contains account moves.')) elif method == 'unlink': raise osv.except_osv(_('Error !'), _('You cannot remove an account which has account entries!. ')) + #Checking whether the account is set as a property to any Partner or not + value = 'account.account,' + str(ids[0]) + partner_prop_acc = self.pool.get('ir.property').search(cr, uid, [('value_reference','=',value)], context=context) + if partner_prop_acc: + raise osv.except_osv(_('Warning !'), _('You cannot remove/deactivate an account which is set as a property to any Partner.')) return True def _check_allow_type_change(self, cr, uid, ids, new_type, context):