Skip to Content
Menu
This question has been flagged
2 Replies
13465 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)
Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

Best Answer

An EOL ( End of Line ) while scanning string literal error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error . Reasons:

  • Missing quotes

  • Strings spanning multiple lines

Strings can't normally span multiple lines. If you don't want the string to appear on multiple lines but you want to initialize it on multiple lines (so you can read it more easily), you can "escape" the newline by putting a backslash before the newline. If you want it to appear on multiple lines, you can use triple quotes around the string. Python is particularly prone to this type of error, since Python ends statements with newlines/line breaks , whereas most other programming languages have a character such as a semicolon (:wink: , which means that other programming languages work more easily with multi-line statements out of the box.

http://net-informations.com/python/err/eol.htm

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 21
804
2
Apr 20
9530
0
May 24
1318
2
May 24
2841
3
Feb 24
2462