mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP][FIX] py3o_report, py3o_report_fusion_server: Compute the availability of py3o report
Before this change it was not possible to install modules declaring py3o report into a non native format without specifying a Fusion server once the module py3o_report_fusion_server was installed. With theses changes, we now take care of the availability of the libreoffice runtime to display/log a warning message when the report is in a non native runtime.
This commit is contained in:
committed by
Alexis de Lattre
parent
2b64b6c0e0
commit
fb715f5e30
@@ -7,26 +7,19 @@ from odoo.exceptions import ValidationError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from py3o.formats import Formats
|
||||
except ImportError:
|
||||
logger.debug('Cannot import py3o.formats')
|
||||
|
||||
|
||||
class IrActionsReport(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
|
||||
@api.multi
|
||||
@api.constrains("py3o_is_local_fusion", "py3o_server_id", "py3o_filetype")
|
||||
@api.constrains("py3o_is_local_fusion", "py3o_server_id")
|
||||
def _check_py3o_server_id(self):
|
||||
for report in self:
|
||||
if report.report_type != "py3o":
|
||||
continue
|
||||
is_native = Formats().get_format(report.py3o_filetype).native
|
||||
if ((not is_native or not report.py3o_is_local_fusion) and
|
||||
not report.py3o_server_id):
|
||||
if (not report.py3o_is_local_fusion and not report.py3o_server_id):
|
||||
raise ValidationError(_(
|
||||
"Can not use not native format in local fusion. "
|
||||
"You can not use remote fusion without Fusion server. "
|
||||
"Please specify a Fusion Server"))
|
||||
|
||||
py3o_is_local_fusion = fields.Boolean(
|
||||
@@ -42,3 +35,22 @@ class IrActionsReport(models.Model):
|
||||
'py3o.pdf.options', string='PDF Options', ondelete='restrict',
|
||||
help="PDF options can be set per report, but also per Py3o Server. "
|
||||
"If both are defined, the options on the report are used.")
|
||||
|
||||
@api.depends("lo_bin_path", "is_py3o_native_format", "report_type",
|
||||
"py3o_server_id")
|
||||
@api.multi
|
||||
def _compute_py3o_report_not_available(self):
|
||||
for rec in self:
|
||||
if not rec.report_type == "py3o":
|
||||
continue
|
||||
if (not rec.is_py3o_native_format and
|
||||
not rec.lo_bin_path and not rec.py3o_server_id):
|
||||
rec.is_py3o_report_not_available = True
|
||||
rec.msg_py3o_report_not_available = _(
|
||||
"A fusion server or a libreoffice runtime are required "
|
||||
"to genereate the py3o report '%s'. If the libreoffice"
|
||||
"runtime is already installed and is not found by "
|
||||
"Odoo, you can provide the full path to the runtime by "
|
||||
"setting the key 'py3o.conversion_command' into the "
|
||||
"configuration parameters."
|
||||
) % rec.name
|
||||
|
||||
Reference in New Issue
Block a user