Odoo Help

Welcome!

This community 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.

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 238 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

--Ray Carnes--
15677
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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