Skip to content
Snippets Groups Projects
Commit 112bd835 authored by Martin Trigaux's avatar Martin Trigaux Committed by Raphael Collet
Browse files

[FIX] base: drop translations when dropping a column or table

Better than if ba58888c as the records may be removed via ondelete='cascade'
(where the unlink is not called on the record).  Will be faster too.

A solution to opw-1955062 and opw-1950117 with uninstallation of website.

Closes odoo/odoo#32056
parent ad4b5053
No related branches found
No related tags found
No related merge requests found
......@@ -185,6 +185,11 @@ class IrModel(models.Model):
self._cr.execute('DROP VIEW "%s"' % table)
elif kind == 'r':
self._cr.execute('DROP TABLE "%s" CASCADE' % table)
# discard all translations for this model
self._cr.execute("""
DELETE FROM ir_translation
WHERE type IN ('model', 'model_terms') AND name LIKE %s
""", [model.model + ',%'])
else:
_logger.warning('The model %s could not be dropped because it did not exist in the registry.', model.model)
return True
......@@ -574,6 +579,12 @@ class IrModelFields(models.Model):
tables_to_drop.add(rel_name)
if field.state == 'manual' and is_model:
model._pop_field(field.name)
if field.translate:
# discard all translations for this field
self._cr.execute("""
DELETE FROM ir_translation
WHERE type IN ('model', 'model_terms') AND name=%s
""", ['%s,%s' % (field.model, field.name)])
if tables_to_drop:
# drop the relation tables that are not used by other fields
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment