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.

1

how to put domain on field

By
Aijay Ogbugha
on 7/25/13, 6:21 AM 1,047 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?

1

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, 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

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

0 follower(s)

Stats

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