OCA reporting engine fork for dev and update.
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

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Avoin.Systems
  3. # Copyright 2017 Eficent Business and IT Consulting Services, S.L.
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from odoo import api, fields, models, _
  6. from odoo.exceptions import ValidationError
  7. import logging
  8. _logger = logging.getLogger(__name__)
  9. class Paper(models.Model):
  10. _inherit = 'report.paperformat'
  11. custom_params = fields.One2many(
  12. 'report.paperformat.parameter',
  13. 'paperformat_id',
  14. 'Custom Parameters',
  15. help='Custom Parameters passed forward as wkhtmltopdf '
  16. 'command arguments'
  17. )
  18. @api.constrains('custom_params')
  19. def _check_recursion(self):
  20. for paperformat in self:
  21. sample_html = """
  22. <!DOCTYPE html>
  23. <html style="height: 0;">
  24. <body>
  25. <div>
  26. <span itemprop="name">Hello World!</span>
  27. </div>
  28. </body>
  29. </html>
  30. """
  31. contenthtml = [tuple([1, sample_html])]
  32. content = self.env['report']._run_wkhtmltopdf(
  33. [], [], contenthtml, False, paperformat, False, False, False)
  34. if not content:
  35. raise ValidationError(_(
  36. "Failed to create a PDF using the provided parameters."))