Skip to content

Commit

Permalink
[MIG] report_py3o: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
phuctranfxvn authored and Tardo committed Mar 24, 2023
1 parent 19335d8 commit 1155598
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 75 deletions.
11 changes: 6 additions & 5 deletions report_py3o/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Py3o Report Engine
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/14.0/report_py3o
:target: https://github.com/OCA/reporting-engine/tree/15.0/report_py3o
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-report_py3o
:target: https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-report_py3o
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/143/14.0
:target: https://runbot.odoo-community.org/runbot/143/15.0
:alt: Try me on Runbot

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

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

Expand All @@ -225,6 +225,7 @@ Contributors
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Omar Castiñeira <omar@comunitea.com>
* Holger Brunn <hbrunn@therp.nl>
* Phuc Tran Thanh <phuc@trobz.com>

Maintainers
~~~~~~~~~~~
Expand All @@ -239,6 +240,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/14.0/report_py3o>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/15.0/report_py3o>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
13 changes: 10 additions & 3 deletions report_py3o/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@
"name": "Py3o Report Engine",
"summary": "Reporting engine based on Libreoffice (ODT -> ODT, "
"ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"category": "Reporting",
"license": "AGPL-3",
"author": "XCG Consulting," "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["web"],
"external_dependencies": {"python": ["py3o.template", "py3o.formats", "PyPDF2"]},
"external_dependencies": {
"python": ["py3o.template", "py3o.formats", "PyPDF2"],
"deb": ["libreoffice"],
},
"assets": {
"web.assets_backend": [
"report_py3o/static/src/js/py3oactionservice.esm.js",
],
},
"data": [
"security/ir.model.access.csv",
"views/menu.xml",
"views/py3o_template.xml",
"views/ir_actions_report.xml",
"views/report_py3o.xml",
"demo/report_py3o.xml",
],
"installable": True,
Expand Down
8 changes: 4 additions & 4 deletions report_py3o/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def report_routes(self, reportname, docids=None, converter=None, **data):
ir_action = request.env["ir.actions.report"]
action_py3o_report = ir_action.get_from_report_name(
reportname, "py3o"
).with_context(context)
).with_context(**context)
if not action_py3o_report:
raise exceptions.HTTPException(
description="Py3o action report not found for report_name "
Expand All @@ -57,7 +57,7 @@ def report_routes(self, reportname, docids=None, converter=None, **data):
return request.make_response(res, headers=http_headers)

@route()
def report_download(self, data, token):
def report_download(self, data, context=None):
"""This function is used by 'qwebactionmanager.js' in order to trigger
the download of a py3o/controller report.
Expand All @@ -68,7 +68,7 @@ def report_download(self, data, token):
requestcontent = json.loads(data)
url, report_type = requestcontent[0], requestcontent[1]
if "py3o" not in report_type:
return super(ReportController, self).report_download(data, token)
return super(ReportController, self).report_download(data, context)
try:
reportname = url.split("/report/py3o/")[1].split("?")[0]
docids = None
Expand All @@ -87,7 +87,7 @@ def report_download(self, data, token):
response = self.report_routes(
reportname, converter="py3o", **dict(data)
)
response.set_cookie("fileToken", token)
response.set_cookie("fileToken", context)
return response
except Exception as e:
se = _serialize_exception(e)
Expand Down
4 changes: 1 addition & 3 deletions report_py3o/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def _get_py3o_filetypes(self):
)
is_py3o_native_format = fields.Boolean(compute="_compute_is_py3o_native_format")
py3o_template_id = fields.Many2one("py3o.template", "Template")
module = fields.Char(
"Module", help="The implementer module that provides this report"
)
module = fields.Char(help="The implementer module that provides this report")
py3o_template_fallback = fields.Char(
"Fallback",
size=128,
Expand Down
2 changes: 2 additions & 0 deletions report_py3o/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Omar Castiñeira <omar@comunitea.com>
* Holger Brunn <hbrunn@therp.nl>
* Phuc Tran Thanh <phuc@trobz.com>
* Alexandre D. Díaz (`Grupo Isonor <alexandrediaz@grupoisonor.es>`_)
9 changes: 5 additions & 4 deletions report_py3o/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Py3o Report Engine</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Py3o Report Engine</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/reporting-engine/tree/14.0/report_py3o"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-report_py3o"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" 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" href="https://github.com/OCA/reporting-engine/tree/15.0/report_py3o"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-report_py3o"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>The py3o reporting engine is a reporting engine for Odoo based on <a class="reference external" href="http://www.libreoffice.org/">Libreoffice</a>:</p>
<ul class="simple">
<li>the report is created with Libreoffice (ODT or ODS),</li>
Expand Down Expand Up @@ -546,7 +546,7 @@ <h1><a class="toc-backref" href="#id8">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_py3o%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_py3o%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -567,6 +567,7 @@ <h2><a class="toc-backref" href="#id11">Contributors</a></h2>
<li>Guewen Baconnier &lt;<a class="reference external" href="mailto:guewen.baconnier&#64;camptocamp.com">guewen.baconnier&#64;camptocamp.com</a>&gt;</li>
<li>Omar Castiñeira &lt;<a class="reference external" href="mailto:omar&#64;comunitea.com">omar&#64;comunitea.com</a>&gt;</li>
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
<li>Phuc Tran Thanh &lt;<a class="reference external" href="mailto:phuc&#64;trobz.com">phuc&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -576,7 +577,7 @@ <h2><a class="toc-backref" href="#id12">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/14.0/report_py3o">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/15.0/report_py3o">OCA/reporting-engine</a> project on GitHub.</p>
<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>
</div>
</div>
Expand Down
42 changes: 0 additions & 42 deletions report_py3o/static/src/js/py3oactionmanager.js

This file was deleted.

54 changes: 54 additions & 0 deletions report_py3o/static/src/js/py3oactionservice.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/** @odoo-module **/

import {download} from "@web/core/network/download";
import {registry} from "@web/core/registry";

registry
.category("ir.actions.report handlers")
.add("py3o_handler", async function (action, options, env) {
if (action.report_type === "py3o") {
let url = `/report/py3o/${action.report_name}`;
const actionContext = action.context || {};
if (
_.isUndefined(action.data) ||
_.isNull(action.data) ||
(_.isObject(action.data) && _.isEmpty(action.data))
) {
// Build a query string with `action.data` (it's the place where reports
// using a wizard to customize the output traditionally put their options)
if (actionContext.active_ids) {
var activeIDsPath = "/" + actionContext.active_ids.join(",");
url += activeIDsPath;
}
} else {
var serializedOptionsPath =
"?options=" + encodeURIComponent(JSON.stringify(action.data));
serializedOptionsPath +=
"&context=" + encodeURIComponent(JSON.stringify(actionContext));
url += serializedOptionsPath;
}
env.services.ui.block();
try {
await download({
url: "/report/download",
data: {
data: JSON.stringify([url, action.report_type]),
context: JSON.stringify(env.services.user.context),
},
});
} finally {
env.services.ui.unblock();
}
const onClose = options.onClose;
if (action.close_on_report_download) {
return env.services.action.doAction(
{type: "ir.actions.act_window_close"},
{onClose}
);
} else if (onClose) {
onClose();
}
return Promise.resolve(true);
}
return Promise.resolve(false);
});
2 changes: 1 addition & 1 deletion report_py3o/tests/test_report_py3o.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_report_template_configs(self):
with temporary_copy(flbk_filename) as tmp_filename:
self.report.py3o_template_fallback = tmp_filename
tools.config.misc["report_py3o"] = {
"root_tmpl_path": os.path.dirname(tmp_filename)
"root_tmpl_path": os.path.realpath(os.path.dirname(tmp_filename))
}
res = self.report._render(self.env.user.ids)
self.assertTrue(res)
Expand Down
4 changes: 2 additions & 2 deletions report_py3o/views/py3o_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<field name="name">py3o.template.configuration.tree.view</field>
<field name="model">py3o.template</field>
<field name="arch" type="xml">
<tree string="Py3o Templates">
<tree>
<field name="name" />
<field name="filetype" />
</tree>
Expand All @@ -47,7 +47,7 @@
</record>
<menuitem
id="py3o_template_configuration_menu"
parent="py3o_config_menu"
parent="base.reporting_menuitem"
action="py3o_template_configuration_action"
/>
</odoo>
11 changes: 0 additions & 11 deletions report_py3o/views/report_py3o.xml

This file was deleted.

0 comments on commit 1155598

Please sign in to comment.