Odoo Help

Welcome!

This community 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.

0

How to require all fields?

By
Jeff Beidler
on 11/5/14, 7:41 PM 926 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?

1
Petar
On 11/5/14, 8:33 PM

Hi Jeff,
Have you tried following approach

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

Hope this helps :)


Cheers,
Petar

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

Jeff Beidler
on 11/6/14, 11:34 AM
1
LIfe
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....

LIfe
on 11/6/14, 11:41 PM
0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 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:

1. WITH PY:
    _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.
 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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