تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7686 أدوات العرض

Hi friends,

I have defined a string variable 'desc' as below:

'desc': fields.char('Description', size=50),

Now i can enter upto 50 chars in form. But i have set limit only for 20 chars when displays this field in report.Give me python methods to solve this.Thanks

الصورة الرمزية
إهمال
أفضل إجابة

Hi Vadivel,

It is simple because string is allowed subscripting ([ ]) in python. So, according to that your requirement will be fulfill as like below.

As your field named "desc" will take 50 characters and you want print only 20 in report. Just make this line inside your report, requirement will fulfill.

1) object.desc[0:20] #It will only takes 20 character from desc field.
2) object.desc if len(object.desc) < 20 else "%s..." %(object.desc[0:18])

I hope you will get what you want.

Thanks.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
7
يوليو 20
90081
2
مايو 22
34579
0
مارس 19
4455
0
يناير 19
5535
4
فبراير 24
12848