I have defined product_id
in the class sale_order_line
as below:
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
def _get_product_ids(self):
return [('sale_ok', '=', True), ('state', 'in', ['sellable', 'custom']), ('id', '=', )]
_columns = {
'product_id': fields.many2one('product.product', 'Product',
domain=_get_product_ids,
change_default=True),
}
The form view of sale.order
has the below snippet where product_id
is shown:
<field name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}"
groups="base.group_user"
on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, False, product_uos_qty, False, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
Initially in Sale Orders(model: sale.order)
I select pricelist_id
field. And then I click on 'Add an item' in Order Lines section to add a sale order line. In the form view of sale.order.line
, I need to only show the products in the product_id
based on the pricelist_id
I selected earlier.
In product.product
class the pricelist_id
is a "dummy" field. So I am not able to figure out how to add domain filter since it will always return null value.
Could you please help me how to apply hard filter on product_id
many2one field to show only the products based on selected pricelist_id
in parent class?