Skip to content

[MIG][11.0] report_py3o backport of v12 - #285

Closed
tbaden wants to merge 95 commits into
OCA:11.0from
tbaden:11.0-mig-report-py3o
Closed

tbaden wants to merge 95 commits into
OCA:11.0from
tbaden:11.0-mig-report-py3o

Conversation

@tbaden

@tbaden tbaden commented May 1, 2019

Copy link
Copy Markdown
Member

No description provided.

lmignon and others added 30 commits May 1, 2019 04:16
Replace README.md by README.rst (not finished)
Remove <data> in views
Protect import of py3o libs
Remove dep on base module
Other small changes
Rename __openerp__.py to __manifest__.py
lmignon and others added 7 commits May 1, 2019 04:16
lang_code is already supported by o_format_date
Co-Authored-By: lmignon <laurent.mignon@acsone.eu>
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: reporting-engine-12.0/reporting-engine-12.0-report_py3o
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-12-0/reporting-engine-12-0-report_py3o/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: reporting-engine-12.0/reporting-engine-12.0-report_py3o_fusion_server
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-12-0/reporting-engine-12-0-report_py3o_fusion_server/
@tbaden tbaden changed the title [MIG][11.0] report_py3o backport of v12 [MIG][11.0][WIP] report_py3o backport of v12 May 1, 2019
@pedrobaeza pedrobaeza added this to the 11.0 milestone May 1, 2019
@lmignon

lmignon commented May 2, 2019

Copy link
Copy Markdown
Contributor

@tbaden Thank you for taking care of this backport. Can I ask you to preserve the commit history and authorship of changes when backporting the addons from Odoo 12.
Here it's a technical method to backport the addons from 12.0...

  • On a shell command:
$ git clone https://github.com/OCA/reporting-engine -b 11.0
$ git checkout -b 11.0-mig-reporting-engine origin/11.0
$ git format-patch --keep-subject --stdout origin/11.0..origin/12.0 -- report_py3o report_py3o_fusion_server | git am -3 --keep
  • Adapt the module to the 11.0 version.
  • On a shell command:
$ git add --all
$ git commit -m "[MIG] $MODULE: Migration to 11.0"
$ git remote add $USER_ORG git@github.com:$USER_ORG/$REPO.git # This mode requires an SSH key in the GitHub account
$ ... or ....
$ git remote add $USER_ORG https://github.com/$USER_ORG/$REPO.git # This will required to enter user/password each time
$ git push $USER_ORG 11.0-mig-$MODULE --set-upstream

(same method as for normal migration process but adapted to takes the 12.0 branch as source. This method also takes care to migrate report_py3o and report_py3o_fusion_server at same time. https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-12.0#technical-method-to-migrate-a-module-from-110-to-120-branch)

@tbaden

tbaden commented May 2, 2019

Copy link
Copy Markdown
Member Author

@lmignon I'll take care of this.

@lmignon

lmignon commented May 2, 2019

Copy link
Copy Markdown
Contributor

@lmignon I'll take care of this.

Thank you to you for this work 😏

@tbaden

tbaden commented May 2, 2019

Copy link
Copy Markdown
Member Author

@lmignon maybe you can give me a hint. I got all tests on green now except for test_reports_merge_zip.

getting the error:
:1: in <Expression '__py3o_frame(b64decode(objects.image), 'png', width='2cm', height='2cm', origin_attrib={'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}anchor-type': 'paragraph', '{urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0}width': '0.7902in', '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}name': "py3o.image(b64decode(objects.image), 'png', width='2cm', height='2cm')", '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}style-name': 'fr1', '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}z-index': '0'})'>
???
/usr/lib/python3.5/base64.py:81: in b64decode
s = _bytes_from_decode_data(s)


TypeError: argument should be a bytes-like object or ASCII string, not 'bool'

If you need it, I can push my current code to github.

@oca-clabot

Copy link
Copy Markdown

Hey @tbaden, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/cla
Here is a list of the users:

Appreciation of efforts,
OCA CLAbot

Comment thread report_xlsx/static/src/js/report/qwebactionmanager.js Outdated
Comment thread report_py3o_fusion_server/readme/CONTRIBUTORS.rst Outdated
Comment thread report_py3o/readme/CONTRIBUTORS.rst Outdated
Comment thread report_py3o/models/ir_actions_report.py
Comment thread report_py3o/static/src/js/py3oactionmanager.js Outdated
Comment thread report_py3o/static/src/js/py3oactionmanager.js Outdated
Comment thread report_py3o/static/src/js/py3oactionmanager.js Outdated
@lmignon

lmignon commented May 3, 2019

Copy link
Copy Markdown
Contributor

@lmignon maybe you can give me a hint. I got all tests on green now except for test_reports_merge_zip.

getting the error:
:1: in <Expression '__py3o_frame(b64decode(objects.image), 'png', width='2cm', height='2cm', origin_attrib={'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}anchor-type': 'paragraph', '{urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0}width': '0.7902in', '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}name': "py3o.image(b64decode(objects.image), 'png', width='2cm', height='2cm')", '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}style-name': 'fr1', '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}z-index': '0'})'>
???
/usr/lib/python3.5/base64.py:81: in b64decode
s = _bytes_from_decode_data(s)

TypeError: argument should be a bytes-like object or ASCII string, not 'bool'

If you need it, I can push my current code to github.

objects.image is False... That means that field image is False on the object used into the report...
In fact into the demo template, we don't check if the image field is set before the call to b64decode... We should fix the template to avoid this kind of error.

@tbaden tbaden left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I checked the object neither of the entries had images and only the last one failed. I'll check again.

@tbaden

tbaden commented May 3, 2019

Copy link
Copy Markdown
Member Author

@lmignon @pedrobaeza
how should I handle this test?

    def test_py3o_report_availability(self):
        # This test could fails if libreoffice is not available on the server

locally it pass, because of libreoffice installation, but travis will fail.

@tbaden

tbaden commented May 3, 2019

Copy link
Copy Markdown
Member Author

@lmignon maybe you can give me a hint. I got all tests on green now except for test_reports_merge_zip.
getting the error:
:1: in <Expression '__py3o_frame(b64decode(objects.image), 'png', width='2cm', height='2cm', origin_attrib={'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}anchor-type': 'paragraph', '{urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0}width': '0.7902in', '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}name': "py3o.image(b64decode(objects.image), 'png', width='2cm', height='2cm')", '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}style-name': 'fr1', '{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}z-index': '0'})'>
???
/usr/lib/python3.5/base64.py:81: in b64decode
s = _bytes_from_decode_data(s)
TypeError: argument should be a bytes-like object or ASCII string, not 'bool'
If you need it, I can push my current code to github.

objects.image is False... That means that field image is False on the object used into the report...
In fact into the demo template, we don't check if the image field is set before the call to b64decode... We should fix the template to avoid this kind of error.

seems like I dived to deep... found it and catching this issue in the context parser.

on local all tests are green

@lmignon

lmignon commented May 3, 2019

Copy link
Copy Markdown
Contributor

@lmignon @pedrobaeza
how should I handle this test?

    def test_py3o_report_availability(self):
        # This test could fails if libreoffice is not available on the server

locally it pass, because of libreoffice installation, but travis will fail.

@tbaden add this commit by cherry-pick 😏 8d3b61a

Comment thread report_py3o/models/py3o_report.py Outdated
report_xml._get_rendering_context(model_instance.ids, data)
)
context['objects'] = model_instance
# image false will crash base64 decoding

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbaden The image field does not exist on all models. It is in the template that you must add an `if' instruction before using this field (it is a demo template)

@tbaden tbaden May 3, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would this instruction look like in the odt template?
additional: wouldn't it be good to still check if image exists in objects and when false to set it to empty bytestring. otherwise you'll get an error if an user forgets this if instruction.

like this:

        if (
            hasattr(context['objects'], 'image') and
            not context['objects'].image
        ):
            context['objects'].image = b''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbaden A report can be defined for any model and the name of a field used to store an image is not always 'image'.
It's important to manage this case into the template to also avoid to display an empty square if the image is missing into the document.
You can use a control structure into the template to avoid to output an image if not set https://py3otemplate.readthedocs.io/en/latest/templating.html#use-control-structures

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmignon done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbaden The demo template seems to no more work....

@tbaden tbaden May 3, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmignon the use of simplejson could fix this. what's your opinion on this?

like:

 try:
         import simplejson as json
except ImportError:
         import json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbaden Before introducing a new dependency I prefer to understand what's the root cause of the problem...

@tbaden tbaden May 6, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll reset my dev env and install it again. Maybe I messed it up somewhere for other developments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to stay with the standard python libraries. It doesn't seem normal to me that the result of serialization to json works with one library and not another when it shouldn't make any difference. I have the feeling that the problem encountered is elsewhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmignon I found the "issue". In v11 the portal User has no image, in v12 the portal user has an image. If you delete the image in v12 you get the exact same error:

File "/usr/lib/python3.5/base64.py", line 46, in _bytes_from_decode_data
"string, not %r" % s.class.name) from None
TypeError: argument should be a bytes-like object or ASCII string, not 'bool'

If I use my if structure template I get the same error:

E TypeError: b'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC' is not JSON serializable

So it's a general issue in v11 and v12. As you said, this should be caught in the odt template with an if structure. Maybe my if structure is still faulty. Could you please check my odt template

Comment thread report_py3o/static/src/js/py3oactionmanager.js Outdated
@tbaden tbaden changed the title [MIG][11.0][WIP] report_py3o backport of v12 [MIG][11.0] report_py3o backport of v12 May 3, 2019
@emagdalenaC2i emagdalenaC2i mentioned this pull request Jun 1, 2019
12 tasks
@lmignon lmignon mentioned this pull request Jun 3, 2019
@cataclysmic

Copy link
Copy Markdown

What is the current situation with the backport? I'm using odoo 11 CE and would really like to try this module. I'd be willing to help. However, I'm a noob in odoo development.

@github-actions

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 20, 2022
@github-actions github-actions Bot closed this Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.