2
votes

How reduce string length in qweb?

Example:

<p t-field="doc.name" />

return stackoverflow I want remowe last 8 character and get stack

3

3 Answers

7
votes
<p><t t-esc="doc.name[:-8] if doc.name else ''"/></p>
1
votes

For string you can use this:

<p><t t-esc="doc.name[:-8] if doc.name else ''"/></p>

For float value try this one:

<p><t t-esc="'%.2f'%(t.amount)"/></p>

This will print value to exactly two decimal places

1
votes

For "char" came from DB (just this works for me, Odoo V11)

<p><span t-if="doc.name" t-esc="str(doc.name)[:-8]"/></p>