I wanted to set the first line of the product description to BOLD so I added the following code to my model
@api.multi
def setFirstLineBold(self,txt):
# code magic to set first line bold
return txt
@api.multi
def render_html(self, docids, data=None):
report = self.env['report']._get_report_from_name(self._template)
docargs = {
'doc_ids': self._ids,
'doc_model': report.model,
'docs': self.env['sale.order'].browse(self._ids),
'setFirstLineBold': self.setFirstLineBold
}
return report_obj.render(self._template, docargs)
I then called the method inside my template
<t t-foreach="layout_category['lines']" t-as="l">
<tr class="table-body">
<span t-esc="doc.setFirstLineBold(l.name)"/></td>
But what happens then is actually exactly the opposite of what I want to achieve: The formatting that previously existed in the description text (the line breaks), which were previously shown with line breaks in the printed pdf-report, has been completely removed.
Now my question: How can I create formatting for the description text? I just want to make the first line bold.
It looks like the linebreaks will not be recognized as such or will be removed.
Unfortunately, the debugging seems impossible (not really, but extremly complicated) as I develop inside a docker container - I'm new to Odoo development, if someone gives me a tip here - thank you!
Thanks a lot!
EDIT: I already found out that this works:
@api.multi
def setFirstLineBold(self,txt):
txt = txt.replace('\n', '<br/>')
return txt
but the HTML is not interpreted, so it only shows <br/>
instead of ‘\n’ inside the description part of the PDF.
RAW works - thanx @Jainesh!