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.

56 lines
2.3 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. class IrActionsReport(models.Model):
  9. _inherit = 'ir.actions.report'
  10. @api.multi
  11. @api.constrains("py3o_is_local_fusion", "py3o_server_id")
  12. def _check_py3o_server_id(self):
  13. for report in self:
  14. if report.report_type != "py3o":
  15. continue
  16. if (not report.py3o_is_local_fusion and not report.py3o_server_id):
  17. raise ValidationError(_(
  18. "You can not use remote fusion without Fusion server. "
  19. "Please specify a Fusion Server"))
  20. py3o_is_local_fusion = fields.Boolean(
  21. "Local Fusion",
  22. help="Native formats will be processed without a server. "
  23. "You must use this mode if you call methods on your model into "
  24. "the template.",
  25. default=True)
  26. py3o_server_id = fields.Many2one(
  27. "py3o.server",
  28. "Fusion Server")
  29. pdf_options_id = fields.Many2one(
  30. 'py3o.pdf.options', string='PDF Options', ondelete='restrict',
  31. help="PDF options can be set per report, but also per Py3o Server. "
  32. "If both are defined, the options on the report are used.")
  33. @api.depends("lo_bin_path", "is_py3o_native_format", "report_type",
  34. "py3o_server_id")
  35. @api.multi
  36. def _compute_py3o_report_not_available(self):
  37. for rec in self:
  38. if not rec.report_type == "py3o":
  39. continue
  40. if (not rec.is_py3o_native_format and
  41. not rec.lo_bin_path and not rec.py3o_server_id):
  42. rec.is_py3o_report_not_available = True
  43. rec.msg_py3o_report_not_available = _(
  44. "A fusion server or a libreoffice runtime are required "
  45. "to genereate the py3o report '%s'. If the libreoffice"
  46. "runtime is already installed and is not found by "
  47. "Odoo, you can provide the full path to the runtime by "
  48. "setting the key 'py3o.conversion_command' into the "
  49. "configuration parameters."
  50. ) % rec.name