[FIX] base: unlink custom cron after uninstalling model
When user uninstalls a module it doesn't unlinks custom crons which are created by user and it will keep running in the background and will generate traceback. So, to fix this we unlink all the custom crons which are related to the module being uninstalled. sentry-3929309220 closes odoo/odoo#124175 X-original-commit: b0202488220bd48dd177e9e0601f2f3ba8d7a0f1 Signed-off-by: Fabien Pinckaers <fp@odoo.com> Signed-off-by: Rahul Prajapati (rapr) <rapr@odoo.com>
This commit is contained in:
@@ -463,7 +463,7 @@ class IrActionsServer(models.Model):
|
||||
sequence = fields.Integer(default=5,
|
||||
help="When dealing with multiple actions, the execution order is "
|
||||
"based on the sequence. Low number means high priority.")
|
||||
model_id = fields.Many2one('ir.model', string='Model', required=True, ondelete='cascade',
|
||||
model_id = fields.Many2one('ir.model', string='Model', required=True, ondelete='cascade', index=True,
|
||||
help="Model on which the server action runs.")
|
||||
model_name = fields.Char(related='model_id.model', string='Model Name', readonly=True, store=True)
|
||||
# Python code
|
||||
|
||||
@@ -319,6 +319,11 @@ class IrModel(models.Model):
|
||||
# delete fields whose comodel is being removed
|
||||
self.env['ir.model.fields'].search([('relation', 'in', self.mapped('model'))]).unlink()
|
||||
|
||||
# delete ir_crons created by user
|
||||
crons = self.env['ir.cron'].with_context(active_test=False).search([('model_id', 'in', self.ids)])
|
||||
if crons:
|
||||
crons.unlink()
|
||||
|
||||
self._drop_table()
|
||||
res = super(IrModel, self).unlink()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user