Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6448 มุมมอง

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
4135
3
เม.ย. 19
6832
Change field alignment(Vertical) in view แก้ไขแล้ว
1
ม.ค. 24
13663
2
ส.ค. 22
20372
5
ก.ค. 15
7686