1

I want to set a limit to the number of Characters displaying in the tree view by 60, that comes from the field "Description" in the project module. But just limit the characters that display in the tree view NOT limit the input of the field.

would that be possible? with an attribute in xml? or directly using custom css or js

enter image description here

<xpath expr="//tree[1]/field[@name='name']" position="after">
     **strong text**<field name="description" string="Comments" Limit="60"/>
</xpath>
Ron
  • 91
  • 8

1 Answers1

2

I don't think it is possible through XML, but what you can do is create a new computed field that copies the first 60 characters of the description field (in the front-end or through code, doesn't matter). It duplicates data but it will do what you want.

x_description_limited = fields.Char(compute=_compute_x_description_limited, stored=False)

@api.depends('description')
def _compute_x_description_limited(self):
    for record in self:
        if record.description:
            if len(record.description) > 60:
                record['x_description_limited'] = f"{record.description[:60]}..."
            else:
                record['x_description_limited'] = record.description
        else:
            record['x_description_limited'] = False
Lenormju
  • 4,078
  • 2
  • 8
  • 22
adekock11
  • 544
  • 2
  • 11