[ADD] theme 14.0

This commit is contained in:
Jeremy Kersten
2021-05-10 15:45:35 +02:00
commit cb1e3be3f8
2309 changed files with 55585 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_http
from . import ir_ui_view
from . import website
+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, tools
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() or tools.config.options['test_enable']) and force_website_id:
request.env['website']._force_website(force_website_id)
super(Http, cls)._add_dispatch_parameters(func)
+28
View File
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
from odoo.http import request
class View(models.Model):
_name = "ir.ui.view"
_inherit = "ir.ui.view"
@api.model
def _prepare_qcontext(self):
qcontext = super(View, self)._prepare_qcontext()
if request and getattr(request, 'is_frontend', False) and 'multi_website_websites' in qcontext:
Website = self.env['website']
websites_themes = Website.get_test_themes_websites()
for multi_website_website in qcontext['multi_website_websites']:
website_id = multi_website_website['website_id']
theme_img = None
if website_id in websites_themes.ids:
# prefetched by get_test_themes_websites
website = Website.browse(website_id)
if website.theme_id.sudo().image_ids:
theme_img = "<img src='/web/image/%s' width='150'/>" % website.theme_id.sudo().image_ids[0].id
multi_website_website['theme_img'] = theme_img
return qcontext
+24
View File
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class Website(models.Model):
_inherit = 'website'
def get_test_themes_websites(self):
website_imd_ids = self.env['ir.model.data'].sudo().search([
('module', '=', 'test_themes'),
('model', '=', 'website'),
])
return self.browse(website_imd_ids.mapped('res_id'))
def unlink(self):
websites_themes = self.get_test_themes_websites()
if self in websites_themes:
# Bypass foreign key constraint
website_domain = [('website_id', '=', self.id)]
self.env['ir.ui.view'].with_context(active_test=False, _force_unlink=True).search(website_domain).unlink()
self.env['ir.attachment'].with_context(active_test=False).search(website_domain).unlink()
return super().unlink()