Skip to Content
Menu
This question has been flagged
1 Reply
1189 Views

One of my users gets this error when she tries to open the Inbox on Discuss:


Record does not exist or has been deleted.

(Record: crm.lead(51,), User: 8)


crm.lead with id 51 seems to be deleted when I search for it using the shell. 

I've tried to delete alle messages related to this lead, hoping this would solve the error. On the odoo shell:

env['mail.message'].search([('res_id', '=', 51), ('model', '=', 'crm.lead')]).unlink()


2022-11-16 08:44:42,459 130 INFO odoo.models.unlink: User #1 deleted mail.message records with IDs: [947, 941]


But the error remains. How can I solve this?





Avatar
Discard
Author Best Answer

Ok so I didn't commit the db transaction after unlink(). That solved my problem.


For reference here's what I did in the odoo.sh shell

odoo-bin shell
env['mail.message'].with_user(8)._message_fetch(domain=[('needaction', '=', True)]) # to replicate the error and find the offending message id's
env['mail.message'].with_user(8).search([('needaction', '=', True), ('res_id', '=', 51)]).sudo().unlink()
self.env.cr.commit()
Avatar
Discard