[IMP] account: added new constraint on account object which will check when the internal type is payable/receiable then the deferral method on account type can be set to unreconciled only

bzr revid: psi@tinyerp.co.in-20110701133420-2pho2e8himf6sz0q
This commit is contained in:
psi (Open ERP) 2011-07-01 19:04:20 +05:30
parent 19c88c744b
commit 630dc1e56d
1 changed files with 7 additions and 0 deletions

View File

@ -431,9 +431,16 @@ class account_account(osv.osv):
return False
return True
def _check_account_type(self, cr, uid, ids, context=None):
for account in self.browse(cr, uid, ids, context=context):
if account.type in ('receivable', 'payable') and account.user_type.close_method != 'unreconciled':
return False
return True
_constraints = [
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']),
(_check_type, 'Configuration Error! \nYou cannot define children to an account with internal type different of "View"! ', ['type']),
(_check_account_type, 'Configuration Error! \nYou cannot define deferral method different of "Unreconciled" on account type to an account with internal type of "Payable/Receivable"! ', ['type']),
]
_sql_constraints = [
('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')