[FIX] base: copied views are delete too early
Install Invoicing (account) and uninstall it. It results to a an error
because some views required by `payment.acquirer` are deleted before
the acquirers.
The problem is due to the way copied views are deleted, since 1388b7f
they are removed before the module uninstallation. The related commit
faced a similar problem where copied views were deleted too late
during a module uninstallation.
The two problems are revealing that the copied views have to be removed
as part of the module uninstallation, more precisely after all records
refering to them has been deleted but before the schemas has been
cleaned.
opw-1943286
closes odoo/odoo#31443
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
committed by
Julien (juc) Castiaux
parent
63ba2317f8
commit
8a7dc813af
@@ -1594,9 +1594,17 @@ class IrModelData(models.Model):
|
||||
|
||||
# Remove non-model records first, then model fields, and finish with models
|
||||
undeletable += unlink_if_refcount(item for item in to_unlink if item[0] not in ('ir.model', 'ir.model.fields', 'ir.model.constraint'))
|
||||
|
||||
# Remove copied views. This must happen after removing all records from
|
||||
# the modules to remove, otherwise ondelete='restrict' may prevent the
|
||||
# deletion of some view. This must also happen before cleaning up the
|
||||
# database schema, otherwise some dependent fields may no longer exist
|
||||
# in database.
|
||||
modules = self.env['ir.module.module'].search([('name', 'in', modules_to_remove)])
|
||||
modules._remove_copied_views()
|
||||
|
||||
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()
|
||||
|
||||
|
||||
@@ -457,7 +457,6 @@ class Module(models.Model):
|
||||
tables, columns, constraints, etc.
|
||||
"""
|
||||
modules_to_remove = self.mapped('name')
|
||||
self._remove_copied_views()
|
||||
self.env['ir.model.data']._module_data_uninstall(modules_to_remove)
|
||||
# we deactivate prefetching to not try to read a column that has been deleted
|
||||
self.with_context(prefetch_fields=False).write({'state': 'uninstalled', 'latest_version': False})
|
||||
|
||||
Reference in New Issue
Block a user