[MERGE] Account: Add constraint on account.account and account.account.template for type=view
bzr revid: mra@mra-laptop-20110111095527-ea7ifuxep1xuk26c
This commit is contained in:
@@ -418,9 +418,19 @@ class account_account(osv.osv):
|
||||
c_ids = s_ids
|
||||
ids = child_ids
|
||||
return True
|
||||
|
||||
def _check_type(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
accounts = self.browse(cr, uid, ids, context=context)
|
||||
for account in accounts:
|
||||
if account.child_id and account.type != 'view':
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id'])
|
||||
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']),
|
||||
(_check_type, 'You cannot create a account! \nMake sure if the account has children then it should be type "View"! ', ['type']),
|
||||
]
|
||||
_sql_constraints = [
|
||||
('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')
|
||||
@@ -2295,9 +2305,20 @@ class account_account_template(osv.osv):
|
||||
'nocreate': False,
|
||||
}
|
||||
|
||||
def _check_type(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
accounts = self.browse(cr, uid, ids, context=context)
|
||||
for account in accounts:
|
||||
if account.parent_id and account.parent_id.type != 'view':
|
||||
return False
|
||||
return True
|
||||
|
||||
_check_recursion = check_cycle
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id'])
|
||||
(_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id']),
|
||||
(_check_type, 'You cannot create a account template! \nMake sure if the account template has parent then it should be type "View"! ', ['type']),
|
||||
|
||||
]
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
|
||||
Reference in New Issue
Block a user