Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
server-tools
queue
Empty file added report_async/README.rst
Empty file.
5 changes: 5 additions & 0 deletions report_async/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from . import models
from . import wizard
27 changes: 27 additions & 0 deletions report_async/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
{
"name": "Report Async",
"summary": "Central place to run reports live or async",
"version": "14.0.1.0.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/reporting-engine",
"category": "Generic Modules",
"depends": ["queue_job"],
"data": [
"security/ir.model.access.csv",
"security/ir_rule.xml",
"views/assets.xml",
"data/mail_template.xml",
"data/queue_job_function_data.xml",
"views/report_async.xml",
"wizard/print_report_wizard.xml",
"views/ir_actions_report.xml",
],
"qweb": ["static/src/xml/report_async.xml"],
"demo": ["demo/report_async_demo.xml"],
"installable": True,
"maintainers": ["kittiu"],
"development_status": "Beta",
}
73 changes: 73 additions & 0 deletions report_async/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="async_report_delivery" model="mail.template">
<field name="name">Report Async: New Report Available</field>
<field name="model_id" ref="base.model_ir_attachment" />
<field name="subject">Your report is available, ${object.name}</field>
<field
name="email_from"
>${object.company_id.partner_id.email_formatted|safe}</field>
<field name="partner_to">${user.partner_id.id}</field>
<field name="body_html" type="html">
<table
border="0"
cellpadding="0"
cellspacing="0"
style="background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;"
>
<tr>
<td align="center">
<table
border="0"
cellpadding="0"
cellspacing="0"
width="590"
style="padding: 16px; background-color: white; color: #454748; border-collapse:separate;"
>
<tbody>
<tr>
<td align="center" style="min-width: 590px;">
<table
border="0"
cellpadding="0"
cellspacing="0"
width="590"
style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;"
>
<tr>
<td
valign="top"
style="font-size: 13px;"
>
% set base_url_async = object.env['ir.config_parameter'].sudo().get_param('web.base.url.async_reports')
% set base_url = base_url_async or object.env['ir.config_parameter'].sudo().get_param('web.base.url')
% set download_url = '%s/web/content/ir.attachment/%s/datas/%s?download=true' % (base_url, object.id, object.name, )
<div>
Dear ${object.create_uid.partner_id.name or ''},
<br /><br />
Your requested report, ${object.name}, is available for <b
>
<a
href='${download_url}'
>download</a>
</b>.
<br /><br />
Have a nice day!<br />
--<br />${object.company_id.name}
</div>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</field>
<field name="auto_delete" eval="True" />
</record>
</data>
</odoo>
6 changes: 6 additions & 0 deletions report_async/data/queue_job_function_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo noupdate="1">
<record id="job_function_report_async_run_report" model="queue.job.function">
<field name="model_id" ref="report_async.model_report_async" />
<field name="method">run_report</field>
</record>
</odoo>
7 changes: 7 additions & 0 deletions report_async/demo/report_async_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="report_async_print_document" model="report.async">
<field name="action_id" eval="ref('report_async.action_print_report_wizard')" />
<field name="allow_async" eval="0" />
</record>
</odoo>
7 changes: 7 additions & 0 deletions report_async/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from . import report_async
from . import ir_report
from . import ir_actions
from . import queue_job
26 changes: 26 additions & 0 deletions report_async/models/ir_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import api, models


class IrActionsActWindow(models.Model):
_inherit = "ir.actions.act_window"

@api.model
def name_search(self, name, args=None, operator="ilike", limit=100):
if self._context.get("access_sudo", False):
self = self.sudo()
return super().name_search(name, args, operator, limit)

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
if self._context.get("access_sudo", False):
self = self.sudo()
return super().search(args, offset, limit, order, count)

def _read(self, fields):
"""Add permission to read analytic account for do something."""
if self._context.get("access_sudo", False):
self = self.sudo()
return super()._read(fields)
35 changes: 35 additions & 0 deletions report_async/models/ir_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import fields, models

# Define all supported report_type
REPORT_TYPES = ["qweb-pdf", "qweb-text", "qweb-xml", "csv", "excel", "xlsx"]


class Report(models.Model):
_inherit = "ir.actions.report"

async_report = fields.Boolean(default=False)
async_no_records = fields.Integer(
string="Min of Records",
default=100,
help="Min no of records to use async report functionality; e.g 100+",
)
async_mail_recipient = fields.Char(
string="Mail Recipient",
help="The email that will receive the async report",
default=lambda self: self.env.user.email,
)

def report_action(self, docids, data=None, config=True):
res = super(Report, self).report_action(docids, data=data, config=config)
if res["context"].get("async_process", False):
rpt_async_id = res["context"]["active_id"]
report_async = self.env["report.async"].browse(rpt_async_id)
if res["report_type"] in REPORT_TYPES:
report_async.with_delay().run_report(
res["context"].get("active_ids", []), data, self.id, self._uid
)
return {}
return res
30 changes: 30 additions & 0 deletions report_async/models/queue_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 Sunflower IT (https://sunflowerweb.nl/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import api, models


class QueueJob(models.Model):
_inherit = "queue.job"

@api.model
def create(self, values):
res = super(QueueJob, self).create(values)
if (
"model_name" in values
and values["model_name"] == "report.async"
and "kwargs" in values
and "to_email" in values["kwargs"]
):
followers = self._find_partner(res, values["kwargs"]["to_email"])
if followers:
res.message_subscribe(partner_ids=followers)
return res

def _find_partner(self, record, email):
partner = self.env["res.partner"].search([("email", "=", email)], limit=1)
followers = record.message_follower_ids.mapped("partner_id")
ids = [x for x in partner.ids if x not in followers.ids]
if partner and ids:
return ids
return None
Loading