Line breaks in ir.message

Hi,
I want to send an email from the code, it has a long body, and im facing a problem with the line breaks, which are being ignored.
The message is allocated at the message.xml, and I don’t know how to specify line breaks, as manually enters:

<record model="ir.message" id="message_id">
     <field name="text">line
			            break
     </field>
</record>

are just getting ignored, with \n:

<field name="text">line\nbreak</field>

The result I get is literally “line\nbreak”, and with <br/> I cannot even create the record because the tag is not supported.

to get the message im doing:
body=gettext('my_module.message_id')

How can I get the message with the correct format?
Thanks.

Hi, this way it should work

<record model="ir.message" id="message_id">
     <field name="text">line
break</field>
</record>

Not really, it does if you use this message for a warning or an error, but for an email the line break is still getting ignored

Because on email line break is <br/> and not \n which is what is stored on the message.

But for emails you should be able to write the HTML as is using a translatable report and include the report content as part of the message. You can use the get_email function to render a report as an email.

Hope this helps!

I solved it just by replacing “\n” with “<br/>”, maybe its not the correct way but its simple, in case someone faces the same problem.
Thanks for helping guys.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.