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
43 changes: 22 additions & 21 deletions report_async/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# 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': '12.0.1.0.1',
'author': 'Ecosoft, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/reporting-engine',
'category': 'Generic Modules',
'depends': [
'queue_job',
"name": "Report Async",
"summary": "Central place to run reports live or async",
"version": "10.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",
"data/mail_template.xml",
"views/assets.xml",
"views/ir_actions_report_xml.xml",
"views/report_async.xml",
"wizard/print_report_wizard.xml"
],
'data': [
'security/ir.model.access.csv',
'security/ir_rule.xml',
'data/mail_template.xml',
'views/report_async.xml',
'wizard/print_report_wizard.xml',
'qweb': [
'static/src/xml/report_async.xml'
],
'demo': [
'demo/report_async_demo.xml',
],
'installable': True,
'maintainers': ['kittiu'],
'development_status': 'Beta',
"demo": ["demo/report_async_demo.xml"],
"installable": True,
"maintainers": ["kittiu"],
"development_status": "Beta",
}
7 changes: 4 additions & 3 deletions report_async/data/mail_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<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="email_from">${object.sudo().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;">
Expand All @@ -18,15 +18,16 @@
<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 = object.env['ir.config_parameter'].sudo().get_param('web.base.url')
% 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}
--<br/>${object.sudo().company_id.name}
</div>
</td>
</tr>
Expand Down
4 changes: 3 additions & 1 deletion report_async/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +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_actions_report_xml
from . import ir_report
from . import report_async
from . import queue_job
36 changes: 36 additions & 0 deletions report_async/models/ir_actions_report_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, fields, api


class IrActionsReportXml(models.Model):
"""
Reports
"""

_inherit = 'ir.actions.report.xml'

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+"
)

@api.model
def is_report_async(self, report_name):
""" Returns True if the report is an async report

Called from js
"""
report_obj = self.env['report']
report = report_obj._get_report_from_name(report_name)
result = {'is_report_async': False}
if not report:
return result
return {
'is_report_async': report.async_report,
'no_of_records': report.async_no_records,
'mail_recipient': self.env.user.email
}
23 changes: 10 additions & 13 deletions report_async/models/ir_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@


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


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

@api.noguess
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:
def get_action(self, docids, report_name, data=None):
res = super(Report, self).get_action(docids, report_name, data=data)
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)
res["context"].get("active_ids", []), data, self.id, self._uid
)
return {}
return res
29 changes: 29 additions & 0 deletions report_async/models/queue_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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