python - create function openerp 6.0 -


i created module in openerp 6.0, problem openerp 6.0 did not support same code openerp 7, function create: if 1 can me solve problem:

def create(self, cr, uid, vals, context=none):     if context none:         context = {}     if vals['teacher_id']:         teacher=self.pool.get("res.partner").browse(cr,uid,vals['teacher_id'],context)         teacher.attendee=true     if vals['etudiant_ids'][0][2]:         etudiant in self.pool.get("res.partner").browse(cr,uid,vals['etudiant_ids'][0][2],context):             etudiant.attendee=true     return super(attendee, self).create(cr, uid, vals, context=context) 

the problem in "if vals['etudiant_ids'][0][2]:"

if vals['etudiant_ids'][0][2]: typeerror: 'bool' object has no attribute '__getitem__' 

the above error comes, when accessing dictionary, key not found. better way debug is, use print statements check value print vals['etudiant_ids'], print vals['etudiant_ids'][0], print vals['etudiant_ids'][0][2], , can know key not fetching.

and try avoid ambigous statements, use vals.get('etudiant_ids') when using dictionaries, return false if key not found instead of error.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -