diff options
| author | Romain Derie <rde@odoo.com> | 2019-03-07 11:39:10 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2019-03-07 13:36:10 +0000 |
| commit | 3f5a6f423d1556191a814367c6194f67ae3aca91 (patch) | |
| tree | 3441139dc5d740ab132099bc53d9d84b96b7a8b8 | |
| parent | ffbdea57f5d0e736a45d1e1d63791ae006943f4e (diff) | |
[FIX] website: fix install theme error
Commit 5a81d8883 fixed the COW view deletion on module update but introduced an
error when installing a theme.
Indeed, when installing a theme, the first step is to remove the currently
installed theme from the website (by unlinking its ir.ui.view).
Commit 5a81d8883 introduced the fact that deleting an ir.ui.view during a
module uninstall also search and delete the COW views, calling
`_get_specific_views` (that expects a singleton).
When installing a theme, it calls `_theme_cleanup` which search COW views and
unlink them. If not cow view, unlink is called with an empty record set raising
the singleton error.
closes odoo/odoo#31662
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
| -rw-r--r-- | addons/test_website/tests/test_views_during_module_operation.py | 2 | ||||
| -rw-r--r-- | addons/website/models/ir_ui_view.py | 8 | ||||
| -rw-r--r-- | addons/website_theme_install/tests/__init__.py | 1 | ||||
| -rw-r--r-- | addons/website_theme_install/tests/test_theme.py | 14 |
4 files changed, 21 insertions, 4 deletions
diff --git a/addons/test_website/tests/test_views_during_module_operation.py b/addons/test_website/tests/test_views_during_module_operation.py index fceb71b5dc4..58cf943daf4 100644 --- a/addons/test_website/tests/test_views_during_module_operation.py +++ b/addons/test_website/tests/test_views_during_module_operation.py @@ -62,7 +62,7 @@ class TestViewsDuringModuleOperation(TransactionCase): self.assertTrue(self.env.ref(update_module_view_to_be_t_called.key)) self.assertTrue(self.env.ref(update_module_base_view.key)) - # Uninstall module + # Update the module test_website_module = self.env['ir.module.module'].search([('name', '=', 'test_website')]) test_website_module.button_immediate_upgrade() diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 90447640c41..d40204f7ff3 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -158,10 +158,12 @@ class View(models.Model): # care of creating pages and menus. view.with_context(website_id=website.id).write({'name': view.name}) - if self.pool._init: - self += self._get_specific_views() + specific_views = self.env['ir.ui.view'] + if self and self.pool._init: + for view in self: + specific_views += view._get_specific_views() - result = super(View, self).unlink() + result = super(View, self + specific_views).unlink() self.clear_caches() return result diff --git a/addons/website_theme_install/tests/__init__.py b/addons/website_theme_install/tests/__init__.py index 28efb5bbfb5..ae189cba198 100644 --- a/addons/website_theme_install/tests/__init__.py +++ b/addons/website_theme_install/tests/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import test_theme from . import test_views diff --git a/addons/website_theme_install/tests/test_theme.py b/addons/website_theme_install/tests/test_theme.py new file mode 100644 index 00000000000..845474d67d2 --- /dev/null +++ b/addons/website_theme_install/tests/test_theme.py @@ -0,0 +1,14 @@ +# coding: utf-8 +from odoo.tests import common + + +class TestTheme(common.TransactionCase): + + def test_theme_remove_working(self): + """ This test ensure theme can be removed. + Theme removal is also the first step during theme installation. + """ + theme_common_module = self.env['ir.module.module'].search([('name', '=', 'theme_default')]) + website = self.env['website'].get_current_website() + website.theme_id = theme_common_module.id + self.env['ir.module.module']._theme_remove(website) |
