Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
35106 Переглядів

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
21505
1
бер. 23
2312
0
лист. 16
2465
1
трав. 18
6127
0
груд. 24
973