mirror of https://github.com/OCA/web.git
[MIG] web_assets_warmup: Migration to 18.0
parent
76827edc3b
commit
58de22f111
|
@ -67,6 +67,13 @@ Contributors
|
|||
|
||||
- Sébastien Alix <sebastien.alix@camptocamp.com>
|
||||
- Michael Tietz (MT Software) <mtietz@mt-software.de>
|
||||
- Do Anh Duy <duyda@trobz.com>
|
||||
|
||||
Other credits
|
||||
-------------
|
||||
|
||||
The migration of this module from 14.0 to 18.0 was financially supported
|
||||
by Camptocamp.
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{
|
||||
"name": "Generate assets when Odoo starts",
|
||||
"summary": "Ensure that assets are generated when Odoo starts.",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "18.0.1.0.0",
|
||||
"category": "Hidden",
|
||||
"author": "Camptocamp, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
<field name='name'>Generate report assets</field>
|
||||
<field name='interval_number'>1</field>
|
||||
<field name='interval_type'>months</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="active" eval="True" />
|
||||
<field name="doall" eval="False" />
|
||||
<field
|
||||
name="nextcall"
|
||||
eval="(datetime.now() + timedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:00')"
|
||||
|
|
|
@ -7,7 +7,9 @@ import os
|
|||
|
||||
import psycopg2
|
||||
|
||||
from odoo import fields, registry
|
||||
from odoo import fields
|
||||
from odoo.modules.registry import Registry
|
||||
from odoo.tools import config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -16,8 +18,8 @@ def active_cron_assets():
|
|||
"""Plan the next execution of the cron responsible to generate assets."""
|
||||
if os.environ.get("RUNNING_ENV") == "dev":
|
||||
return
|
||||
dbname = os.environ.get("DB_NAME")
|
||||
reg = registry(dbname)
|
||||
dbname = config["db_name"]
|
||||
reg = Registry(dbname)
|
||||
with reg.cursor() as cr:
|
||||
cron_module, cron_ref = "web_assets_warmup", "cron_generate_assets"
|
||||
query = """
|
||||
|
|
|
@ -15,23 +15,13 @@ class IrActionsReport(models.Model):
|
|||
def cron_generate_assets(self):
|
||||
"""Ensure that the assets are well-generated in the database."""
|
||||
logger.info("Ensure that assets are generated and stored in the database...")
|
||||
# Call `_get_asset_nodes` as done when printing a report based on
|
||||
# `web.report_layout` template (used by `web.html_container`)
|
||||
options = {
|
||||
"commit_assetsbundle": False,
|
||||
"debug": False,
|
||||
"inherit_branding": False,
|
||||
"dev_mode": False,
|
||||
"caller_template": "web.html_container",
|
||||
}
|
||||
assets_template_ids = [
|
||||
bundles = [
|
||||
"web.report_assets_common",
|
||||
"web.assets_common",
|
||||
"web.report_assets_pdf",
|
||||
]
|
||||
for xml_id in assets_template_ids:
|
||||
self.env["ir.qweb"]._get_asset_nodes(
|
||||
xmlid=xml_id, options=options, css=True, js=True
|
||||
)
|
||||
for bundle in bundles:
|
||||
files = self.env["ir.qweb"]._get_asset_bundle(bundle, css=True, js=True)
|
||||
files.js()
|
||||
files.css()
|
||||
logger.info("Ensure that assets are generated and stored in the database: done")
|
||||
return True
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
- Sébastien Alix \<<sebastien.alix@camptocamp.com>\>
|
||||
- Michael Tietz (MT Software) \<<mtietz@mt-software.de>\>
|
||||
- Do Anh Duy \<<duyda@trobz.com>\>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp.
|
|
@ -385,7 +385,8 @@ well-generated when Odoo starts, not when the report is printed.</p>
|
|||
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
|
||||
<li><a class="reference internal" href="#other-credits" id="toc-entry-5">Other credits</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -411,10 +412,16 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<ul class="simple">
|
||||
<li>Sébastien Alix <<a class="reference external" href="mailto:sebastien.alix@camptocamp.com">sebastien.alix@camptocamp.com</a>></li>
|
||||
<li>Michael Tietz (MT Software) <<a class="reference external" href="mailto:mtietz@mt-software.de">mtietz@mt-software.de</a>></li>
|
||||
<li>Do Anh Duy <<a class="reference external" href="mailto:duyda@trobz.com">duyda@trobz.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="other-credits">
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
|
||||
<p>The migration of this module from 14.0 to 18.0 was financially supported
|
||||
by Camptocamp.</p>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
|
|
Loading…
Reference in New Issue