From a1cdcc780ef34fd3103f67340e010d198baa8d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elmeri=20Niemel=C3=A4?= Date: Wed, 21 Oct 2020 18:33:18 +0300 Subject: [PATCH] [14.0][MIG] report_py3o: Migration to 14.0 --- report_py3o/README.rst | 13 ++++++----- report_py3o/__manifest__.py | 2 +- report_py3o/controllers/main.py | 2 +- report_py3o/models/ir_actions_report.py | 11 ++++++--- report_py3o/models/py3o_report.py | 2 +- report_py3o/security/ir.model.access.csv | 1 + report_py3o/static/description/index.html | 4 ++-- report_py3o/tests/test_report_py3o.py | 28 +++++++++++------------ 8 files changed, 35 insertions(+), 28 deletions(-) diff --git a/report_py3o/README.rst b/report_py3o/README.rst index fcb63514..62cda6d8 100644 --- a/report_py3o/README.rst +++ b/report_py3o/README.rst @@ -14,16 +14,16 @@ 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/13.0/report_py3o + :target: https://github.com/OCA/reporting-engine/tree/14.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-13-0/reporting-engine-13-0-report_py3o + :target: https://translation.odoo-community.org/projects/reporting-engine-14.0/reporting-engine-14.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/13.0 + :target: https://runbot.odoo-community.org/runbot/143/14.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| The py3o reporting engine is a reporting engine for Odoo based on `Libreoffice `_: @@ -203,7 +203,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -225,6 +225,7 @@ Contributors * Guewen Baconnier * Omar Castiñeira * Holger Brunn +* Elmeri Niemelä Maintainers ~~~~~~~~~~~ @@ -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 `_ project on GitHub. +This module is part of the `OCA/reporting-engine `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/report_py3o/__manifest__.py b/report_py3o/__manifest__.py index 3121d358..93614de9 100644 --- a/report_py3o/__manifest__.py +++ b/report_py3o/__manifest__.py @@ -4,7 +4,7 @@ "name": "Py3o Report Engine", "summary": "Reporting engine based on Libreoffice (ODT -> ODT, " "ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "category": "Reporting", "license": "AGPL-3", "author": "XCG Consulting," "ACSONE SA/NV," "Odoo Community Association (OCA)", diff --git a/report_py3o/controllers/main.py b/report_py3o/controllers/main.py index ac4decaf..08deed20 100644 --- a/report_py3o/controllers/main.py +++ b/report_py3o/controllers/main.py @@ -43,7 +43,7 @@ class ReportController(main.ReportController): description="Py3o action report not found for report_name " "%s" % reportname ) - res, filetype = action_py3o_report.render(docids, data) + res, filetype = action_py3o_report._render(docids, data) filename = action_py3o_report.gen_report_download_filename(docids, data) if not filename.endswith(filetype): filename = "{}.{}".format(filename, filetype) diff --git a/report_py3o/models/ir_actions_report.py b/report_py3o/models/ir_actions_report.py index 5889e37e..e8ecde33 100644 --- a/report_py3o/models/ir_actions_report.py +++ b/report_py3o/models/ir_actions_report.py @@ -47,7 +47,13 @@ class IrActionsReport(models.Model): selections.append((name, description)) return selections - report_type = fields.Selection(selection_add=[("py3o", "py3o")]) + report_type = fields.Selection( + selection_add=[("py3o", "py3o")], + ondelete={ + 'py3o': 'cascade', + }, + ) + py3o_filetype = fields.Selection( selection="_get_py3o_filetypes", string="Output Format" ) @@ -65,7 +71,6 @@ class IrActionsReport(models.Model): "or an absolute path on your server." ), ) - report_type = fields.Selection(selection_add=[("py3o", "Py3o")]) py3o_multi_in_one = fields.Boolean( string="Multiple Records in a Single Report", help="If you execute a report on several records, " @@ -155,7 +160,7 @@ class IrActionsReport(models.Model): [("report_name", "=", report_name), ("report_type", "=", report_type)] ) - def render_py3o(self, res_ids, data): + def _render_py3o(self, res_ids, data): self.ensure_one() if self.report_type != "py3o": raise RuntimeError( diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index da905ae7..a4c9015a 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -196,7 +196,7 @@ class Py3oReport(models.TransientModel): # consumption... # ... but odoo wants the whole data in memory anyways :) buffer = BytesIO(f.read()) - self.ir_actions_report_id.postprocess_pdf_report(model_instance, buffer) + self.ir_actions_report_id._postprocess_pdf_report(model_instance, buffer) return result_path def _create_single_report(self, model_instance, data): diff --git a/report_py3o/security/ir.model.access.csv b/report_py3o/security/ir.model.access.csv index 6d45c8de..bc6eb629 100644 --- a/report_py3o/security/ir.model.access.csv +++ b/report_py3o/security/ir.model.access.csv @@ -1,3 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_py3o_template_admin,access_py3o_template_admin,model_py3o_template,base.group_no_one,1,1,1,1 access_py3o_template_user,access_py3o_template_user,model_py3o_template,base.group_user,1,0,0,0 +access_py3o_report_user,access_py3o_report_user,model_py3o_report,base.group_user,1,1,1,1 diff --git a/report_py3o/static/description/index.html b/report_py3o/static/description/index.html index 95f7af93..9df060ca 100644 --- a/report_py3o/static/description/index.html +++ b/report_py3o/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runbot

The py3o reporting engine is a reporting engine for Odoo based on Libreoffice:

  • the report is created with Libreoffice (ODT or ODS),
  • @@ -576,7 +576,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    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 project on GitHub.

    +

    This module is part of the OCA/reporting-engine project on GitHub.

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

    diff --git a/report_py3o/tests/test_report_py3o.py b/report_py3o/tests/test_report_py3o.py index c2e02b47..294c79fe 100644 --- a/report_py3o/tests/test_report_py3o.py +++ b/report_py3o/tests/test_report_py3o.py @@ -9,7 +9,7 @@ import tempfile from base64 import b64decode, b64encode from contextlib import contextmanager -import mock +from unittest import mock import pkg_resources from PyPDF2 import PdfFileWriter from PyPDF2.pdf import PageObject @@ -46,7 +46,7 @@ def temporary_copy(path): class TestReportPy3o(TransactionCase): def setUp(self): super(TestReportPy3o, self).setUp() - self.env.user.image = PNG + self.env.user.image_1920 = PNG self.report = self.env.ref("report_py3o.res_users_report_py3o") self.py3o_report = self.env["py3o.report"].create( {"ir_actions_report_id": self.report.id} @@ -74,13 +74,13 @@ class TestReportPy3o(TransactionCase): or result ) # test the call the the create method inside our custom parser - self.report.render(self.env.user.ids) + self.report._render(self.env.user.ids) self.assertEqual(call_count, patched_pdf.call_count) # generated files no more exists self.assertFalse(os.path.exists(result)) def test_reports(self): - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertTrue(res) def test_reports_merge_zip(self): @@ -93,7 +93,7 @@ class TestReportPy3o(TransactionCase): py3o_report.__class__, "_zip_results" ) as patched_zip_results: patched_zip_results.side_effect = _zip_results - content, filetype = self.report.render(users.ids) + content, filetype = self.report._render(users.ids) self.assertEqual(1, patched_zip_results.call_count) self.assertEqual(filetype, "zip") @@ -122,7 +122,7 @@ class TestReportPy3o(TransactionCase): # time we ask the report we received the saved attachment not a newly # generated document created_attachement.datas = base64.encodestring(b"new content") - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertEqual((b"new content", self.report.py3o_filetype), res) def test_report_post_process(self): @@ -150,24 +150,24 @@ class TestReportPy3o(TransactionCase): "odoo.addons.%s" % self.report.module, tmpl_name ) self.assertTrue(os.path.exists(flbk_filename)) - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertTrue(res) # The generation fails if the template is not found self.report.module = False with self.assertRaises(TemplateNotFound), self.env.cr.savepoint(): - self.report.render(self.env.user.ids) + self.report._render(self.env.user.ids) # the template can also be provided as an abspath if it's root path # is trusted self.report.py3o_template_fallback = flbk_filename with self.assertRaises(TemplateNotFound): - self.report.render(self.env.user.ids) + self.report._render(self.env.user.ids) 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) } - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertTrue(res) # the tempalte can also be provided as a binary field @@ -184,7 +184,7 @@ class TestReportPy3o(TransactionCase): ) self.report.py3o_template_id = py3o_template self.report.py3o_template_fallback = flbk_filename - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertTrue(res) @tools.misc.mute_logger("odoo.addons.report_py3o.models.py3o_report") @@ -240,7 +240,7 @@ class TestReportPy3o(TransactionCase): self.assertFalse(self.report.lo_bin_path) self.assertFalse(self.report.is_py3o_report_not_available) self.assertFalse(self.report.msg_py3o_report_not_available) - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertTrue(res) # The report should become unavailable for an non native output format @@ -249,7 +249,7 @@ class TestReportPy3o(TransactionCase): self.assertTrue(self.report.is_py3o_report_not_available) self.assertTrue(self.report.msg_py3o_report_not_available) with self.assertRaises(RuntimeError): - self.report.render(self.env.user.ids) + self.report._render(self.env.user.ids) # if we reset the wrong path, everything should work self.env["ir.config_parameter"].set_param( @@ -260,5 +260,5 @@ class TestReportPy3o(TransactionCase): self.assertFalse(self.report.is_py3o_native_format) self.assertFalse(self.report.is_py3o_report_not_available) self.assertFalse(self.report.msg_py3o_report_not_available) - res = self.report.render(self.env.user.ids) + res = self.report._render(self.env.user.ids) self.assertTrue(res)