[IMP] Forbid to change type of account for 'consolidation' and 'view' if there is entries on it or his children.

bzr revid: joel.grandguillaume@camptocamp.com-20121025134702-7px784iu3226qc0l
This commit is contained in:
Joël Grand-Guillaume 2012-10-25 15:47:02 +02:00
parent e242773cac
commit aef8541bc8
1 changed files with 6 additions and 7 deletions

View File

@ -633,8 +633,7 @@ class account_account(osv.osv):
return True
def _check_allow_type_change(self, cr, uid, ids, new_type, context=None):
group1 = ['payable', 'receivable', 'other']
group2 = ['consolidation','view']
group_dest = ['consolidation','view']
line_obj = self.pool.get('account.move.line')
for account in self.browse(cr, uid, ids, context=context):
old_type = account.type
@ -642,12 +641,12 @@ class account_account(osv.osv):
if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]):
#Check for 'Closed' type
if old_type == 'closed' and new_type !='closed':
raise osv.except_osv(_('Warning!'), _("You cannot change the type of account from 'Closed' to any other type which contains journal items!"))
#Check for change From group1 to group2 and vice versa
if (old_type in group1 and new_type in group2) or (old_type in group2 and new_type in group1):
raise osv.except_osv(_('Warning!'), _("You cannot change the type of account from '%s' to '%s' type as it contains journal items!") % (old_type,new_type,))
return True
raise osv.except_osv(_('Warning !'), _("You cannot change the type of account from 'Closed' to any other type which contains journal items!"))
# Forbid to change an account type for group_dest if move are on it (or his children)
if (new_type in group_dest):
raise osv.except_osv(_('Warning !'), _("You cannot change the type of account for '%s' type as it contains journal items!") % (new_type,))
return True
# For legal reason (forbiden to modify journal entries which belongs to a closed fy or period), Forbid to modify
# the code of an account if journal entries have been already posted on this account. This cannot be simply