Odoo Help

0

How to replace carriege return \n or \r or both into html <br> in a qWeb pdf report? (Odoo9)

By
Andreas Jonderko
on 8/17/16, 2:28 PM 697 views

In an sale order we have the possibility to enter some line feeds or carriege return signs. In the preview, you can see it in Odoo, but on the pdf generation, the signs are ignored. 


What i tried is:

<t t-set="temp_name" t-value="temp_name.replace('\n','&#13;')"/>

<t t-esc="temp_name"/>

but this produces an exception:



  File "/home/odoo/src/odoo/9.0/openerp/tools/safe_eval.py", line 296, in safe_eval
    c = test_expr(expr, _SAFE_OPCODES, mode=mode)
  File "/home/odoo/src/odoo/9.0/openerp/tools/safe_eval.py", line 153, in test_expr
    code_obj = compile(expr, "", mode)
QWebException: EOL while scanning string literal (, line 1)
1
Ray Carnes
On 8/17/16, 3:45 PM

Have you seen and tried https://www.odoo.com/forum/help-1/question/webkit-line-returns-for-text-fields-11072 ?

-------------------------------------------------------------------------------------


${note | carriage_returns} is what you looking for

with:

    <%
    def carriage_returns(text):
        return text.replace('\n', '<br />')
    %>

at the start of the document

Thank you very much, I tried this, but get also an exception on inserting the definition. Where exactly can I put this definition?

gastronovi GmbH & Co. KG, Andreas Jonderko
on 8/17/16, 3:47 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 8/17/16, 2:28 PM
Seen: 697 times
Last updated: 8/18/16, 1:59 AM