This question has been flagged
1 Reply
5754 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?

Avatar
Discard
Best Answer

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)"/>
Avatar
Discard
Author

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