H, I have the following code
class Sprint(models.Model):
user_id = fields.Many2one('res.users', string='Assigned to',
domain=[('id', 'in', self.team_ids.team_members.id)])
class Team(models.Model):
team_members = fields.Many2many('res.users')
sprint_ids = fields.Many2many('project_extension.sprint')
With the following error :
Odoo Server Error
Traceback (most recent call last):
File "/var/www/odoo10/odoo/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/var/www/odoo10/odoo/odoo/http.py", line 689, in dispatch
return self._json_response(result)
File "/var/www/odoo10/odoo/odoo/http.py", line 627, in _json_response
body = json.dumps(response)
File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
return _default_encoder.encode(obj) File "/usr/lib/python2.7/json/encoder.py", line 207, in encode chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: res.users() is not JSON serializable
I've tried many thing, both in python and xml files
What I wan't is to filter my field "Assigned to" on my Sprint view form with only user who are in a team attached to the sprint.
If someone have an idea thanks a lot !
Sorry I made a mistake (and can't edit my post), this error doesnt appear with this code
the domaine is like:
domain=lambda self: [(self.user_id,'=',self.team_ids.team_members.id)])
Also if someone know how to filter based on user group, please tell me.
I tried
domain="[('user_id.groups_id','=',38)]"
where 38 should be project.group_project_user