Skip to content

Commit 6fbddc9

Browse files
committed
[MIG] report_async: Migration to 18.0
1 parent 07a0767 commit 6fbddc9

10 files changed

Lines changed: 56 additions & 40 deletions

File tree

report_async/README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Report Async
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
20-
:target: https://github.com/OCA/reporting-engine/tree/17.0/report_async
20+
:target: https://github.com/OCA/reporting-engine/tree/18.0/report_async
2121
:alt: OCA/reporting-engine
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-report_async
23+
:target: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_async
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -88,7 +88,7 @@ Bug Tracker
8888
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
8989
In case of trouble, please check there if your issue has already been reported.
9090
If you spotted it first, help us to smash it by providing a detailed and welcomed
91-
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_async%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
91+
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_async%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
9292

9393
Do not contact contributors directly about support or help with technical issues.
9494

@@ -114,6 +114,10 @@ Contributors
114114
- Daniel Reis <dreis@opensourceintegrators.com>
115115
- Nikul Chaudhary <nchaudhary@opensourceintegrators.com>
116116

117+
- `Trobz <https://trobz.com>`__:
118+
119+
- Do Anh Duy <duyda@trobz.com>
120+
117121
Maintainers
118122
-----------
119123

@@ -135,6 +139,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
135139

136140
|maintainer-kittiu|
137141

138-
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/17.0/report_async>`_ project on GitHub.
142+
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/18.0/report_async>`_ project on GitHub.
139143

140144
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

report_async/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Report Async",
55
"summary": "Central place to run reports live or async",
6-
"version": "17.0.1.0.0",
6+
"version": "18.0.1.0.0",
77
"author": "Ecosoft, Odoo Community Association (OCA)",
88
"license": "AGPL-3",
99
"website": "https://github.com/OCA/reporting-engine",

report_async/models/ir_actions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ class IrActionsActWindow(models.Model):
88
_inherit = "ir.actions.act_window"
99

1010
@api.model
11-
def name_search(self, name, args=None, operator="ilike", limit=100):
12-
if self._context.get("access_sudo", False):
11+
def name_search(self, name="", args=None, operator="ilike", limit=100):
12+
if self.env.context.get("access_sudo"):
1313
self = self.with_user(SUPERUSER_ID)
14-
return super().name_search(name, args, operator, limit)
14+
return super().name_search(name=name, args=args, operator=operator, limit=limit)
1515

1616
@api.model
17-
def search(self, args, offset=0, limit=None, order=None):
18-
if self._context.get("access_sudo", False):
17+
def _search(self, domain, offset=0, limit=None, order=None):
18+
if self.env.context.get("access_sudo"):
1919
self = self.with_user(SUPERUSER_ID)
20-
return super().search(args, offset, limit, order)
20+
return super()._search(domain=domain, offset=offset, limit=limit, order=order)
2121

2222
def fetch(self, field_names):
2323
"""Add permission to read analytic account for do something."""
24-
if self._context.get("access_sudo", False):
24+
if self.env.context.get("access_sudo"):
2525
self = self.with_user(SUPERUSER_ID)
26-
return super().fetch(field_names)
26+
return super().fetch(field_names=field_names)

report_async/models/ir_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Report(models.Model):
1111
_inherit = "ir.actions.report"
1212

1313
def report_action(self, docids, data=None, config=True):
14-
res = super().report_action(docids, data=data, config=config)
15-
if res["context"].get("async_process", False):
14+
res = super().report_action(docids=docids, data=data, config=config)
15+
if res["context"].get("async_process"):
1616
rpt_async_id = res["context"]["active_id"]
1717
report_async = self.env["report.async"].browse(rpt_async_id)
1818
if res["report_type"] in REPORT_TYPES:

report_async/models/report_async.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
import base64
55

6-
from odoo import SUPERUSER_ID, _, api, fields, models
6+
from odoo import SUPERUSER_ID, api, fields, models
77
from odoo.exceptions import UserError
8+
from odoo.tools import SQL
89
from odoo.tools.safe_eval import safe_eval
910

1011
# Define all supported report_type
@@ -13,7 +14,7 @@
1314
"qweb-text": "_render_qweb_text",
1415
"qweb-xml": "_render_qweb_xml",
1516
"csv": "_render_csv",
16-
"excel": "render_excel",
17+
"excel": "_render_excel",
1718
"xlsx": "_render_xlsx",
1819
}
1920

@@ -79,7 +80,7 @@ def _compute_job(self):
7980
.env["queue.job"]
8081
.search(
8182
[
82-
("func_string", "like", "report.async(%s,)" % rec.id),
83+
("func_string", "like", f"report.async({rec.id},)"),
8384
("user_id", "=", self._uid),
8485
],
8586
order="id desc",
@@ -111,7 +112,7 @@ def run_now(self):
111112
def run_async(self):
112113
self.ensure_one()
113114
if not self.allow_async:
114-
raise UserError(_("Background process not allowed."))
115+
raise UserError(self.env._("Background process not allowed."))
115116
result = self.env[self.action_id.type]._for_xml_id(self.action_id.xml_id)
116117
ctx = safe_eval(result.get("context", {}))
117118
ctx.update({"async_process": True})
@@ -157,11 +158,16 @@ def run_report(self, docids, data, report_id, user_id):
157158
}
158159
)
159160
)
160-
self._cr.execute(
161-
"""
162-
UPDATE ir_attachment SET create_uid = %s, write_uid = %s
163-
WHERE id = %s""",
164-
(self._uid, self._uid, attachment.id),
161+
self.env.execute_query(
162+
SQL(
163+
"""
164+
UPDATE ir_attachment
165+
SET create_uid = %(create_uid)s, write_uid = %(write_uid)s
166+
WHERE id = %(attachment_id)s""",
167+
create_uid=self._uid,
168+
write_uid=self._uid,
169+
attachment_id=attachment.id,
170+
)
165171
)
166172
# Send email
167173
if self.email_notify:

report_async/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
- Opensourceintegrators
66
- Daniel Reis \<<dreis@opensourceintegrators.com>\>
77
- Nikul Chaudhary \<<nchaudhary@opensourceintegrators.com>\>
8+
- [Trobz](https://trobz.com):
9+
- Do Anh Duy \<<duyda@trobz.com>\>

report_async/security/ir_rule.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<field name="perm_unlink" eval="False" />
1111
<field
1212
name="domain_force"
13-
>['|', ('group_ids', '=', False), ('group_ids', 'in', [g.id for g in user.groups_id])]</field>
13+
>[('group_ids', 'in', user.groups_id.ids + [False])]</field>
1414
</record>
1515
<record id="rule_report_async_access_all" model="ir.rule">
1616
<field name="name">Report Async by Groups</field>

report_async/static/description/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Report Async</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:b78bb80d7af0d825eb97d22bd12d497480c0bb50406d307649f54ce152fc216d
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/17.0/report_async"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-report_async"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/report_async"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_async"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>The new menu “Report Center” is the central place to host your reports
374374
in one place. From here, there are 2 ways to launch the report,</p>
375375
<ol class="arabic simple">
@@ -435,7 +435,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
435435
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
436436
In case of trouble, please check there if your issue has already been reported.
437437
If you spotted it first, help us to smash it by providing a detailed and welcomed
438-
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_async%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
438+
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_async%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
439439
<p>Do not contact contributors directly about support or help with technical issues.</p>
440440
</div>
441441
<div class="section" id="credits">
@@ -460,6 +460,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
460460
<li>Nikul Chaudhary &lt;<a class="reference external" href="mailto:nchaudhary&#64;opensourceintegrators.com">nchaudhary&#64;opensourceintegrators.com</a>&gt;</li>
461461
</ul>
462462
</li>
463+
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
464+
<li>Do Anh Duy &lt;<a class="reference external" href="mailto:duyda&#64;trobz.com">duyda&#64;trobz.com</a>&gt;</li>
465+
</ul>
466+
</li>
463467
</ul>
464468
</div>
465469
<div class="section" id="maintainers">
@@ -473,7 +477,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
473477
promote its widespread use.</p>
474478
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
475479
<p><a class="reference external image-reference" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a></p>
476-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/17.0/report_async">OCA/reporting-engine</a> project on GitHub.</p>
480+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/18.0/report_async">OCA/reporting-engine</a> project on GitHub.</p>
477481
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
478482
</div>
479483
</div>

report_async/tests/test_report_async.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
33
from odoo.exceptions import UserError
4-
from odoo.tests import common
5-
from odoo.tests.common import Form
4+
from odoo.tests import Form, common
65

76

87
class TestJobChannel(common.TransactionCase):
9-
def setUp(self):
10-
super().setUp()
11-
self.print_doc = self.env.ref("report_async.report_async_print_document")
12-
self.test_rec = self.env.ref("base.module_mail")
13-
self.test_rpt = self.env.ref("base.ir_module_reference_print")
8+
@classmethod
9+
def setUpClass(cls):
10+
super().setUpClass()
11+
cls.print_doc = cls.env.ref("report_async.report_async_print_document")
12+
cls.test_rec = cls.env.ref("base.module_mail")
13+
cls.test_rpt = cls.env.ref("base.ir_module_reference_print")
1414

1515
def _print_wizard(self, res):
1616
obj = self.env[res["res_model"]]

report_async/views/report_async.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
33
<record id="view_report_async_tree" model="ir.ui.view">
4-
<field name="name">report.async.tree</field>
4+
<field name="name">report.async.list</field>
55
<field name="model">report.async</field>
66
<field name="arch" type="xml">
7-
<tree>
7+
<list>
88
<field name="action_id" context="{'access_sudo': True}" />
99
<button type="object" name="run_now" string="Run Now" icon="fa-bolt" />
1010
<button
@@ -24,7 +24,7 @@
2424
<field name="allow_async" column_invisible="1" />
2525
<field name="job_status" optional="hide" />
2626
<field name="email_notify" />
27-
</tree>
27+
</list>
2828
</field>
2929
</record>
3030
<record id="view_report_async_form" model="ir.ui.view">
@@ -153,7 +153,7 @@
153153
<field name="res_model">ir.attachment</field>
154154
<field name="view_id" eval="False" />
155155
<field name="search_view_id" ref="base.view_attachment_search" />
156-
<field name="view_mode">kanban,tree,form</field>
156+
<field name="view_mode">kanban,list,form</field>
157157
<field
158158
name="domain"
159159
>[('res_model', '=', 'report.async'), ('create_uid', '=', uid)]</field>

0 commit comments

Comments
 (0)