[IMP] account: added new constraint on account object which will check when the inter...
authorpsi (Open ERP) <psi@tinyerp.co.in>
Fri, 1 Jul 2011 13:34:20 +0000 (19:04 +0530)
committerpsi (Open ERP) <psi@tinyerp.co.in>
Fri, 1 Jul 2011 13:34:20 +0000 (19:04 +0530)
bzr revid: psi@tinyerp.co.in-20110701133420-2pho2e8himf6sz0q

addons/account/account.py

index d0e9c50..f8b4be7 100644 (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 !')