[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
15 lines
443 B
Python
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()
|