[FIX] base: key error during uninstall of unavailable module
In case a user has installed a module where the code becomes unavailable or during migration a module was removed and needs to be removed after migration it is impossible to uninstall the module from a database still holding the fields or the models. In order to disable prefetch based on information from the database it is needed that the module and models of the unavailable module are initialized with related fields and models. closes odoo/odoo#62895 X-original-commit: e4a1121e572d07cc720ede8c1b1116d4f1d7ae98 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
@@ -2071,8 +2071,11 @@ class IrModelData(models.Model):
|
||||
# methods is not in cache it will be fetched, and fields that exist in the registry but not
|
||||
# in the database will be prefetched, this will of course fail and prevent the uninstall.
|
||||
for ir_field in self.env['ir.model.fields'].browse(field_ids):
|
||||
field = self.pool[ir_field.model]._fields[ir_field.name]
|
||||
field.prefetch = False
|
||||
model = self.pool.get(ir_field.model)
|
||||
if model is not None:
|
||||
field = model._fields.get(ir_field.name)
|
||||
if field is not None:
|
||||
field.prefetch = False
|
||||
|
||||
# to collect external ids of records that cannot be deleted
|
||||
undeletable_ids = []
|
||||
|
||||
Reference in New Issue
Block a user