[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:
Laurent Mignon (ACSONE)
2019-02-01 14:52:24 +01:00
committed by Elmeri Niemelä
parent ac6e75c7b4
commit 6f6cf5688b
4 changed files with 139 additions and 7 deletions

View File

@@ -242,8 +242,7 @@ class Py3oReport(models.TransientModel):
@api.multi
def _convert_single_report(self, result_path, model_instance, data):
"""Run a command to convert to our target format"""
filetype = self.ir_actions_report_id.py3o_filetype
if not Formats().get_format(filetype).native:
if not self.ir_actions_report_id.is_py3o_native_format:
command = self._convert_single_report_cmd(
result_path, model_instance, data,
)
@@ -256,7 +255,8 @@ class Py3oReport(models.TransientModel):
result_path, result_filename = os.path.split(result_path)
result_path = os.path.join(
result_path, '%s.%s' % (
os.path.splitext(result_filename)[0], filetype
os.path.splitext(result_filename)[0],
self.ir_actions_report_id.py3o_filetype
)
)
return result_path
@@ -264,10 +264,14 @@ class Py3oReport(models.TransientModel):
@api.multi
def _convert_single_report_cmd(self, result_path, model_instance, data):
"""Return a command list suitable for use in subprocess.call"""
lo_bin = self.ir_actions_report_id.lo_bin_path
if not lo_bin:
raise RuntimeError(
_("Libreoffice runtime not available. "
"Please contact your administrator.")
)
return [
self.env['ir.config_parameter'].get_param(
'py3o.conversion_command', 'libreoffice',
),
lo_bin,
'--headless',
'--convert-to',
self.ir_actions_report_id.py3o_filetype,