From 23c3bc1a5982bd92fa80b112b259f949edb5f024 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 18 Oct 2016 18:11:36 +0200 Subject: [PATCH] [FIX] web: really remove traceback on unlink_if_refcount Previous commit was just stupid: #4128ab641 - Mea Culpa --- odoo/addons/base/ir/ir_model.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/odoo/addons/base/ir/ir_model.py b/odoo/addons/base/ir/ir_model.py index d94385e88cb..1e23c311da2 100644 --- a/odoo/addons/base/ir/ir_model.py +++ b/odoo/addons/base/ir/ir_model.py @@ -1233,7 +1233,7 @@ class IrModelData(models.Model): _logger.info('Unable to force processing of workflow for item %s@%s in order to leave activity to be deleted', res_id, model, exc_info=True) def unlink_if_refcount(to_unlink): - global undeletable + undeletable = self.browse() for model, res_id in to_unlink: external_ids = self.search([('model', '=', model), ('res_id', '=', res_id)]) if external_ids - datas: @@ -1261,21 +1261,22 @@ class IrModelData(models.Model): self._cr.execute('ROLLBACK TO SAVEPOINT record_unlink_save') else: self._cr.execute('RELEASE SAVEPOINT record_unlink_save') + return undeletable # Remove non-model records first, then model fields, and finish with models - unlink_if_refcount(item for item in to_unlink if item[0] not in ('ir.model', 'ir.model.fields', 'ir.model.constraint')) - unlink_if_refcount(item for item in to_unlink if item[0] == 'ir.model.constraint') + undeletable += unlink_if_refcount(item for item in to_unlink if item[0] not in ('ir.model', 'ir.model.fields', 'ir.model.constraint')) + undeletable += unlink_if_refcount(item for item in to_unlink if item[0] == 'ir.model.constraint') modules = self.env['ir.module.module'].search([('name', 'in', modules_to_remove)]) constraints = self.env['ir.model.constraint'].search([('module', 'in', modules.ids)]) constraints._module_data_uninstall() - unlink_if_refcount(item for item in to_unlink if item[0] == 'ir.model.fields') + undeletable += unlink_if_refcount(item for item in to_unlink if item[0] == 'ir.model.fields') relations = self.env['ir.model.relation'].search([('module', 'in', modules.ids)]) relations._module_data_uninstall() - unlink_if_refcount(item for item in to_unlink if item[0] == 'ir.model') + undeletable += unlink_if_refcount(item for item in to_unlink if item[0] == 'ir.model') self._cr.commit()