[FIX] account: incorrect check for parent_id value

would try a read on parent_id=False, which blows up

bzr revid: xmo@openerp.com-20121001071728-npq7ieoe3rpz44i7
This commit is contained in:
Xavier Morel 2012-10-01 09:17:28 +02:00
parent 4787939773
commit 45ee8b434d
1 changed files with 2 additions and 2 deletions

View File

@ -2522,14 +2522,14 @@ class account_account_template(osv.osv):
]
def create(self, cr, uid, vals, context=None):
if 'parent_id' in vals:
if vals.get('parent_id'):
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:
if vals.get('parent_id'):
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'."))