[ADD] theme 13.0

This commit is contained in:
Design
2021-05-11 15:59:09 +02:00
committed by Jeremy Kersten
commit a2747ad88b
2859 changed files with 66469 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from odoo import api, SUPERUSER_ID
def post_init_hook(cr, registry):
''' Create a new website for each theme and install the theme on it. '''
env = api.Environment(cr, SUPERUSER_ID, {})
IrModule = env['ir.module.module']
themes = IrModule.search([
('category_id', 'child_of', env.ref('base.module_category_theme').id),
], order='name')
exclude_list = ['_common', '_blog', '_sale']
themes = themes.filtered(lambda t: not any([ex for ex in exclude_list if ex in t.name]))
assert len(themes) == len(env.ref('base.module_test_themes').dependencies_id)
for theme in themes:
website = env['website'].create({
'name': theme.display_name,
'social_facebook': 'test_themes',
'theme_id': theme.id,
})
theme._theme_get_stream_themes()._theme_load(website)
def uninstall_hook(cr, registry):
''' Remove the created websites. '''
env = api.Environment(cr, SUPERUSER_ID, {})
websites_themes = env['website'].search([('social_facebook', '=', 'test_themes')])
assert len(websites_themes) == len(env.ref('base.module_test_themes').dependencies_id)
# Bypass foreign key constraint
website_domain = [('website_id', 'in', websites_themes.ids)]
env['ir.ui.view'].with_context(active_test=False, _force_unlink=True).search(website_domain).unlink()
env['ir.attachment'].with_context(active_test=False).search(website_domain).unlink()
websites_themes.unlink()
+47
View File
@@ -0,0 +1,47 @@
{
'name': 'Themes Testing Module',
'version': '1.0',
'category': 'Hidden',
'sequence': 9877,
'summary': 'Create a new website for each Odoo theme for an easy preview.',
'description': """This module will help you to quickly test all the Odoo
themes without having to switch from one theme to another on your website.
It will simply create a new website for each Odoo theme and install every
theme on one website.""",
'depends': [
# CE themes
'theme_bootswatch',
'theme_default',
# design-themes themes
'theme_anelusia',
'theme_artists',
'theme_avantgarde',
'theme_beauty',
'theme_bewise',
'theme_bistro',
'theme_bookstore',
'theme_clean',
'theme_enark',
'theme_graphene',
'theme_kea',
'theme_kiddo',
'theme_loftspace',
'theme_monglia',
'theme_nano',
'theme_notes',
'theme_odoo_experts',
'theme_orchid',
'theme_real_estate',
'theme_treehouse',
'theme_vehicle',
'theme_yes',
'theme_zap',
],
'data': [
],
'installable': True,
'application': False,
'post_init_hook': 'post_init_hook',
'uninstall_hook': 'uninstall_hook',
}
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_http
+18
View File
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.http import request
class Http(models.AbstractModel):
_inherit = 'ir.http'
@classmethod
def _add_dispatch_parameters(cls, func):
# Allow public user to use `fw` query string in test mode to ease tests
force_website_id = request.httprequest.args.get('fw')
if request.registry.in_test_mode() and force_website_id:
request.env['website']._force_website(force_website_id)
super(Http, cls)._add_dispatch_parameters(func)
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_crawl
+33
View File
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
@tagged('post_install', '-at_install')
class Crawler(HttpCase):
def test_01_crawl_every_themes(self):
""" Crawl every website (and so every themes) to ensure all themes can
be rendered and do not crash.
"""
Website = self.env['website']
websites_themes = Website.search([('social_facebook', '=', 'test_themes')])
assert len(websites_themes) == len(self.env.ref('base.module_test_themes').dependencies_id)
def test_crawling():
for website in websites_themes.filtered(lambda w: w.theme_id.name != 'theme_default'):
r = self.url_open('/?fw=%s&debug=assets' % website.id)
self.assertEqual(r.status_code, 200, "Ensure rendering went fine as public user")
self.assertTrue('/%s/static/src' % website.theme_id.name in r.text, "Ensure rendering went fine as public user")
# Hack for theme_bootswatch which does not have it's own view asset
WebsiteBootswatch = websites_themes.filtered(lambda w: w.theme_id.name == 'theme_bootswatch')
vref = Website.with_context(website_id=WebsiteBootswatch.id).viewref
(vref('theme_bootswatch.theme_cosmo_bs_variables') + vref('theme_bootswatch.theme_cosmo')).write({'active': True})
# 1. Test as public user
test_crawling()
# 2. Test as admin
self.authenticate('admin', 'admin')
test_crawling()