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.

45 lines
1.7 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2013 XCG Consulting <http://odoo.consulting>
  3. # © 2017 Therp BV <http://therp.nl>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. import logging
  6. from openerp import _, api, fields, models
  7. from odoo.exceptions import ValidationError
  8. logger = logging.getLogger(__name__)
  9. try:
  10. from py3o.formats import Formats
  11. except ImportError:
  12. logger.debug('Cannot import py3o.formats')
  13. class IrActionsReportXml(models.Model):
  14. _inherit = 'ir.actions.report.xml'
  15. @api.multi
  16. @api.constrains("py3o_is_local_fusion", "py3o_server_id", "py3o_filetype")
  17. def _check_py3o_server_id(self):
  18. for report in self:
  19. if report.report_type != "py3o":
  20. continue
  21. is_native = Formats().get_format(report.py3o_filetype).native
  22. if ((not is_native or not report.py3o_is_local_fusion) and
  23. not report.py3o_server_id):
  24. raise ValidationError(_(
  25. "Can not use not native format in local fusion. "
  26. "Please specify a Fusion Server"))
  27. py3o_is_local_fusion = fields.Boolean(
  28. "Local Fusion",
  29. help="Native formats will be processed without a server. "
  30. "You must use this mode if you call methods on your model into "
  31. "the template.",
  32. default=True)
  33. py3o_server_id = fields.Many2one(
  34. "py3o.server",
  35. "Fusion Server")
  36. pdf_options_id = fields.Many2one(
  37. 'py3o.pdf.options', string='PDF Options', ondelete='restrict',
  38. help="PDF options can be set per report, but also per Py3o Server. "
  39. "If both are defined, the options on the report are used.")