[12.0][FIX] - report_py3o: run libreoffice in an isolated user installation
Bug when more than one conversion print is launched within the same libreoffice instance. The standard behavior of libreoffice when a user open it while another instance is running is to show a new window and throw an error if a new instance is forced within the same user installation [see](https://bugs.documentfoundation.org/show_bug.cgi?id=37531). This implies a bug in report_py3o module when we call libreoffice at the same time for different documents. To reproduce this bug: **Case 1:** 1. Simultaneously print two documents. **Case 2:** 1. Run print jobs using job_queue module 2. Manually print another document **Case 3:** 2. Open libreoffice 3. Print a py3o report This PR creates a temporary user installation for each libreoffice conversion to bypass this limitation.pull/365/head
parent
bd4cad3904
commit
e55f91ac5c
|
@ -243,26 +243,32 @@ class Py3oReport(models.TransientModel):
|
||||||
def _convert_single_report(self, result_path, model_instance, data):
|
def _convert_single_report(self, result_path, model_instance, data):
|
||||||
"""Run a command to convert to our target format"""
|
"""Run a command to convert to our target format"""
|
||||||
if not self.ir_actions_report_id.is_py3o_native_format:
|
if not self.ir_actions_report_id.is_py3o_native_format:
|
||||||
command = self._convert_single_report_cmd(
|
with tempfile.TemporaryDirectory() as tmp_user_installation:
|
||||||
result_path, model_instance, data,
|
command = self._convert_single_report_cmd(
|
||||||
)
|
result_path,
|
||||||
logger.debug('Running command %s', command)
|
model_instance,
|
||||||
output = subprocess.check_output(
|
data,
|
||||||
command, cwd=os.path.dirname(result_path),
|
user_installation=tmp_user_installation,
|
||||||
)
|
)
|
||||||
logger.debug('Output was %s', output)
|
logger.debug('Running command %s', command)
|
||||||
self._cleanup_tempfiles([result_path])
|
output = subprocess.check_output(
|
||||||
result_path, result_filename = os.path.split(result_path)
|
command, cwd=os.path.dirname(result_path),
|
||||||
result_path = os.path.join(
|
)
|
||||||
result_path, '%s.%s' % (
|
logger.debug('Output was %s', output)
|
||||||
os.path.splitext(result_filename)[0],
|
self._cleanup_tempfiles([result_path])
|
||||||
self.ir_actions_report_id.py3o_filetype
|
result_path, result_filename = os.path.split(result_path)
|
||||||
|
result_path = os.path.join(
|
||||||
|
result_path, '%s.%s' % (
|
||||||
|
os.path.splitext(result_filename)[0],
|
||||||
|
self.ir_actions_report_id.py3o_filetype
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
return result_path
|
return result_path
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _convert_single_report_cmd(self, result_path, model_instance, data):
|
def _convert_single_report_cmd(
|
||||||
|
self, result_path, model_instance, data, user_installation=None
|
||||||
|
):
|
||||||
"""Return a command list suitable for use in subprocess.call"""
|
"""Return a command list suitable for use in subprocess.call"""
|
||||||
lo_bin = self.ir_actions_report_id.lo_bin_path
|
lo_bin = self.ir_actions_report_id.lo_bin_path
|
||||||
if not lo_bin:
|
if not lo_bin:
|
||||||
|
@ -270,13 +276,16 @@ class Py3oReport(models.TransientModel):
|
||||||
_("Libreoffice runtime not available. "
|
_("Libreoffice runtime not available. "
|
||||||
"Please contact your administrator.")
|
"Please contact your administrator.")
|
||||||
)
|
)
|
||||||
return [
|
cmd = [
|
||||||
lo_bin,
|
lo_bin,
|
||||||
'--headless',
|
'--headless',
|
||||||
'--convert-to',
|
'--convert-to',
|
||||||
self.ir_actions_report_id.py3o_filetype,
|
self.ir_actions_report_id.py3o_filetype,
|
||||||
result_path,
|
result_path,
|
||||||
]
|
]
|
||||||
|
if user_installation:
|
||||||
|
cmd.append('-env:UserInstallation=file:%s' % user_installation)
|
||||||
|
return cmd
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_or_create_single_report(self, model_instance, data,
|
def _get_or_create_single_report(self, model_instance, data,
|
||||||
|
|
Loading…
Reference in New Issue