summaryrefslogtreecommitdiff
path: root/addons/website_theme_install/models/ir_module_module.py
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2018-12-28 13:17:26 +0000
committerSébastien Theys <seb@odoo.com>2019-01-09 12:54:47 +0000
commitc4ee25fb7ff6a6213e5d443756a0e7bc81e870e3 (patch)
tree3a0f39807d1f913b392023706393828d25cf0dd8 /addons/website_theme_install/models/ir_module_module.py
parent2e32cc5aa35044e8f0e7c299c8612a8095d9f479 (diff)
[FIX] base,*: add MODULE_UNINSTALL_FLAG to cleanup views
* website_theme_install This commit will add MODULE_UNINSTALL_FLAG to the cleanup methods of themes and modules. This is necessary to also unlink inherited views of those we try to unlink. Before this commit, an error would be raised when trying to delete a view that still had other inherited views (either created manually by the user, or with just bad luck in the order of which the views are deleted). PR: #29753
Diffstat (limited to 'addons/website_theme_install/models/ir_module_module.py')
-rw-r--r--addons/website_theme_install/models/ir_module_module.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/website_theme_install/models/ir_module_module.py b/addons/website_theme_install/models/ir_module_module.py
index 85a777efa7c..55f77590c6b 100644
--- a/addons/website_theme_install/models/ir_module_module.py
+++ b/addons/website_theme_install/models/ir_module_module.py
@@ -6,6 +6,7 @@ import os
from collections import OrderedDict
from odoo import api, fields, models
+from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG
from odoo.exceptions import MissingError
from odoo.http import request
@@ -206,7 +207,7 @@ class IrModuleModule(models.Model):
for model_name in self._theme_model_names:
template = self._get_module_data(model_name)
- models = template.with_context(active_test=False).mapped('copy_ids').filtered(lambda m: m.website_id == website)
+ models = template.with_context(**{'active_test': False, MODULE_UNINSTALL_FLAG: True}).mapped('copy_ids').filtered(lambda m: m.website_id == website)
models.unlink()
self._theme_cleanup(model_name, website)
@@ -235,8 +236,9 @@ class IrModuleModule(models.Model):
if model_name in ('website.page', 'website.menu'):
return model
-
- orphans = model.with_context(active_test=False).search([
+ # use active_test to also unlink archived models
+ # and use MODULE_UNINSTALL_FLAG to also unlink inherited models
+ orphans = model.with_context(**{'active_test': False, MODULE_UNINSTALL_FLAG: True}).search([
('key', '=like', self.name + '.%'),
('website_id', '=', website.id),
('theme_template_id', '=', False),