Odoo Help


How to require all fields?

Jeff Beidler
on 11/5/14, 7:41 PM 1,780 views

I have a simple 3-field form, and I want to make all fields required.  I have tried this:

<field name="name" required />

(Invalid XML)

and this:

<field name="name" attrs="{'required': [('id', '!=', False)]}" />

which gives this error:

Error: Unknown field id in domain [["id","!=",false]]

Every record gets an id on creation, right?  So shouldn't the second version work?  How do you make a field required at all times?

On 11/5/14, 8:33 PM

Hi Jeff,
Have you tried following approach

<field name="name" required="1"/>

Hope this helps :)


This works, thanks! Too bad the Odoo documentation didn't have better examples.

Jeff Beidler
on 11/6/14, 11:34 AM
On 11/6/14, 12:18 AM

Add as show below

<field name="name" required=True />


and then convert to this as a answer......thanx

This gives an error. However, if you enclose "True" in quotes, it will work. Could have sworn I tried this yesterday, but it had no effect. Must be a cache thing. I restarted the server with -u and -d options to update the module and database, but, apparently, you still need to navigate to a different section of the application and come back in order to see the changes sometimes.

Jeff Beidler
on 11/6/14, 11:33 AM

i will do like this and its works for me....

on 11/6/14, 11:41 PM

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 5 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 11/7/14, 12:13 AM

To make a field required, you can achieve by 2 methods:

    _columns = {
      'name': fields.char("Name",size=64,required=1),

2. WITH XML: (Same as Jeff's Suggestion)
         <field name="name" required="1"/>

NOTE: If we make the field required at PYTHON file, no need to add required at XML.

Error: Unknown field id in domain [["id","!=",false]]:
          A domain can be set for the fields that are displayed on its own view.

If you are trying to use domain = "[('categ_id','=',False)]", then 'categ_id' field should be available in their respective FORM/TREE view.

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

1 follower(s)


Asked: 11/5/14, 7:41 PM
Seen: 1780 times
Last updated: 3/16/15, 8:10 AM