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

Is there a way to limit number of digits in integer in OpenERP like you can in char type? I need field that would only let you enter max two digits.

For example with char, you can do this:

'char_field': fields.char(size=2),

Then if you try to enter more than two symbols, it won't write it.

But if I create integer field:

'integer_field': fields.integer(),

It will let me write any number of digits I want.

อวตาร
ละทิ้ง
ผู้เขียน

Thanks Atul It's an easy solution..

คำตอบที่ดีที่สุด

You can use a _constraint to check the value of your integer and raise an exception if it is not in your desired range.

Check this blog post about how to create a constraint.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The size attribute is also availbe for integer fields!

'integer_field': fields.integer('My Integer', size=4),

 

Regards.

อวตาร
ละทิ้ง

It seems not working like Char field. Because when we use 'size' in fields.Char it won't allow more than that limit. But in Integer it allow to enter more than this limit.

So better user constraint for that specific field.

Related Posts ตอบกลับ มุมมอง กิจกรรม
6
มี.ค. 24
21510
Integer Field Converts Value to Zero แก้ไขแล้ว
1
มี.ค. 23
2316
0
พ.ย. 16
2465
increment integer for a field odoov11 แก้ไขแล้ว
1
พ.ค. 18
6132
0
ธ.ค. 24
975