Tryton - Issues



Title generated report filetype default mimetype application/zip and not application/vnd.oasis.opendocument.text
Priority bug Status invalid
Superseder Nosy List ced, risto3
Type Components
Assigned To Keywords

Created on 2018-05-02.15:01:42 by risto3, last changed by ced.

msg40530 (view) Author: [hidden] (risto3) Date: 2018-05-05.19:28:45
??? only M$ Windoze relies on the file extension !
`file' has been used since before even DOS was born.

It is clear that the generated file is not conforming to 3.3 MIME Media Type

The mimetype file must be the first file in the zipped odt.
$ zipinfo 
Zip file size: 65427 bytes, number of entries: 6
?rw-------  2.0 unx     2547 b- stor 18-May-05 16:14 meta.xml
?rw-------  2.0 unx    12914 b- stor 18-May-05 16:14 settings.xml
?rw-------  2.0 unx    21709 b- stor 18-May-05 16:14 content.xml
?rw-------  2.0 unx    27006 b- stor 18-May-05 16:14 styles.xml
?rw-------  2.0 unx       39 b- stor 18-May-05 16:14 mimetype
?rw-------  2.0 unx      594 b- stor 18-May-05 16:14 META-INF/manifest.xml
6 files, 64809 bytes uncompressed, 64809 bytes compressed:  0.0%
msg40529 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-05-05.18:59:29
Well, msg40524 just shows that the order of the files in the zip are different. But the generate file is a valid odt that LibreOffice can open. It is just that your xdg-open relies on libmagic (which is obviously magic) and not on the extension. I guess libmagic just expect to find the mimetype file at the beginning.

So it should be reported as a feature request to
msg40528 (view) Author: [hidden] (risto3) Date: 2018-05-05.18:45:27
BTW, when I say 'all other examples', I mean outside of Tryton.
msg40527 (view) Author: [hidden] (risto3) Date: 2018-05-05.18:37:18
Thought I'd try SAO... and it seems to work okay.
So the problem seems limited to the gtk client.
msg40524 (view) Author: [hidden] (risto3) Date: 2018-05-05.18:25:35
This is with the defaults on a newly created base.

I don't believe xdg-open is busted as it works fine with all other examples.
Besides, it relies on `file` which uses libmagic.

Here are the 'magic' headers, showing that the file generated by the default installation give 'zip':
$ xxd trial_balance.odt |head -5
00000000: 504b 0304 1400 0008 0000 4282 a54c 5ec6  PK........B..L^.
00000010: 320c 2700 0000 2700 0000 0800 0000 6d69  2.'...'.......mi
00000020: 6d65 7479 7065 6170 706c 6963 6174 696f  metypeapplicatio
00000030: 6e2f 766e 642e 6f61 7369 732e 6f70 656e  n/
00000040: 646f 6375 6d65 6e74 2e74 6578 7450 4b03  document.textPK.
$ xxd Trial-Balance.odt |head -5
00000000: 504b 0304 1400 0000 0000 d881 a54c 0381  PK...........L..
00000010: 5462 f309 0000 f309 0000 0800 0000 6d65
00000020: 7461 2e78 6d6c 3c3f 786d 6c20 7665 7273  ta.xml<?xml vers
00000030: 696f 6e3d 2731 2e30 2720 656e 636f 6469  ion='1.0' encodi
00000040: 6e67 3d27 5554 462d 3827 3f3e 0a3c 6f66  ng='UTF-8'?>.<of

BTW: $ soffice --version
LibreOffice 40m0(Build:2)
msg40519 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-05-05.17:37:15
I think the problem is your xdg-open that is broken and can not correctly detect the file type.
Putting an extension to the report does not change anything because by default it fallback to the template extension [1].
Your test about converting fodt into odt does not provide any information as it is just the template.

The changeset you are pointing as nothing to do with flat ODT. It is about defining report template that works only for a single record.
But as you point it, you may have defined the report as single which will result in a zip file containing a report for each record.

msg40495 (view) Author: [hidden] (risto3) Date: 2018-05-02.15:01:41
I noticed since the new flat xml ODF report template integration that
leaving the report output format the default, or blank, causes problems
opening the file after generation.

The system zip archive manager gives the following:
Could not open "Trial-Balance.odt"
Archive type not supported.

$ file -ik /tmp/tryton_vvtc3Q/Trial-Balance.odt
/tmp/tryton_vvtc3Q/Trial-Balance.odt: application/zip\012- application/octet-stream; charset=binary
$ xdg-open /tmp/tryton_vvtc3Q/Trial-Balance.odt
# gives error indicated above

if I manually do a conversion off the model: 
$ soffice --headless --nolockcheck --nodefault --norestore --convert-to odt --outdir /tmp ~/src/hg-tryton/trytond/trytond/modules/account/trial_balance.fodt
$ file -ik /tmp/trial_balance.odt 
/tmp/trial_balance.odt: application/vnd.oasis.opendocument.text\012- application/octet-stream; charset=binary
$ xdg-open /tmp/trial_balance.odt
#opens the file just fine

I believe, though not sure, that the following commit may have something to do with the issue:
># HG changeset patch
># User C├ędric Krier <>
># Date 1504430050 -7200
>#      Sun Sep 03 11:14:10 2017 +0200
># Node ID 0bd088a8474b262d263f2e17e393e69c174f86f4
># Parent  ddd3ff6b77b9fdfe2a55ab93ebace98ddb010270
>Add support for single record report
>A single report render each record separately and return them in a zip file.
>To ensure the uniqueness of the file in the zip, it uses the id of the record
>but also the record name to be user-friendly.

The workaround that works for me is to specifically set an extension
in Administration->User Interface->Actions->Reports for each report
Date User Action Args
2018-05-05 20:05:10cedsetstatus: chatting -> invalid
2018-05-05 19:28:45risto3setstatus: invalid -> chatting
messages: + msg40530
2018-05-05 18:59:29cedsetstatus: need-eg -> invalid
messages: + msg40529
2018-05-05 18:45:27risto3setmessages: + msg40528
2018-05-05 18:37:19risto3setmessages: + msg40527
2018-05-05 18:25:35risto3setmessages: + msg40524
2018-05-05 17:37:16cedsetstatus: unread -> need-eg
nosy: + ced
messages: + msg40519
2018-05-02 15:01:42risto3create

Showing 10 items. Show all history (warning: this could be VERY long)