You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
42 lines
1.4 KiB
# -*- 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).
|
|
|
|
from odoo import api, fields, models, _
|
|
from odoo.exceptions import ValidationError
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Paper(models.Model):
|
|
_inherit = 'report.paperformat'
|
|
|
|
custom_params = fields.One2many(
|
|
'report.paperformat.parameter',
|
|
'paperformat_id',
|
|
'Custom Parameters',
|
|
help='Custom Parameters passed forward as wkhtmltopdf '
|
|
'command arguments'
|
|
)
|
|
|
|
@api.constrains('custom_params')
|
|
def _check_recursion(self):
|
|
for paperformat in self:
|
|
sample_html = """
|
|
<!DOCTYPE html>
|
|
<html style="height: 0;">
|
|
<body>
|
|
<div>
|
|
<span itemprop="name">Hello World!</span>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
"""
|
|
contenthtml = [tuple([1, sample_html])]
|
|
content = self.env['report']._run_wkhtmltopdf(
|
|
[], [], contenthtml, False, paperformat, False, False, False)
|
|
if not content:
|
|
raise ValidationError(_(
|
|
"Failed to create a PDF using the provided parameters."))
|