Community mailing list archives

community@mail.odoo.com

Re: Domain for Many2one on onchange

by
ich
- 06/07/2016 08:39:28
Does this work when the form gets loaded too?
Afaik it didn't, my workaround was using a context variable and overwriting the
search/name_search method to limit available values

> @api.one
> @api.onchange('req_from', 'req_to')
> def vehicle_filter(self):
>     fleet_req_obj = self.env['fleet.requisition']
>     requisition_search =
> fleet_req_obj.search([['req_from','=',self.req_
> to]])
>     vehicle_models = []
>     for i in requisition_search:
>         vehicle_models.append(i.vehicle_rq.id)
> 
>     res = {}
>     if vehicle_models:
>         res['domain'] = {'vehicle_rq': [('id', '=', vehicle_models)]}
>     return res
> 
> 
> Regards,
> -- 
> MD. Tanzilul Hasan Khan.
> _______________________________________________
> Mailing-List: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe
> _______________________________________________
> Mailing-List: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe