# create method in model 'purchase.order'
@api.model
def create(self, values):
rec = super(PurchaseOrder, self).create(values)
team = self.env['crm.team'].sudo().search(
[('company_id', '=', self.env.user.company_id.id), ('main_team', '=', True)])
partners = [i.id for i in team.user_id.partner_id]
if partners:
rec.message_follower_ids = [(6, 0, partners)]
return rec
When i try to create a record as an administrator, the following error is displayed
Error message:
The requested operation cannot be completed due to security restrictions. Please contact your system administrator.
(Document type: Document Followers, Operation: write)
@api.model
def create(self, values):
rec = super(SaleOrder, self).create(values)
if 'partner_id' in values:
team = self.env['crm.team'].sudo().search(
[('company_id', '=', self.env['res.partner'].sudo().browse(values['partner_id']).company_id.id),
('main_team', '=', True)])
partners = [i.id for i in team.user_id.partner_id]
if partners:
rec.message_subscribe(partner_ids=partners)
if 'company_id' in values:
company = self.env['res.company'].sudo().browse(values['company_id'])
team = self.env['crm.team'].sudo().search(
[('company_id', '=', company.id), ('main_team', '=', True)])
partners = [i.id for i in team.user_id.partner_id]
if partners:
rec.message_subscribe(partner_ids=partners)
return rec