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.

44 lines
1.6 KiB

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