This question has been flagged

Hi,

i've just created a model like this:


    _name = 'sale.order.package'


    name = fields.Char(string='Package Name', readonly=True, copy=False)

    weight = fields.Float()

    sale_order_id = fields.Many2one('sale.order')

    picking_id = fields.Many2one('stock.picking')


And in sale.order form, i've created a new tab (page) in order to create the package. When creating a new package from a Sale Order, i can set by default the current sale.order id with "context", but i don't know how to apply a domain in the picking_id field. I mean, when creating a package, i would like to display the picking_ids related to my sale.order, not all picking_ids. How could i do that? I'm triying with "domain" but it doesn't work:

 

                    <field name="package_ids"

                           widget="one2many_list"

                           domain="[('picking_id', 'in', picking_ids.ids)]"

                           context="{'default_sale_order_id': active_id}">

                        <tree>

                            <field name="name"/>

                            <field name="weight" sum="Total weight"/>

                            <field name="picking_id"/>

                        </tree>

                    </field>

Avatar
Discard
Best Answer

The problem is the TYPE in domain.  

picking_id is a recordset.

picking_ids.ids I don't think such thing exists.

picking_ids itself being a one2many field should already be a list consist of integer numbers (the ids).  


picking_id.id will give you the id number of the recordset.  

Try domain="[('picking_id.id', 'in', picking_ids)]"

Avatar
Discard