As the below code achieves the dynamic domain condition, this is what i want to achieve but this will get the Deprecation Warning in odoo v16, so if anybody knows the solutions that achieves similar functionality. Please comment it.
@api.onchange('customer', 'picking_type_code')
def _onchange_customer(self):
if self.picking_type_code == 'outgoing' and self.customer:
return {'domain': {'move_ids.product_id': [('picking_id.picking_type_code', '=', 'incoming'), ('picking_id.customer', '=', self.customer)]}}
else:
return {'domain': {'move_ids.product_id': []}}