I have created on2many field in class A and other field nombre (integer):
'Inventaire' : fields.one2many('class.b','id_classb'),
'nombre' : fields.integer('Nombre'),
In class b :
'id_classb' : fields.many2one('class.a', 'ID_classA'),
'ql' : fields.integer('QL'),
I want to create a function in class a that create records for object b according to the value of nombre field. for example if nombre =3 I should create 3 object of class b
here is my function:
def save_b(self, cr, uid, ids, field_name, arg, context):
a= self.browse(cr, uid, id)
nbr=a.nombre
num=22
for i in range(nbr):
num+=1
self.create(cr, uid, [(0, 0,{'ql':num})])
I get these errors : TypeError:range()integer expected ,got NoneType ValueError: dictionary update sequence element #0 has length 3; 2 is required
can someone help me to improve my function?