From f4f45c476c2a734d45170f12400413bcfaa0a7ac Mon Sep 17 00:00:00 2001 From: "Rajesh Prajapati (OpenERP)" Date: Tue, 6 Nov 2012 11:57:36 +0530 Subject: [PATCH] [IMP] account : added constraints to check parent account bzr revid: rpr@tinyerp.com-20121106062736-28vgz6515h4rt3s2 --- addons/account/account.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/account/account.py b/addons/account/account.py index c9dd1950347..90ae22a08bd 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -541,10 +541,18 @@ class account_account(osv.osv): return False return True + def _check_parent_id(self, cr, uid, ids, context=None): + parent = self.browse(cr, uid, ids, context=context)[0] + if parent.parent_id: + if parent.company_id != parent.parent_id.company_id: + return False + return True + _constraints = [ (_check_recursion, 'Error!\nYou cannot 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 select an account type with a deferral method different of "Unreconciled" for accounts with internal type "Payable/Receivable".', ['user_type','type']), + (_check_parent_id, 'You cannot create an account which has parent account of different company.', ['parent_id']), ] _sql_constraints = [ ('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')