[FIX] ir.model.data: cleanup _process_end()
Allow deletion of ir.model and ir.model.fields when updating modules Log xml id of deleted records Remove xml id of non-existing records
This commit is contained in:
parent
8e5a0ac43c
commit
bfb877a671
|
@ -1230,20 +1230,25 @@ class ir_model_data(osv.osv):
|
|||
and a module in ir_model_data and noupdate set to false, but not
|
||||
present in self.loads.
|
||||
"""
|
||||
if not modules:
|
||||
if not modules or config.get('import_partial'):
|
||||
return True
|
||||
to_unlink = []
|
||||
|
||||
bad_imd_ids = []
|
||||
context = {MODULE_UNINSTALL_FLAG: True}
|
||||
cr.execute("""SELECT id,name,model,res_id,module FROM ir_model_data
|
||||
WHERE module IN %s AND res_id IS NOT NULL AND noupdate=%s ORDER BY id DESC""",
|
||||
(tuple(modules), False))
|
||||
WHERE module IN %s AND res_id IS NOT NULL AND noupdate=%s ORDER BY id DESC
|
||||
""", (tuple(modules), False))
|
||||
for (id, name, model, res_id, module) in cr.fetchall():
|
||||
if (module,name) not in self.loads:
|
||||
to_unlink.append((model,res_id))
|
||||
if not config.get('import_partial'):
|
||||
for (model, res_id) in to_unlink:
|
||||
if (module, name) not in self.loads:
|
||||
if model in self.pool:
|
||||
_logger.info('Deleting %s@%s', res_id, model)
|
||||
self.pool[model].unlink(cr, uid, [res_id])
|
||||
_logger.info('Deleting %s@%s (%s.%s)', res_id, model, module, name)
|
||||
if self.pool[model].exists(cr, uid, [res_id], context=context):
|
||||
self.pool[model].unlink(cr, uid, [res_id], context=context)
|
||||
else:
|
||||
bad_imd_ids.append(id)
|
||||
if bad_imd_ids:
|
||||
self.unlink(cr, uid, bad_imd_ids, context=context)
|
||||
self.loads.clear()
|
||||
|
||||
class wizard_model_menu(osv.osv_memory):
|
||||
_name = 'wizard.ir.model.menu.create'
|
||||
|
|
Loading…
Reference in New Issue