Odoo Help

1

How to filter data in a one2many fields?

By
Anirudh Lou
on 12/22/14, 2:47 AM 933 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.

1
Ivan
On 12/22/14, 5:34 AM

@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.

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

Anirudh Lou
on 12/22/14, 8:19 PM

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

Ivan
on 12/23/14, 12:07 AM

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

Anirudh Lou
on 12/23/14, 3:28 AM

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.

Ivan
on 12/23/14, 7:08 AM

Hi, Ivan

Baiju KS
on 1/6/15, 4:00 AM

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

Anirudh Lou
on 1/6/15, 4:16 AM

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).

Ivan
on 1/6/15, 4:50 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.

Register

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

1 follower(s)

Stats

Asked: 12/22/14, 2:47 AM
Seen: 933 times
Last updated: 3/16/15, 8:10 AM