Hi there i'm tring to override create fucntion to add records in two table same time but i'm getting errorr
when i try to choose standerd for student the student should be added to many2many field in standerd model but i get an errpr when i try to do so .
here is my fields in student model :
'standard_id': fields.many2one('fci.standard', string='Standard', required=True),
and here is my fields in standrard table model:
'code': fields.char(size=8, string='Code', required=True),
'name': fields.char(size=32, string='Name', required=True),
'sequence': fields.integer('Sequence'),
'student_ids': fields.many2many('fci.student', 'student_standard_rel', 'fci_student_standard_id', 'standard_id',
string='Student(s)'),
and here is my create function
def create(self, cr, uid, vals, context=None):
context = context or {}
created_id = super(NAME_OF_YOUR_CLASS, self).create(cr, uid, vals, context=context)
if vals.get('standard_id'):
self.pool.get('fci.standard').write(cr, uid, vals['standard_id'],
{'student_ids': [(4, created_id)]}, context=context)
return created_id
i hope i can find help