This question has been flagged
1 Reply
7196 Views

Hello everyone, is it possible to have a domain in a one2many field? I mean, in a "purchase.order" there is a fields called 'state' of type selection and in "stock.picking.in" there is al

so a selection field called state. In purchase.order view i define my field as something  like this:

<field name="spicking_ids" domain="[('spicking_ids.state','!=','done')]"/>
and upon running, it still displays all picking_ids including those are done. Any help is much appreciated.

Avatar
Discard
Best Answer

@Anirudh, yes it is possible though it cannot domain on child field.  If you want to domain based on the spicking_ids' state, just use [('state','!=','done')] for the domain.

Avatar
Discard
Author

Ok, Thanks sir. I have tried [('state','!=','done')] on the domain but it still appears all lists including those are in a done state.

Is it possible for you to post the definition of spicking_ids field?

Author

from purchase.order i define spicking_ids as follows: 'spicking_ids' : fields.one2many('stock.picking','purchase_id','Product to receive')

Can you try specifying it as 'spicking_ids' : fields.one2many('stock.picking','purchase_id','Product to receive', domain=[('state','!=','done')])? I think the domain in XML will be used only when adding.

Hi, Ivan

Author

I have already tried it but still it didn't work.

Have you check using Developer's Mode if the view is loaded properly and that you are using the correct view? Does your view XML had noupdate="1" set? Check from Settings >> Technical >> User Interface >> Views menu if your view is loaded. My current suspicion is basically either the view is not loaded or the view selected is not the view that you define. Also, the field state of stock.picking need to be in the view as well (it can be invisible).