Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
6322 Widoki

I'm working on a tree view and would like to limit the total possible characters returned on <field name="origin"/>.

Is there a very simple way to accomplish this? Due to automatic procurement rules, some of my fields have become very long and mess up the tree views.

Awatar
Odrzuć
Najlepsza odpowiedź

You could create a computed display_origin and then use this field in your tree, using something like the following (obviously change the numbers to whatever length you want):

display_origin = fields.Char(string='Origin', compute='_compute_display_origin')
@api.depends('origin')
@api.onchange('origin')
def _compute_display_origin(self):
     for rec in self:
         rec.display_origin = (rec.origin[:48] + '..') if len(rec.origin) > 50 else rec.origin
Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

There are multiple ways to achieve that but I would prefer if you can overwrite read method & then you can restrict no. of characters then it would be good & it will work.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sty 21
4019
3
kwi 19
6673
1
sty 24
13562
2
sie 22
20267
5
lip 15
7528