diff --git a/addons/account/account.py b/addons/account/account.py index ebc5aa8af93..33150274bdf 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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