summaryrefslogtreecommitdiff
path: root/addons/website_theme_install/models/ir_module_module.py
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2018-09-05 13:55:09 +0200
committerJeremy Kersten <jke@odoo.com>2018-09-10 08:54:14 +0200
commit9e1092c61f0d014615de2b4f83b90cdb422e4593 (patch)
tree8ce1340f97c85e4bb9961cdb9df95c1803cf52d0 /addons/website_theme_install/models/ir_module_module.py
parentb83a574687c0fc5bbc5a4769e3c6cbde792bab42 (diff)
[FIX] website_theme_install: uninstall theme that have inactive views
Before this commit, if you have some inactive views (option form customize e.g.) the unload crash since you cannot remove views that is still referenced by inherit_id. Now with search with inactive views to delete all.
Diffstat (limited to 'addons/website_theme_install/models/ir_module_module.py')
-rw-r--r--addons/website_theme_install/models/ir_module_module.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/addons/website_theme_install/models/ir_module_module.py b/addons/website_theme_install/models/ir_module_module.py
index 86e262ac046..35d562485a6 100644
--- a/addons/website_theme_install/models/ir_module_module.py
+++ b/addons/website_theme_install/models/ir_module_module.py
@@ -36,7 +36,7 @@ class IrModuleModule(models.Model):
for module in self:
imd_ids = IrModelData.search([('module', '=', module.name), ('model', '=', model_name)]).mapped('res_id')
- records |= self.env[model_name].browse(imd_ids)
+ records |= self.env[model_name].with_context(active_test=False).browse(imd_ids)
return records
@api.multi
@@ -111,20 +111,22 @@ class IrModuleModule(models.Model):
for module in self:
menus = module._get_module_data('theme.website.menu')
- menu_todel = menus.mapped('copy_ids').filtered(lambda m: m.website_id == website)
+ menu_todel = menus.with_context(active_test=False).mapped('copy_ids').filtered(lambda m: m.website_id == website)
menu_todel.unlink()
pages = module._get_module_data('theme.website.page')
- pages_todel = pages.mapped('copy_ids').filtered(lambda p: p.website_id == website)
+ pages_todel = pages.with_context(active_test=False).mapped('copy_ids').filtered(lambda p: p.website_id == website)
pages_todel.unlink()
attachs = module._get_module_data('theme.ir.attachment')
- atachs_todel = attachs.mapped('copy_ids').filtered(lambda a: a.website_id == website)
+ atachs_todel = attachs.with_context(active_test=False).mapped('copy_ids').filtered(lambda a: a.website_id == website)
atachs_todel.unlink()
views = module._get_module_data('theme.ir.ui.view')
- views_todel = views.mapped('copy_ids').filtered(lambda v: v.website_id == website)
- views_todel.unlink()
+ views_todel = views.with_context(active_test=False).mapped('copy_ids').filtered(lambda v: v.website_id == website)
+ # double check - Some records that can be orpahns or no more in the template view.
+ views_todel2 = self.env['ir.ui.view'].with_context(active_test=False).search([('key', '=like', self.name + '_%'), ('website_id', '=', website.id)])
+ (views_todel + views_todel2).unlink()
def _remove_theme_on_website(self, website):
installed_deps = self + website.theme_id.upstream_dependencies(exclude_states=('',)).filtered(lambda x: x.name.startswith('theme_'))