I'm using odoo version 12 and i have a module that inherit maintenace module :
class iserp_op_asset_request(models.Model):
_inherit ="maintenance.request"
...
The maintenance module have function to automatically add a user as followers :
@api.model
def create(self, vals):
self = self.with_context(mail_create_nolog=True)
request = super(MaintenanceRequest, self).create(vals)
if request.owner_user_id or request.user_id:
request._add_followers()
if request.equipment_id and not request.maintenance_team_id:
request.maintenance_team_id = request.equipment_id.maintenance_team_id
request.activity_update()
return request
def _add_followers(self):
for request in self:
partner_ids = (request.owner_user_id.partner_id + request.user_id.partner_id).ids
request.message_subscribe(partner_ids=partner_ids)
So, i wanna automatically add the users who's in Administrative Manager groups as followers when the record be create. I modified _add_followers like this:
def _add_followers(self):
for request in self:
user_ids = self.env['res.groups'].search([('name', '=', 'Administrative Manager')]).users.id
request.message_subscribe(partner_ids=user_ids)
A Error display when i try create a new record
File "/usr/lib/python3/dist-packages/odoo/addons/maintenance/models/maintenance.py", line 337, in create request._add_followers() File "/mnt/extra-addons/iserp_op_asset/models/iserp_op_asset_request.py", line 17, in _add_followers user_ids = self.env['res.groups'].search([('name', '=', 'Administrative Manager')]).users.id File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2863, in __get__ raise ValueError("Expected singleton: %s" % record) ValueError: Expected singleton: res.users(8, 6)
What am i wrong here ? and how can i fix that ?