Skip to content

Commit

Permalink
[MIG] web_assets_warmup: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviedoanhduy committed Dec 20, 2024
1 parent 9d03742 commit 6144c45
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
7 changes: 7 additions & 0 deletions web_assets_warmup/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Contributors

- Sébastien Alix <[email protected]>
- Michael Tietz (MT Software) <[email protected]>
- Do Anh Duy <[email protected]>

Other credits
-------------

The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion web_assets_warmup/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions web_assets_warmup/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down
8 changes: 5 additions & 3 deletions web_assets_warmup/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

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__)

Expand All @@ -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 = """
Expand Down
17 changes: 5 additions & 12 deletions web_assets_warmup/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ def cron_generate_assets(self):
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 change: 1 addition & 0 deletions web_assets_warmup/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Sébastien Alix \<<[email protected]>\>
- Michael Tietz (MT Software) \<<[email protected]>\>
- Do Anh Duy \<<[email protected]>\>
1 change: 1 addition & 0 deletions web_assets_warmup/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp.
11 changes: 9 additions & 2 deletions web_assets_warmup/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ <h1 class="title">Generate assets when Odoo starts</h1>
<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>
Expand All @@ -411,10 +412,16 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Sébastien Alix &lt;<a class="reference external" href="mailto:sebastien.alix&#64;camptocamp.com">sebastien.alix&#64;camptocamp.com</a>&gt;</li>
<li>Michael Tietz (MT Software) &lt;<a class="reference external" href="mailto:mtietz&#64;mt-software.de">mtietz&#64;mt-software.de</a>&gt;</li>
<li>Do Anh Duy &lt;<a class="reference external" href="mailto:duyda&#64;trobz.com">duyda&#64;trobz.com</a>&gt;</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" />
Expand Down

0 comments on commit 6144c45

Please sign in to comment.