Reputation: 135
I want to add a user on group that exist on res.groups But i don't know why he does not add in this group This is my code python
class access_teacher1(models.Model):
_inherit = 'res.users'
def create(self, cr, uid, vals, context=None):
new_id = super(access_teacher1, self).create(cr, uid, vals, context=context)
if self.browse(cr, uid, new_id, context=context).is_teacher:
self.write(cr, uid, [new_id], {'password': vals['login']}, context=context)
res_groups = self.pool['res.groups']
group_id = self.pool['ir.model.data'].get_object(cr, uid,'pronote','proschool_teacher')
res_groups.write(cr, uid, [group_id], {'users': [new_id]}, context=context)
return new_id
the problem stopped on {'users': [new_id]} how to fix that
Upvotes: 1
Views: 370
Reputation: 2754
Try this:
res_groups.write(cr, uid, [group_id.id], {'users': [(4,new_id)]}, context=context)
The reason is that Odoo use an special command format to write values against the One2many and Many2many fields
You could read more about it at:
Upvotes: 3