Files
odoo_source/addons/mail/models/ir_model.py
T
Adrian Torres 14f80bfae6 [FIX] mail: delete leftover followers
[FIX] mail: delete leftover followers

Previous to this commit, if during the unlink of a model which inherits
from mail.thread an exception is raised before mail.thread's unlink() is
called, followers for such model won't be properly deleted from the
database.

This commit changes this by overriding ir_model's unlink and deleting any
followers whose res_model is not installed.

Partial back-port of 3614193
Fixes #21462
OPW 786790
2017-12-26 07:27:25 +00:00

15 lines
443 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class IrModel(models.Model):
_inherit = 'ir.model'
def unlink(self):
# Delete followers for models that will be unlinked.
query = "DELETE FROM mail_followers WHERE res_model IN %s"
self.env.cr.execute(query, [tuple(self.mapped('model'))])
return super(IrModel, self).unlink()