콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
35687 화면

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.

관련 게시물 답글 화면 활동
6
3월 24
21930
1
3월 23
2639
0
11월 16
2706
1
5월 18
6423
0
12월 24
1295