[IMP] report_wkhtmltopdf_param: black, isort, prettier

This commit is contained in:
Saran440
2020-05-15 11:19:13 +07:00
committed by fshah
parent ddbc1926e8
commit f8b51745f6
6 changed files with 52 additions and 65 deletions

View File

@@ -6,21 +6,19 @@ from odoo import api, models
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
_inherit = "ir.actions.report"
@api.model
def _build_wkhtmltopdf_args(
self,
paperformat_id,
landscape,
specific_paperformat_args=None,
set_viewport_size=False):
self,
paperformat_id,
landscape,
specific_paperformat_args=None,
set_viewport_size=False,
):
# noinspection PyUnresolvedReferences,PyProtectedMember
command_args = super(IrActionsReport, self)._build_wkhtmltopdf_args(
paperformat_id,
landscape,
specific_paperformat_args,
set_viewport_size
paperformat_id, landscape, specific_paperformat_args, set_viewport_size
)
for param in paperformat_id.custom_params:

View File

@@ -2,25 +2,25 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
import logging
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__)
class Paper(models.Model):
_inherit = 'report.paperformat'
_inherit = "report.paperformat"
custom_params = fields.One2many(
'report.paperformat.parameter',
'paperformat_id',
'Custom Parameters',
help='Custom Parameters passed forward as wkhtmltopdf '
'command arguments'
"report.paperformat.parameter",
"paperformat_id",
"Custom Parameters",
help="Custom Parameters passed forward as wkhtmltopdf " "command arguments",
)
@api.constrains('custom_params')
@api.constrains("custom_params")
def _check_recursion(self):
for paperformat in self:
sample_html = """
@@ -33,11 +33,12 @@ class Paper(models.Model):
</body>
</html>
"""
contenthtml = [bytes(sample_html, 'utf-8')]
report = self.env['ir.actions.report'].new({
'paperformat_id': paperformat.id
})
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."))
raise ValidationError(
_("Failed to create a PDF using the provided parameters.")
)

View File

@@ -1,25 +1,21 @@
# Copyright 2017 Avoin.Systems
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models, fields
from odoo import fields, models
class ReportPaperformatParameter(models.Model):
_name = 'report.paperformat.parameter'
_description = 'wkhtmltopdf parameters'
_name = "report.paperformat.parameter"
_description = "wkhtmltopdf parameters"
paperformat_id = fields.Many2one(
'report.paperformat',
'Paper Format',
required=True,
"report.paperformat", "Paper Format", required=True,
)
name = fields.Char(
'Name',
"Name",
required=True,
help='The command argument name. Remember to add prefix -- or -'
help="The command argument name. Remember to add prefix -- or -",
)
value = fields.Char(
'Value',
)
value = fields.Char("Value",)