-
-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[17.0] [MIG] report_py3o: Migration to 17.0 #931
Open
bug2point0
wants to merge
135
commits into
OCA:17.0
Choose a base branch
from
bug2point0:17.0
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 134 commits
Commits
Show all changes
135 commits
Select commit
Hold shift + click to select a range
f4260f1
Move to report_py3o after import from HG
lmignon 0862887
Add setup
lmignon 57e18fc
[FIX] View inheritance may not use attribute 'string' as a selector.
lmignon 734273b
[IMP] New API + Short Hearder
lmignon 01c59fc
Remove unicode string
lmignon 9a5a98f
[IMP] Add the possiblity to get the template from an absolute path on…
lmignon fba6962
[IMP] Allow user to use local fusion
lmignon 87700da
Add a simple way to extend the parser context
lmignon 5b66c5c
Remove ACL on removed model
lmignon baaae02
Improve filetype selection name
lmignon 77fcdcb
Fix native flag
lmignon 4e0e0ea
fixed missing comma in model definition
faide 917be4a
Add simple tests and fix call to fusion server
lmignon 0c4bd75
Fix skip fusion on server when the fusion is local
lmignon a680acc
Improve tests
lmignon 17a2df3
Replace openerp element by odoo
lmignon a56ac63
Small usability improvements
alexis-via c3f6d81
Take into accounts most remarks of @lasley
alexis-via 5312202
Replace plain SQL by orm
lmignon 7a2dfd0
rename module ir_report to ir_actions_report_xml
lmignon 80b488a
Add more tests and fixes issues found by tests
lmignon cd04798
[FIX] Check constrains only if report_type == 'py3o'
lmignon 68925bd
report_py3o: full installation procedure in README
alexis-via 30ec1b6
Port report_py3o to Odoo v10
alexis-via 908752a
Update version numbers
alexis-via 66d6df1
PEP8 fix
alexis-via 7e1bf72
Update README
alexis-via aad778d
FIX double dot in filename
alexis-via 72cf1fe
Add access to report_xml object in report
alexis-via 2e1720d
FIX Adapt test suite to my recent commit to avoid double dot on filen…
alexis-via b4458c5
[IMP] Escape 'False' when rendering value
lmignon 4338b9e
[IMP] Replace old style parser by TransientModel
lmignon b418674
[FIX] imports
b061a99
[IMP] Minimizes memory consumption
lmignon da5647f
* travis.yml
16e4ce0
Update and improve README instructions to setup py3o
alexis-via 25615f5
[IMP] Allow to override/extend the way we get the fallback template
lmignon 5d0dcf4
[FIX] report_py3o: fix exception when report must be saved as attache…
lmignon e539c23
OCA Transbot updated translations from Transifex
oca-transbot 254fba1
[FIX] delete PDF invoice attachment on invoice back to draft (native …
alexis-via 81dc82b
[IMP] report_py3o: update authors and contributors
lmignon 55affc8
OCA Transbot updated translations from Transifex
oca-transbot 38289df
[IMP] report_py3o: prevent injections when retrieving the template fr…
lmignon 34d939d
OCA Transbot updated translations from Transifex
oca-transbot b17fffb
report_py3o: bump version following last merge
sbidoul 5ac0006
Fix py3o freeze when using server fusion
guewen 5e464c7
Pass option for escaping False values to server
guewen 292c063
Add option py3o_multi_in_one for Py3o reports
alexis-via 78aa75e
OCA Transbot updated translations from Transifex
oca-transbot fd7868c
[FIX] report_py3o: must return the path to the report
lmignon 1a3d810
[IMP] report_py3o: Take into account print_report_name
lmignon 99b0065
OCA Transbot updated translations from Transifex
oca-transbot 7434fc0
[IMP] report_py3o: Allows to interpret \n and \t in texts, cleans htm…
omar7r d8da8f0
[FIX] Deletes an unnecessary function call
omar7r 4ae4f70
[FIX] report_py3o: Removes api.one
omar7r 954bff2
[FIX] report_py3o: Import new dependencies in try...except
omar7r db75c3e
[UPD] report_py3o: Bump version
omar7r 305c918
OCA Transbot updated translations from Transifex
oca-transbot 6b32e08
[RFR] split off the fusion server to its own module
hbrunn a953e6c
Improve README.rst for report_py3o* modules
alexis-via a8cf443
[ADD] migration script to install report_py3o_fusion_server on upgrades
hbrunn cc51476
OCA Transbot updated translations from Transifex
oca-transbot 3fdac4f
[FIX] fallback to libreoffice conversion when no server is configured
hbrunn 8161988
[FIX] report_py3o: Bump version number
pedrobaeza 74f1872
[FIX]report_py3o: Escape correctly html characters.
jesusVMayor 5b36fa7
[IMP] check for template data, not for the id
hbrunn b657b8a
[FIX] If this is not a py3o report, do nothing at all. In some cases …
SimoRubi fbdb4bb
report_py3o: mention formatLang in README
sbidoul f3887de
report_py3o_fusion_server: Add support for PDF Export options of libr…
alexis-via 26112c0
[UPD] Update report_py3o.pot
oca-travis 687c5ee
Translated using Weblate (Français)
kryskool 1fe23ae
[MIG] report_py3o, report_py3o_fusion_server: Migration to 12.0
lmignon c2ffe0a
[IMP] report_py2o: cleanup js
lmignon c77afb7
[12.0][MIG] improvement py3o_report_extender
0a99cb1
Update i18n
sbejaoui 94a9d12
[FIX] report_py3o: Use the right naming convention for the render method
lmignon f9489d3
[IMP] report_py3o: remove obsolete methods
lmignon 330b55d
[IMP] report_py3o: Document new methods available into the parser con…
lmignon 437657d
[FIX] report_py3o: Add missing method _merge_pdf.
lmignon 0397703
[IMP][FIX] py3o_report, py3o_report_fusion_server: Compute the availa…
lmignon 486448b
[FIX] report_py3o: Add missing 'user' and 'lang' into the parser context
lmignon d28633c
[IMP] py3o_report: Allow to specify the lang when calling o_format_lang
lmignon 01d34d5
[FIX] report_py3o: Access to ir.config_parameter with sudo
lmignon faf6715
[UPD] Update report_py3o.pot
oca-travis cf52453
Update translation files
oca-transbot e6564ef
[UPD] Update report_py3o.pot
oca-travis b5b8574
Update translation files
oca-transbot 5db09c2
Update README for report_py3o and report_py3o_fusion_server (#306)
alexis-via b3b6e73
[FIX] report_py3o readme structure
sbidoul 87dc3cd
[UPD] README.rst
OCA-git-bot 8569ac1
[IMP] report_py3o, report_py3o_fusion_server: black, isort
lmignon 6cc9d71
[MIG] report_py3o, report_py3o_fusion_server: Migration to 13.0
lmignon 6d76f68
Make sure value is always set for computed fields
dupski e6f6c35
[12.0][FIX] - report_py3o: run libreoffice in an isolated user instal…
sbejaoui cc6f2bc
[FIX] report_py3o: prettier xml after merge with master
lmignon 3457421
[FIX] make prettier happy
sbidoul ba99f0d
[UPD] Update report_py3o.pot
oca-travis 1d2106e
[UPD] README.rst
OCA-git-bot 20899f4
Update translation files
oca-transbot ef9143e
Update translation files
oca-transbot 41b164a
[14.0][MIG] report_py3o: Migration to 14.0
elmeriniemela 096546d
Update report_py3o/models/ir_actions_report.py
elmeriniemela 2e93195
[MIG] Use safe_eval wrapped time module. Fix deprecation warnings.
elmeriniemela 861fb47
[IMP] Add ability to include properly formatted datetime field in a r…
elmeriniemela a7fc3ad
[IMP] Workaround for genshi DeprecationWarning that makes runbot buil…
elmeriniemela 684ef84
[IMP] Cleanup unnecessary imports
elmeriniemela 51f443d
[IMP] Remove except of IOError as its an alias to OSError in python3
elmeriniemela e65c2c2
run pre-commit
leemannd 28b2307
[UPD] Update report_py3o.pot
oca-travis 76c7a1c
[UPD] README.rst
OCA-git-bot fd9c32a
[MIG] report_py3o: Migration to 15.0
phuctranfxvn ea59dff
[MIG] report_py3o to v16
alexis-via f1d91a5
[UPD] Update report_py3o.pot
d81e590
[UPD] README.rst
OCA-git-bot dc9af10
[UPD] README.rst
OCA-git-bot f7f0493
Update translation files
weblate 2bf7ffe
Translated using Weblate (Spanish)
Ivorra78 f5cd164
Translated using Weblate (Spanish (Argentina))
ibuioli 7fa23b6
Translated using Weblate (Italian)
mymage 26a392a
Update translation files
weblate 5b6c55d
Replaced `mktemp` with `mkstemp`
fazledyn-or d285efd
Reformatted using pre-commit
fazledyn-or 13925a5
[BOT] post-merge updates
OCA-git-bot 985c35d
Translated using Weblate (Italian)
mymage 63d5e95
[IMP] remove python libs included in odoo from requirements
CRogos c227e08
[BOT] post-merge updates
OCA-git-bot 66ea6c5
Translated using Weblate (Swedish)
jakobkrabbe fe6f946
[FIX] _py3o_parser_context: fix call to format_date in old_format_lang
jdoutreloux f010d85
[BOT] post-merge updates
OCA-git-bot 13056a0
[IMP] report_py3o: use the standard file name behavior when zipping r…
ThomasBinsfeld e11260e
[BOT] post-merge updates
OCA-git-bot 616b563
[IMP] report_py3o: pre-commit auto fixes
bug2point0 7608c90
[17.0] [MIG] report_py3o
bug2point0 4e182ad
[IMP] replace deprecated pkg_resources with importlib.resources
bug2point0 4a144a4
binary dependency enforcement
bug2point0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
================== | ||
Py3o Report Engine | ||
================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:6475c7e18340a01f1070b14e0c403646da2a1e1381b73969ba16b91c163d4db7 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
: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/16.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-16-0/reporting-engine-16-0-report_py3o | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
The py3o reporting engine is a reporting engine for Odoo based on `Libreoffice <http://www.libreoffice.org/>`_: | ||
|
||
* the report is created with Libreoffice (ODT or ODS), | ||
* the report is stored on the server in OpenDocument format (.odt or .ods file) | ||
* the report is sent to the user in OpenDocument format or in any output format supported by Libreoffice (PDF, HTML, DOC, DOCX, Docbook, XLS, etc.) | ||
|
||
The key advantages of a Libreoffice based reporting engine are: | ||
|
||
* no need to be a developer to create or modify a report: the report is created and modified with Libreoffice. So this reporting engine has a full WYSIWYG report development tool! | ||
* For a PDF report in A4/Letter format, it's easier to develop it with a tool such as Libreoffice that is designed to create A4/Letter documents than to develop it in HTML/CSS, also some print peculiarities (backgrounds, margin boxes) are not very well supported by the HTML/CSS based solutions. | ||
* If you want your users to be able to modify the document after its generation by Odoo, just configure the document with ODT output (or DOC or DOCX) and the user will be able to modify the document with Libreoffice (or Word) after its generation by Odoo. | ||
* Easy development of spreadsheet reports in ODS format (XLS output possible). | ||
|
||
This module *report_py3o* is the base module for the Py3o reporting engine. If used alone, it will spawn a libreoffice process for each ODT to PDF (or ODT to DOCX, ..) document conversion. This is slow and can become a problem if you have a lot of reports to convert from ODT to another format. In this case, you should consider the additionnal module *report_py3o_fusion_server* which is designed to work with a libreoffice daemon. With *report_py3o_fusion_server*, the technical environnement is more complex to setup because you have to install additionnal software components and run 2 daemons, but you have much better performances and you can configure the libreoffice PDF export options in Odoo (allows to generate PDF forms, PDF/A documents, password-protected PDFs, watermarked PDFs, etc.). | ||
|
||
This reporting engine is an alternative to `Aeroo <https://github.com/aeroo-community/aeroo_reports>`_: these two reporting engines have similar features but their implementation is entirely different. You cannot use aeroo templates as drop in replacement though, you'll have to change a few details. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Installation | ||
============ | ||
|
||
Install the required python libs: | ||
|
||
.. code:: | ||
|
||
pip install py3o.template | ||
pip install py3o.formats | ||
|
||
To allow the conversion of ODT or ODS reports to other formats (PDF, DOC, DOCX, etc.), install libreoffice: | ||
|
||
.. code:: | ||
|
||
apt-get --no-install-recommends install libreoffice | ||
|
||
Configuration | ||
============= | ||
|
||
For example, to replace the native invoice report by a custom py3o report, add the following XML file in your custom module: | ||
|
||
.. code:: | ||
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="account.account_invoices" model="ir.actions.report"> | ||
<field name="report_type">py3o</field> | ||
<field name="py3o_filetype">odt</field> | ||
<field name="module">my_custom_module_base</field> | ||
<field name="py3o_template_fallback">report/account_invoice.odt</field> | ||
</record> | ||
|
||
</odoo> | ||
|
||
where *my_custom_module_base* is the name of the custom Odoo module. In this example, the invoice ODT file is located in *my_custom_module_base/report/account_invoice.odt*. | ||
|
||
It's also possible to reference a template located in a trusted path of your | ||
Odoo server. In this case you must let the *module* entry empty and specify | ||
the path to the template as *py3o_template_fallback*. | ||
|
||
.. code:: | ||
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="account.account_invoices" model="ir.actions.report"> | ||
<field name="report_type">py3o</field> | ||
<field name="py3o_filetype">odt</field> | ||
<field name="py3o_template_fallback">/odoo/templates/py3o/report/account_invoice.odt</field> | ||
</record> | ||
|
||
</odoo> | ||
|
||
Moreover, you must also modify the Odoo server configuration file to declare | ||
the allowed root directory for your py3o templates. Only templates located | ||
into this directory can be loaded by py3o report. | ||
|
||
.. code:: | ||
|
||
[options] | ||
... | ||
|
||
[report_py3o] | ||
root_tmpl_path=/odoo/templates/py3o | ||
|
||
If you want an invoice in PDF format instead of ODT format, the XML file should look like: | ||
|
||
.. code:: | ||
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="account.account_invoices" model="ir.actions.report"> | ||
<field name="report_type">py3o</field> | ||
<field name="py3o_filetype">pdf</field> | ||
<field name="module">my_custom_module_base</field> | ||
<field name="py3o_template_fallback">report/account_invoice.odt</field> | ||
</record> | ||
|
||
</odoo> | ||
|
||
If you want to add a new py3o PDF report (and not replace a native report), the XML file should look like this: | ||
|
||
.. code:: | ||
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="partner_summary_report" model="ir.actions.report"> | ||
<field name="name">Partner Summary</field> | ||
<field name="model">res.partner</field> | ||
<field name="report_name">res.partner.summary</field> | ||
<field name="report_type">py3o</field> | ||
<field name="py3o_filetype">pdf</field> | ||
<field name="module">my_custom_module_base</field> | ||
<field name="py3o_template_fallback">report/partner_summary.odt</field> | ||
<!-- Add entry in "Print" drop-down list --> | ||
<field name="binding_type">report</field> | ||
<field name="binding_model_id" ref="base.model_res_partner"/> | ||
</record> | ||
|
||
</odoo> | ||
|
||
Configuration parameters | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
py3o.conversion_command | ||
The command to be used to run the conversion, ``libreoffice`` by default. If you change this, whatever you set here must accept the parameters ``--headless --convert-to $ext $file`` and put the resulting file into ``$file``'s directory with extension ``$ext``. The command will be started in ``$file``'s directory. | ||
|
||
Usage | ||
===== | ||
|
||
The templating language is `extensively documented <http://py3otemplate.readthedocs.io/en/latest/templating.html>`_, the records are exposed in libreoffice as ``objects``, on which you can also call functions. | ||
|
||
Available functions and objects | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
user | ||
Browse record of current user | ||
lang | ||
The user's company's language as string (ISO code) | ||
b64decode | ||
``base64.b64decode`` | ||
format_multiline_value(string) | ||
Generate the ODF equivalent of ``<br/>`` and `` `` for multiline fields (ODF is XML internally, so those would be skipped otherwise) | ||
html_sanitize(string) | ||
Sanitize HTML string | ||
time | ||
Python's ``time`` module | ||
display_address(partner) | ||
Return a formatted string of the partner's address | ||
o_format_lang(value, lang_code=False, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True) | ||
Return a formatted numeric or monetary value according to the context language and timezone | ||
o_format_date(value, lang_code=False, date_format=False) | ||
Return a formatted date or time value according to the context language and timezone | ||
|
||
|
||
Sample report templates | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Sample py3o report templates for the main Odoo native reports (invoice, sale order, purchase order, picking, etc.) are available on the Github project `odoo-py3o-report-templates <https://github.com/akretion/odoo-py3o-report-templates>`_. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* generate barcode ? | ||
* add more detailed example in demo file to showcase features | ||
* add migration guide aeroo -> py3o | ||
|
||
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 to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_py3o%0Aversion:%2016.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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* XCG Consulting | ||
* ACSONE SA/NV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Florent Aide (`XCG Consulting <http://odoo.consulting/>`_) | ||
* Laurent Mignon <laurent.mignon@acsone.eu>, | ||
* Alexis de Lattre <alexis.delattre@akretion.com>, | ||
* Guewen Baconnier <guewen.baconnier@camptocamp.com> | ||
* Omar Casti??eira <omar@comunitea.com> | ||
* Holger Brunn <hbrunn@therp.nl> | ||
* Phuc Tran Thanh <phuc@trobz.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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/16.0/report_py3o>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2013 XCG Consulting (http://odoo.consulting) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Py3o Report Engine", | ||
"summary": "Reporting engine based on Libreoffice (ODT -> ODT, " | ||
"ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)", | ||
"version": "17.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"], | ||
"deb": ["libreoffice"], | ||
}, | ||
"assets": { | ||
"web.assets_backend": [ | ||
"report_py3o/static/src/js/py3oactionservice.esm.js", | ||
], | ||
}, | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/py3o_template.xml", | ||
"views/ir_actions_report.xml", | ||
"demo/report_py3o.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
import json | ||
import mimetypes | ||
|
||
from werkzeug import exceptions | ||
from werkzeug.urls import url_decode | ||
|
||
from odoo.http import content_disposition, request, route, serialize_exception | ||
from odoo.tools import html_escape | ||
|
||
from odoo.addons.web.controllers.report import ReportController | ||
|
||
|
||
class ReportController(ReportController): | ||
@route() | ||
def report_routes(self, reportname, docids=None, converter=None, **data): | ||
if converter != "py3o": | ||
return super().report_routes( | ||
reportname=reportname, docids=docids, converter=converter, **data | ||
) | ||
context = dict(request.env.context) | ||
|
||
if docids: | ||
docids = [int(i) for i in docids.split(",")] | ||
if data.get("options"): | ||
data.update(json.loads(data.pop("options"))) | ||
if data.get("context"): | ||
# Ignore 'lang' here, because the context in data is the | ||
# one from the webclient *but* if the user explicitely wants to | ||
# change the lang, this mechanism overwrites it. | ||
data["context"] = json.loads(data["context"]) | ||
if data["context"].get("lang"): | ||
del data["context"]["lang"] | ||
context.update(data["context"]) | ||
|
||
ir_action = request.env["ir.actions.report"] | ||
action_py3o_report = ir_action.get_from_report_name( | ||
reportname, "py3o" | ||
).with_context(**context) | ||
if not action_py3o_report: | ||
raise exceptions.HTTPException( | ||
description="Py3o action report not found for report_name " | ||
"%s" % reportname | ||
) | ||
res, filetype = ir_action._render(reportname, docids, data) | ||
filename = action_py3o_report.gen_report_download_filename(docids, data) | ||
if not filename.endswith(filetype): | ||
filename = f"{filename}.{filetype}" | ||
content_type = mimetypes.guess_type("x." + filetype)[0] | ||
http_headers = [ | ||
("Content-Type", content_type), | ||
("Content-Length", len(res)), | ||
("Content-Disposition", content_disposition(filename)), | ||
] | ||
return request.make_response(res, headers=http_headers) | ||
|
||
@route() | ||
def report_download(self, data, context=None, token=None): | ||
"""This function is used by 'qwebactionmanager.js' in order to trigger | ||
the download of a py3o/controller report. | ||
|
||
:param data: a javascript array JSON.stringified containg report | ||
internal url ([0]) and type [1] | ||
:returns: Response with a filetoken cookie and an attachment header | ||
""" | ||
requestcontent = json.loads(data) | ||
url, report_type = requestcontent[0], requestcontent[1] | ||
if "py3o" not in report_type: | ||
return super().report_download(data, context=context, token=token) | ||
try: | ||
reportname = url.split("/report/py3o/")[1].split("?")[0] | ||
docids = None | ||
if "/" in reportname: | ||
reportname, docids = reportname.split("/") | ||
|
||
if docids: | ||
# Generic report: | ||
response = self.report_routes( | ||
reportname, docids=docids, converter="py3o" | ||
) | ||
else: | ||
# Particular report: | ||
# decoding the args represented in JSON | ||
data = list(url_decode(url.split("?")[1]).items()) | ||
response = self.report_routes( | ||
reportname, converter="py3o", **dict(data) | ||
) | ||
response.set_cookie("fileToken", context) | ||
return response | ||
except Exception as e: | ||
se = serialize_exception(e) | ||
error = {"code": 200, "message": "Odoo Server Error", "data": se} | ||
return request.make_response(html_escape(json.dumps(error))) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2016 ACSONE SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record id="res_users_report_py3o" model="ir.actions.report"> | ||
<field name="name">Py3o Demo Report</field> | ||
<field name="type">ir.actions.report</field> | ||
<field name="model">res.users</field> | ||
<field name="report_name">py3o_user_info</field> | ||
<field name="report_type">py3o</field> | ||
<field name="py3o_filetype">odt</field> | ||
<field name="module">report_py3o</field> | ||
<field name="py3o_template_fallback">demo/res_user.odt</field> | ||
<field | ||
name="print_report_name" | ||
>object.name.replace(' ', '_') + '-demo.odt'</field> | ||
<field name="binding_model_id" ref="base.model_res_users" /> | ||
<field name="binding_type">report</field> | ||
</record> | ||
</odoo> |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More info: https://github.com/odoo/odoo/blob/d759264c6e9b7a8cc8b6cffdc5509df654cd434c/odoo/modules/module.py#L508
I think this should be changed on all versions... and other modules...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odoo docs are pretty clear on this. Nice catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm... looks like OCA "unofficial" way (i don't know where is documented) to handle dependencies in CI env: https://github.com/OCA/oca-ci/blob/c10c90835d3baf6576faaae03f593099b9995009/bin/oca_install_addons#L16
Perhaps a solution could be to use
bin
to have the Odoo check anddeb
to indicate how to install the package with the 'apt package manager'?ping @sbidoul
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add
bin
if you want, but please keepdeb
so libreoffice is installed in ci and runboat.That said, I'm not sure libreoffice is a hard dependency. IIRC it's optional when using
report_py3o_fusion_server
, so in that case we should not addbin
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bug2point0 I think there should be both “bin” and “deb”.
As I see it, actually it all depends on which module you give more importance to 'report_py3o_fusion_server' vs 'report_py3o'... Everything else is a mess of dependencies (if you choose X with Y but you have Z then disable W... :/). At least from what I could see.
You decide, if you choose only “deb” it seems right to me... and if you choose “bin” and “deb” the same. Little more I can say.