Use Output of rich text field in ODT in tryton 3.4

192 views
Skip to first unread message

Udo Spallek

unread,
Oct 1, 2015, 3:43:58 AM10/1/15
to tryton-contrib
Hi,

experimenting with the rich text widget for fields.Text() I can not
find a way to print the text in an odt report with Tryton and show
with libre office.

In libre office in the odt I insert a placeholder field of type "text"
with the field name defined in Tryton. When I print the report, there
is only shown the HTML code, but not the rendered text, like::

<p align='center'><span font_family='Monospace'
size='27'>My Rich Text</span></p>

Is there a way to get the rendered text shown in libre office?

TIA
Best, Udo Spallek

Cédric Krier

unread,
Oct 1, 2015, 4:15:04 AM10/1/15
to tryton
On 2015-10-01 00:28, 'Udo Spallek' via tryton wrote:
> Hi,
>
> experimenting with the rich text widget for fields.Text() I can not
> find a way to print the text in an odt report with Tryton and show
> with libre office.
>
> In libre office in the odt I insert a placeholder field of type "text"
> with the field name defined in Tryton. When I print the report, there
> is only shown the HTML code, but not the rendered text, like::
>
> <p align='center'><span font_family='Monospace'
> size='27'>My Rich Text</span></p>

That's normal because simple python expression is considered as simple
value templating directive.

> Is there a way to get the rendered text shown in libre office?

I did not test but the release 0.6.2 of relatorio include new directive
like content and replace. Those directive should allow you to "insert"
the HTML content in the odt.
But be careful that in 3.4, the richtext widget doesn't always generate
valid HTML as it is a mix of HTML and GTK markup.
Also I don't know if ODT spec contains exactly the subset of HTML (from
trunk) we use, maybe a converter should be used.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Udo Spallek

unread,
Oct 1, 2015, 6:34:59 AM10/1/15
to try...@googlegroups.com
Thu, 1 Oct 2015 10:11:27 +0200
Cédric Krier <cedric...@b2ck.com>:
>On 2015-10-01 00:28, 'Udo Spallek' via tryton wrote:
>> Is there a way to get the rendered text shown in libre office?
>I did not test but the release 0.6.2 of relatorio include new directive
>like content and replace. Those directive should allow you to "insert"
>the HTML content in the odt.
Thank you, but I have no idea how to insert those directives in libreoffice.
I tried placeholder type "text" with:

<content test="sale.quotation_appendix">
</content>
<content:sale.quotation_appendix>

But it always produces errors:

http://pastebin.com/4QfTXspt

Maybe placeholder is not the correct way?

Cédric Krier

unread,
Oct 1, 2015, 7:00:03 AM10/1/15
to try...@googlegroups.com
On 2015-10-01 12:34, 'Udo Spallek' via tryton wrote:
> Thu, 1 Oct 2015 10:11:27 +0200
> Cédric Krier <cedric...@b2ck.com>:
> >On 2015-10-01 00:28, 'Udo Spallek' via tryton wrote:
> >> Is there a way to get the rendered text shown in libre office?
> >I did not test but the release 0.6.2 of relatorio include new directive
> >like content and replace. Those directive should allow you to "insert"
> >the HTML content in the odt.
> Thank you, but I have no idea how to insert those directives in libreoffice.
> I tried placeholder type "text" with:
>
> <content test="sale.quotation_appendix">
> </content>
> <content:sale.quotation_appendix>
>
> But it always produces errors:
>
> http://pastebin.com/4QfTXspt
>
> Maybe placeholder is not the correct way?

Yes it should. The content directive is like any other directive, you
have to put something like in the placeholder:

content: p=sale.quotation_appendix

where "p" is the name of the parent tag for which you want to set the
content.
There is an example in relatorio/examples/columns.odt

Udo Spallek

unread,
Oct 1, 2015, 9:01:15 AM10/1/15
to try...@googlegroups.com
Thu, 1 Oct 2015 12:58:10 +0200
Cédric Krier <cedric...@b2ck.com>:
>On 2015-10-01 12:34, 'Udo Spallek' via tryton wrote:
>> Thu, 1 Oct 2015 10:11:27 +0200
>> Cédric Krier <cedric...@b2ck.com>:
>> >On 2015-10-01 00:28, 'Udo Spallek' via tryton wrote:
>> >> Is there a way to get the rendered text shown in libre office?
>> >I did not test but the release 0.6.2 of relatorio include new
>> >directive like content and replace. Those directive should allow
>> >you to "insert" the HTML content in the odt.
>> Thank you, but I have no idea how to insert those directives in
>> libreoffice. I tried placeholder type "text" with:
>>
>> <content test="sale.quotation_appendix">
>> </content>
>> <content:sale.quotation_appendix>
>>
>> But it always produces errors:
>>
>> http://pastebin.com/4QfTXspt
>>
>> Maybe placeholder is not the correct way?
>Yes it should. The content directive is like any other directive, you
>have to put something like in the placeholder:
>
> content: p=sale.quotation_appendix
>
>where "p" is the name of the parent tag for which you want to set the
>content.
>There is an example in relatorio/examples/columns.odt

Yes, you where correct, it works with placeholder type text::

<content text:p="item.text">

Using this rich text content from Tryton 3.4::

<p align='center'><span font_family='Monospace'
size='27'>My Rich Text</span></p>

... with this odt (extract from content.xml, used
aa and bb as marker around)::
<text:p text:style-name="P25">aa</text:p>
<text:p text:style-name="P23">
<text:placeholder text:placeholder-type="text"><content
text:p="item.text"></text:placeholder> </text:p>
<text:p text:style-name="P28">bb</text:p>

... I get this result::

<text:p text:style-name="P25">aa</text:p>
<text:p text:style-name="P23">
<p align='center'><span font_family='Monospace'
size='27'>My Rich Text</span></p> </text:p>
<text:p text:style-name="P28">bb</text:p>

I think to solve this, it is needed to write a xslt converter for
relatorio, to convert the tryton-richtext-widget-language to open
document format.

Regards Udo

Cédric Krier

unread,
Oct 1, 2015, 10:15:03 AM10/1/15
to try...@googlegroups.com
On 2015-10-01 15:01, 'Udo Spallek' via tryton wrote:
> I think to solve this, it is needed to write a xslt converter for
> relatorio, to convert the tryton-richtext-widget-language to open
> document format.

OK, let's bring this to https://bugs.tryton.org/issue2068

Diego Abad

unread,
Nov 24, 2015, 10:33:33 AM11/24/15
to tryton, tryton-...@googlegroups.com

Udo Spallek

unread,
Nov 25, 2015, 1:02:38 PM11/25/15
to try...@googlegroups.com
Hello Diego,

Tue, 24 Nov 2015 06:29:26 -0800 (PST)
Diego Abad <daba...@gmail.com>:
thanks for sharing your idea. It looks interesting.
The former idea using XSLT would have the limitations, a. that it is
another additional technology and b. AFAIK limited to XML-like
transitions.

With a python parser we would be able to produce other outputs than
html or odf, maybe simple text, markdown or RestructuredText if one
likes...

Best, Udo Spallek
Reply all
Reply to author
Forward
0 new messages