Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
35163 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Atul It's an easy solution..

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

The size attribute is also availbe for integer fields!

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

 

Regards.

Ảnh đại diện
Huỷ bỏ

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
6
thg 3 24
21524
1
thg 3 23
2324
0
thg 11 16
2474
1
thg 5 18
6145
0
thg 12 24
982