Hello Guys
I got a weird Error when I try to create a record in my model. => Error, a partner cannot follow twice the same object.
Do you have any idea how to avoid this ?
Thanks a lot
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello Guys
I got a weird Error when I try to create a record in my model. => Error, a partner cannot follow twice the same object.
Do you have any idea how to avoid this ?
Thanks a lot
you should delete the records from mail_followers.
eg:
delete from mail_followers where res_model in ('hr.attendance.status', 'hr_timesheet_sheet.sheet')
update the code with your concerned model. This is a limitation of the mail_followers model.
Hi, you can use this code:
class Followers(models.Model):
_inherit = 'mail.followers'
@api.model
def create(self, vals):
if 'res_model' in vals and 'res_id' in vals and 'partner_id' in vals:
dups = self.env['mail.followers'].search([('res_model', '=',vals.get('res_model')),
('res_id', '=', vals.get('res_id')),
('partner_id', '=', vals.get('partner_id'))])
if len(dups):
for p in dups:
p.unlink()
res = super(Followers, self).create(vals)
return res
Hi Othmane,
You can solve the issue by referring this blog, https://www.cybrosys.com/blog/how-to-get-rid-of-the-error-a-partner-cannot-follow-twice-the-same-object
Thanks
I already see it, I want a general solution for all the models
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
Disable Followers
Solved
|
|
1
Jul 24
|
1182 | |
|
0
Feb 22
|
1120 | ||
|
0
Feb 20
|
1909 | ||
add followers automatically
Solved
|
|
8
Jun 24
|
34839 | |
|
1
Mar 23
|
1436 |