Community mailing list archives

Domain for Many2one on onchange

Md. Tanzilul Hasan Khan
- 06/04/2016 08:43:04
Hello Community,

I am trying to filter values for a Many2one field on onchange function. But it isn't working. 

My goal is to filter vehicle on a given date. I am getting values from the ORM. Like after searching I am getting 13 in the vehicle_models list. But the domain isn't working.

I have tried various ways by searching in odoo forum and stack overflow. There is no problem with my values but the Domain isn't working. Can anyone please help me with this or let me know what I am missing? My onchange code is below -
@api.onchange('req_from', 'req_to')
def vehicle_filter(self):
fleet_req_obj = self.env['fleet.requisition']
requisition_search =[['req_from','<=',self.req_from],['req_to','>=',self.req_to]])
vehicle_models = []
for i in requisition_search:

res = {}
if vehicle_models:
res['domain'] = {'vehicle_rq': [('id', '=', vehicle_models)]}
return res

MD. Tanzilul Hasan Khan.