[FIX] base,web_editor,website: pregenerate lazyloaded bundles
Prior to this commit, lazy-loaded bundles weren't pregenerated, potentially causing non-deterministic test failures when the generation process took too long. Plus, each Python test loading these bundles necessitated their regeneration. With this commit, the lazy-loaded bundles are now included in the pregenerated bundles. task-3493014 runbot-24842 closes odoo/odoo#134464 Related: odoo/enterprise#46985 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import ir_qweb
|
||||
from . import mailing_models
|
||||
from . import mailing_models_cornercase
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models
|
||||
|
||||
class IrQWeb(models.AbstractModel):
|
||||
_inherit = "ir.qweb"
|
||||
|
||||
def _get_bundles_to_pregenarate(self):
|
||||
js_assets, css_assets = super(IrQWeb, self)._get_bundles_to_pregenarate()
|
||||
assets = {'mass_mailing.iframe_css_assets_edit'}
|
||||
return (js_assets | assets, css_assets | assets)
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import ir_attachment
|
||||
from . import ir_qweb
|
||||
from . import ir_qweb_fields
|
||||
from . import ir_ui_view
|
||||
from . import ir_http
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models
|
||||
|
||||
class IrQWeb(models.AbstractModel):
|
||||
_inherit = "ir.qweb"
|
||||
|
||||
def _get_bundles_to_pregenarate(self):
|
||||
js_assets, css_assets = super(IrQWeb, self)._get_bundles_to_pregenarate()
|
||||
assets = {
|
||||
'web_editor.assets_legacy_wysiwyg',
|
||||
'web_editor.backend_assets_wysiwyg',
|
||||
'web_editor.assets_wysiwyg',
|
||||
'web_editor.wysiwyg_iframe_editor_assets',
|
||||
}
|
||||
return (js_assets | assets, css_assets | assets)
|
||||
@@ -136,3 +136,11 @@ class IrQWeb(models.AbstractModel):
|
||||
if isinstance(atts.get('style'), str) and 'background-image' in atts['style']:
|
||||
atts['style'] = re_background_image.sub(lambda m: '%s%s' % (m[1], url_adapter(m[2])), atts['style'])
|
||||
return atts
|
||||
|
||||
def _get_bundles_to_pregenarate(self):
|
||||
js_assets, css_assets = super(IrQWeb, self)._get_bundles_to_pregenarate()
|
||||
assets = {
|
||||
'website.backend_assets_all_wysiwyg',
|
||||
'website.assets_all_wysiwyg',
|
||||
}
|
||||
return (js_assets | assets, css_assets | assets)
|
||||
|
||||
@@ -2626,6 +2626,24 @@ class IrQWeb(models.AbstractModel):
|
||||
"""
|
||||
_logger.runbot('Pregenerating assets bundles')
|
||||
|
||||
js_bundles, css_bundles = self._get_bundles_to_pregenarate()
|
||||
|
||||
links = []
|
||||
start = time.time()
|
||||
for bundle in sorted(js_bundles):
|
||||
links += self._generate_asset_links(bundle, css=False, js=True)
|
||||
_logger.info('JS Assets bundles generated in %s seconds', time.time()-start)
|
||||
start = time.time()
|
||||
for bundle in sorted(css_bundles):
|
||||
links += self._generate_asset_links(bundle, css=True, js=False)
|
||||
_logger.info('CSS Assets bundles generated in %s seconds', time.time()-start)
|
||||
return links
|
||||
|
||||
def _get_bundles_to_pregenarate(self):
|
||||
"""
|
||||
Returns the list of bundles to pregenerate.
|
||||
"""
|
||||
|
||||
views = self.env['ir.ui.view'].search([('type', '=', 'qweb'), ('arch_db', 'like', 't-call-assets')])
|
||||
js_bundles = set()
|
||||
css_bundles = set()
|
||||
@@ -2638,16 +2656,8 @@ class IrQWeb(models.AbstractModel):
|
||||
js_bundles.add(asset)
|
||||
if css:
|
||||
css_bundles.add(asset)
|
||||
links = []
|
||||
start = time.time()
|
||||
for bundle in sorted(js_bundles):
|
||||
links += self._generate_asset_links(bundle, css=False, js=True)
|
||||
_logger.info('JS Assets bundles generated in %s seconds', time.time()-start)
|
||||
start = time.time()
|
||||
for bundle in sorted(css_bundles):
|
||||
links += self._generate_asset_links(bundle, css=True, js=False)
|
||||
_logger.info('CSS Assets bundles generated in %s seconds', time.time()-start)
|
||||
return links
|
||||
|
||||
return (js_bundles, css_bundles)
|
||||
|
||||
|
||||
def render(template_name, values, load, **options):
|
||||
|
||||
Reference in New Issue
Block a user