Odoo Help


how to put domain on field

Aijay Ogbugha
on 7/25/13, 6:21 AM 1,573 views

Hey guys, I want a field to show only products that have more than one quantity available for selection. please how do i implement this?? Please I need your help urgently. Thank you

Below is the field on my python file: 'my_product_id': fields.many2one('product.product', 'Product', required=True, select=True) And the same field in my xml file: <field name="my_product_id" domain="[('my_product_id','=','qty_available > 0')]" on_change="onchange_my_product_id(my_product_id)"/>

Please what am I doing wrongly?


Daniel Reis

--Daniel Reis--
| 7 8 9
Linda-a-Velha, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt

Daniel Reis
On 7/25/13, 6:56 AM

You mean "more than one unit available" (qty>1) or "at least 1 available" (qty>0) ?

The domain expression applies to the related model. You can try:

<field name="my_product_id" domain ="[('qty_available', '>', 0)]"  on_change="onchange_my_product_id(my_product_id)"/>

Thank you for your response. but it didn't work. it showed all the products(even the ones that have finished) and that is not what I want. "my_product_id" field is a related field to product object. So what I want is that only the products whose quantity is greater than 0(i.e products that are available) will show for selection in this field. How can I include this domain in this field? Thank you

Aijay Ogbugha
on 7/25/13, 7:47 AM

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

0 follower(s)


Asked: 7/25/13, 6:21 AM
Seen: 1573 times
Last updated: 3/16/15, 8:10 AM