[FIX] (test_)website: fix standalone tour

Use theme_default instead of theme_common.
Instead, theme_common is not available when only website is installed as it
depends of the design-themes repository.

closes odoo/odoo#82587

X-original-commit: a10522c6509caf7f09f21e6da3224d5865f0ba6a
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Romain Derie
2022-01-12 11:19:04 +00:00
parent 1e1b45ea62
commit 90f411ea03
3 changed files with 20 additions and 17 deletions
+1
View File
@@ -15,6 +15,7 @@ models which only purpose is to run tests.""",
'depends': [
'web_unsplash',
'website',
'theme_default',
],
'data': [
'views/templates.xml',
@@ -118,20 +118,21 @@ def test_02_copy_ids_views_unlink_on_module_update(env):
website_1 = env['website'].browse(1)
website_2 = env['website'].browse(2)
theme_common = env.ref('base.module_theme_common')
theme_default = env.ref('base.module_theme_default')
# Install theme_common on website 1 and website 2
(website_1 + website_2).theme_id = theme_common
# Install theme_default on website 1 and website 2
(website_1 + website_2).theme_id = theme_default
env['ir.module.module'].with_context(load_all_views=True)._theme_load(website_1)
env['ir.module.module'].with_context(load_all_views=True)._theme_load(website_2)
key = 'theme_common.theme_child_view'
key = 'theme_default.theme_child_view'
domain = [
('type', '=', 'qweb'),
('key', '=', key),
]
def _simulate_xml_view():
# Simulate a theme.ir.ui.view inside theme_common XML files
# Simulate a theme.ir.ui.view inside theme_default XML files
base_view = env.ref('test_website.update_module_base_view')
theme_child_view = ThemeView.create({
'name': 'Theme Child View',
@@ -146,7 +147,7 @@ def test_02_copy_ids_views_unlink_on_module_update(env):
})
# Create IMD so when updating the module the views will be removed (not found in file)
Imd.create({
'module': 'theme_common',
'module': 'theme_default',
'name': 'theme_child_view',
'model': 'theme.ir.ui.view',
'res_id': theme_child_view.id,
@@ -171,20 +172,20 @@ def test_02_copy_ids_views_unlink_on_module_update(env):
return view_website_1, view_website_2, theme_child_view
############################################
## CASE 1: generic update (-u, migration) ##
############################################
##########################################
# CASE 1: generic update (-u, migration) #
##########################################
view_website_1, view_website_2, theme_child_view = _simulate_xml_view()
# Upgrade the module
theme_common.button_immediate_upgrade()
theme_default.button_immediate_upgrade()
env.reset() # clear the set of environments
env = env() # get an environment that refers to the new registry
# Ensure the theme.ir.ui.view got removed (since there is an IMD but not
# present in XML files)
view = env.ref('theme_common.theme_child_view', False)
view = env.ref('theme_default.theme_child_view', False)
assert not view, "Theme view should have been removed during module update."
assert not theme_child_view.exists(),\
"Theme view should have been removed during module update. (2)"
@@ -194,21 +195,21 @@ def test_02_copy_ids_views_unlink_on_module_update(env):
assert not (view_website_1.exists() or view_website_2.exists()),\
"copy_ids views did not get removed! (2)"
#######################################################
## CASE 2: specific update (website theme selection) ##
#######################################################
#####################################################
# CASE 2: specific update (website theme selection) #
#####################################################
view_website_1, view_website_2, theme_child_view = _simulate_xml_view()
# Upgrade the module
with MockRequest(env, website=website_1):
theme_common.button_immediate_upgrade()
theme_default.button_immediate_upgrade()
env.reset() # clear the set of environments
env = env() # get an environment that refers to the new registry
# Ensure the theme.ir.ui.view got removed (since there is an IMD but not
# present in XML files)
view = env.ref('theme_common.theme_child_view', False)
view = env.ref('theme_default.theme_child_view', False)
assert not view, "Theme view should have been removed during module update."
assert not theme_child_view.exists(),\
"Theme view should have been removed during module update. (2)"
+2 -1
View File
@@ -1,7 +1,8 @@
# coding: utf-8
from odoo.tests import common
from odoo.tests import common, tagged
@tagged('-at_install', 'post_install')
class TestTheme(common.TransactionCase):
def test_theme_remove_working(self):