[FIX] Add Domain in parent_id and remove unnecessary code.
authorVijaykumar Baladaniya <vba@tinyerp.com>
Fri, 28 Sep 2012 05:58:52 +0000 (11:28 +0530)
committerVijaykumar Baladaniya <vba@tinyerp.com>
Fri, 28 Sep 2012 05:58:52 +0000 (11:28 +0530)
bzr revid: vba@tinyerp.com-20120928055852-utqbghq2e1we7r9g

addons/account/account.py

index c2e6f3d..49e106f 100644 (file)
@@ -2518,7 +2518,7 @@ class account_account_template(osv.osv):
         'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if you want the user to reconcile entries in this account."),
         'shortcut': fields.char('Shortcut', size=12),
         'note': fields.text('Note'),
-        'parent_id': fields.many2one('account.account.template', 'Parent Account Template', ondelete='cascade'),
+        'parent_id': fields.many2one('account.account.template', 'Parent Account Template', ondelete='cascade', domain=[('type','=','view')]),
         'child_parent_ids':fields.one2many('account.account.template', 'parent_id', 'Children'),
         'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel', 'account_id', 'tax_id', 'Default Taxes'),
         'nocreate': fields.boolean('Optional create', help="If checked, the new chart of accounts will not contain this by default."),
@@ -2536,20 +2536,6 @@ class account_account_template(osv.osv):
         (_check_recursion, 'Error!\nYou cannot create recursive account templates.', ['parent_id']),
     ]
 
-    def create(self, cr, uid, vals, context=None):
-        if 'parent_id' in vals:
-            parent = self.read(cr, uid, [vals['parent_id']], ['type'])
-            if parent and parent[0]['type'] != 'view':
-                raise osv.except_osv(_('Warning!'), _("You may only select a parent account of type 'View'."))
-        return super(account_account_template, self).create(cr, uid, vals, context=context)
-
-    def write(self, cr, uid, ids, vals, context=None):
-        if 'parent_id' in vals:
-            parent = self.read(cr, uid, [vals['parent_id']], ['type'])
-            if parent and parent[0]['type'] != 'view':
-                raise osv.except_osv(_('Warning!'), _("You may only select a parent account of type 'View'."))
-        return super(account_account_template, self).write(cr, uid, ids, vals, context=context)
-
     def name_get(self, cr, uid, ids, context=None):
         if not ids:
             return []