String function in qweb template odoo

I want to show data with specific length in qweb template and more data would be replaced by ...

i.e Name = "Administrator"

and if I want to show only first five char then,

"Admin..."

I have google about this topic but no luck, and no such documentation related to that.

Any help would be appreciated.

Upvotes: 2

Views: 4571

Answers (1)

DASADIYA CHAITANYA
DASADIYA CHAITANYA

Reputation: 2892

Create a custom function on parser report class

def cal_string(string):
    if len(string) >5
        val=string[:5]+'...' 
    else: 
        val=string
    return val

Call the function into Qweb Template

 <field t-esc="cal_string(string)" />

I hope my answer may helpful for you :)

Upvotes: 1

Related Questions