We have a field "picking_type" on stock.picking model.
I want to apply domain on "product_id" which is inside the "move_lines" field (as we know move_lines is o2m).
Explanation:
When ever there is a change in operations type(picking_type) while creating a transfer a domain shall be applied on product_id field in the move lines of transfer(stock.picking) object and i shall be able to select only the limited products i want.
I have set a field on product form which links the operation type with the product.
Here is My code:
@api.onchange('picking_type_id')
def onchange_picking_operation_type(self):
product_template_ids = self.env['product.template'].search([('picking_type_code', '=', self.picking_type_id.code)])
product_product_ids = self.env['product.product'].search([('product_tmpl_id', 'in', product_template_ids.ids)])
_logger.info('----------------Products-----------------'+ str(product_product_ids))
return {'domain': {'move_lines': [('product_id', 'in', product_product_ids.ids)]}}
Am able to view the list of product ids clearly in logs but somehow the domain is not working. Can anyone point out how to implement the domain on a many2one field inside the one2many object??
Odoo Customization Tips: https://www.scoop.it/t/learn-openerp