Odoo Help


only number in value of char [Closed]

on 12/23/14, 12:44 AM 1,276 views

The Question has been closed

on 01/21/2016 23:17:51

i have a field with type char i want this field only have number value

for example : 023455

how can i make it?

Bole, what about the Help attribute ?

Gopalakrishnan Kasilingam
on 12/23/14, 5:29 AM

Anil R. Kesariya

--Anil R. Kesariya--
| 6 5 8
Rajkot, India
--Anil R. Kesariya--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Anil R. Kesariya
On 12/23/14, 1:02 AM

Hello Susi ,

You have three option you can use

constraints or on change method.


Eg. 1) by using widget (as Ben Bernard said):

in  your xml file inside form view.

<field name="your_field" widget="integer"/>


Eg. 2) by using constraint.

#by using constraint you can raise your own warning message on the screen if user enter the #wrong value.

_columns = { 'your_field':fields.char('Your Field Label')}

def check_numval(self, cr, uid, ids, context=None):

    for obj in self.browse(cr, uid, ids, context = context): 

        val = obj.your_field

        if val.isdigit():

            return True


            return False

_constraints = [(check_numval, 'Enter Value is not correct!', ['your_field']), ]


#like wise you can apply in onchange method, you can is isdigit() method to check entered value.

Hope this will helps you.

thank u Anil Kesariya its work :)

on 12/23/14, 1:24 AM

if i want two field with using constraint,,how i make it?

on 12/23/14, 1:27 AM

you can use the same method check for both the field in condition simple, pass both field as argument in list.

Anil R. Kesariya
on 12/23/14, 1:46 AM



| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 12/23/14, 5:21 AM

and you can use onchange method like

in xml: 
<field name="field_name" on_change="check_numeric(field_name)" />

def check_numeric(self, cr, uid, ids, value, context=None:
       test = int(value) #->be creative with check... this is basic
        return {'warning':{'title':'error','message':'value should be numeric'}}
    return True

hope it helps




Ben Bernard

--Ben Bernard--

| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 12/23/14, 5:35 AM

You can also use attribute integer widget in the field: widget="integer"

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 12/23/14, 12:44 AM
Seen: 1276 times
Last updated: 1/21/16, 11:17 PM