[MIG] report_wkhtmltopdf_param: Migraton to 11.0

This commit is contained in:
Enric Tobella
2017-12-22 12:55:54 +01:00
committed by fshah
parent 749801193d
commit 04a01f6c0e
79 changed files with 823 additions and 621 deletions

View File

@@ -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

View File

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

View File

@@ -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."))

View File

@@ -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