Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
6340 Представления

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.

Аватар
Отменить
Лучший ответ

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
Аватар
Отменить
Лучший ответ

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.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
янв. 21
4044
3
апр. 19
6707
1
янв. 24
13579
2
авг. 22
20303
5
июл. 15
7593