From 0cd41fb18bc3625094dc5205779b97a77c577cb6 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Fri, 22 Dec 2017 12:55:54 +0100 Subject: [PATCH] [MIG] report_wkhtmltopdf_param: Migraton to 11.0 --- report_wkhtmltopdf_param/README.rst | 8 ++---- report_wkhtmltopdf_param/__init__.py | 3 +- report_wkhtmltopdf_param/__manifest__.py | 5 ++-- report_wkhtmltopdf_param/models/__init__.py | 3 +- report_wkhtmltopdf_param/models/report.py | 28 +++++++++++-------- .../models/report_paperformat.py | 11 ++++---- .../models/report_paperformat_parameter.py | 3 +- report_wkhtmltopdf_param/tests/__init__.py | 3 +- .../tests/test_report_paperformat.py | 2 +- .../views/paperformat.xml | 2 +- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/report_wkhtmltopdf_param/README.rst b/report_wkhtmltopdf_param/README.rst index 567acaed..e8c3e546 100644 --- a/report_wkhtmltopdf_param/README.rst +++ b/report_wkhtmltopdf_param/README.rst @@ -1,5 +1,5 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 ======================== @@ -23,12 +23,11 @@ Usage #. Go to *Settings* and press 'Activate the developer mode (with assets)' #. Go to *Settings - Technical - Reports - Paper Format* #. Add additional parameters indicating the command argument name (remember to - add prefix -- or -) and value. - + add prefix -- or -) and value. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/143/10.0 + :target: https://runbot.odoo-community.org/runbot/143/11.0 Bug Tracker @@ -53,7 +52,6 @@ Contributors * Miku Laitinen * Jordi Ballester - Maintainer ---------- diff --git a/report_wkhtmltopdf_param/__init__.py b/report_wkhtmltopdf_param/__init__.py index 056ac84d..0c60f8dc 100644 --- a/report_wkhtmltopdf_param/__init__.py +++ b/report_wkhtmltopdf_param/__init__.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import models diff --git a/report_wkhtmltopdf_param/__manifest__.py b/report_wkhtmltopdf_param/__manifest__.py index d45d1903..d0bac688 100644 --- a/report_wkhtmltopdf_param/__manifest__.py +++ b/report_wkhtmltopdf_param/__manifest__.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # noinspection PyStatementEffect { @@ -17,7 +16,7 @@ "website": "https://avoin.systems", "category": "Technical Settings", "depends": [ - "report", + "web", ], "data": [ "security/ir.model.access.csv", diff --git a/report_wkhtmltopdf_param/models/__init__.py b/report_wkhtmltopdf_param/models/__init__.py index ebdbde57..c0003bd5 100644 --- a/report_wkhtmltopdf_param/models/__init__.py +++ b/report_wkhtmltopdf_param/models/__init__.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import report_paperformat_parameter from . import report_paperformat diff --git a/report_wkhtmltopdf_param/models/report.py b/report_wkhtmltopdf_param/models/report.py index fc14c983..82f318e6 100644 --- a/report_wkhtmltopdf_param/models/report.py +++ b/report_wkhtmltopdf_param/models/report.py @@ -1,23 +1,29 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems # Copyright 2017 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import models +from odoo import api, models -class Report(models.Model): - _inherit = 'report' +class IrActionsReport(models.Model): + _inherit = 'ir.actions.report' - def _build_wkhtmltopdf_args(self, paperformat, - specific_paperformat_args=None): + @api.model + def _build_wkhtmltopdf_args( + self, + paperformat_id, + landscape, + specific_paperformat_args=None, + set_viewport_size=False): # noinspection PyUnresolvedReferences,PyProtectedMember - command_args = super(Report, self)._build_wkhtmltopdf_args( - paperformat, - specific_paperformat_args + command_args = super(IrActionsReport, self)._build_wkhtmltopdf_args( + paperformat_id, + landscape, + specific_paperformat_args, + set_viewport_size ) - for param in paperformat.custom_params: + for param in paperformat_id.custom_params: command_args.extend([param.name]) if param.value: command_args.extend([param.value]) diff --git a/report_wkhtmltopdf_param/models/report_paperformat.py b/report_wkhtmltopdf_param/models/report_paperformat.py index 6b2582ce..20846771 100644 --- a/report_wkhtmltopdf_param/models/report_paperformat.py +++ b/report_wkhtmltopdf_param/models/report_paperformat.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems # Copyright 2017 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models, _ from odoo.exceptions import ValidationError @@ -34,9 +33,11 @@ class Paper(models.Model): """ - contenthtml = [tuple([1, sample_html])] - content = self.env['report']._run_wkhtmltopdf( - [], [], contenthtml, False, paperformat, False, False, False) + contenthtml = [bytes(sample_html, 'utf-8')] + report = self.env['ir.actions.report'].new({ + 'paperformat_id': paperformat.id + }) + content = report._run_wkhtmltopdf(contenthtml) if not content: raise ValidationError(_( "Failed to create a PDF using the provided parameters.")) diff --git a/report_wkhtmltopdf_param/models/report_paperformat_parameter.py b/report_wkhtmltopdf_param/models/report_paperformat_parameter.py index c044a6aa..b8980c91 100644 --- a/report_wkhtmltopdf_param/models/report_paperformat_parameter.py +++ b/report_wkhtmltopdf_param/models/report_paperformat_parameter.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import models, fields diff --git a/report_wkhtmltopdf_param/tests/__init__.py b/report_wkhtmltopdf_param/tests/__init__.py index 17a83ad6..5b86a660 100644 --- a/report_wkhtmltopdf_param/tests/__init__.py +++ b/report_wkhtmltopdf_param/tests/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems # Copyright 2017 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + from . import test_report_paperformat diff --git a/report_wkhtmltopdf_param/tests/test_report_paperformat.py b/report_wkhtmltopdf_param/tests/test_report_paperformat.py index 2307a588..33c98799 100644 --- a/report_wkhtmltopdf_param/tests/test_report_paperformat.py +++ b/report_wkhtmltopdf_param/tests/test_report_paperformat.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2017 Avoin.Systems # Copyright 2017 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import odoo.tests from odoo.exceptions import ValidationError diff --git a/report_wkhtmltopdf_param/views/paperformat.xml b/report_wkhtmltopdf_param/views/paperformat.xml index 57d6777a..460dd427 100644 --- a/report_wkhtmltopdf_param/views/paperformat.xml +++ b/report_wkhtmltopdf_param/views/paperformat.xml @@ -4,7 +4,7 @@ paperformat with custom parameters report.paperformat - +