Browse Source

[MIG] report_wkhtmltopdf_param: Migraton to 11.0

pull/278/head
Enric Tobella 7 years ago
committed by Abraham Anes
parent
commit
0cd41fb18b
  1. 6
      report_wkhtmltopdf_param/README.rst
  2. 3
      report_wkhtmltopdf_param/__init__.py
  3. 5
      report_wkhtmltopdf_param/__manifest__.py
  4. 3
      report_wkhtmltopdf_param/models/__init__.py
  5. 28
      report_wkhtmltopdf_param/models/report.py
  6. 11
      report_wkhtmltopdf_param/models/report_paperformat.py
  7. 3
      report_wkhtmltopdf_param/models/report_paperformat_parameter.py
  8. 3
      report_wkhtmltopdf_param/tests/__init__.py
  9. 2
      report_wkhtmltopdf_param/tests/test_report_paperformat.py
  10. 2
      report_wkhtmltopdf_param/views/paperformat.xml

6
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
========================
@ -25,10 +25,9 @@ Usage
#. Add additional parameters indicating the command argument name (remember to
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 <miku@avoin.systems>
* Jordi Ballester <jordi.ballester@eficent.com>
Maintainer
----------

3
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

5
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",

3
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

28
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])

11
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):
</body>
</html>
"""
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."))

3
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

3
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

2
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

2
report_wkhtmltopdf_param/views/paperformat.xml

@ -4,7 +4,7 @@
<record id="paperformat_view_form_custom" model="ir.ui.view">
<field name="name">paperformat with custom parameters</field>
<field name="model">report.paperformat</field>
<field name="inherit_id" ref="report.paperformat_view_form"/>
<field name="inherit_id" ref="base.paperformat_view_form"/>
<field name="arch" type="xml">
<field name="report_ids" position="after">
<field name="custom_params">

Loading…
Cancel
Save