Community mailing list archives

community@mail.odoo.com

Re: Domain for Many2one on onchange

by
Md. Tanzilul Hasan Khan
- 06/05/2016 00:33:28
Thank you Pedro. It is working :) .

Thank you Gustavo. Yes, I know it will be 'in' or 'no in' in case of list. I was testing it with passing static ids.

Regards.

On Sun, Jun 5, 2016 at 3:47 AM, Gustavo Marino <gamarino@numaes.com> wrote:
And if you want to limit to a list of ids,  the domain should be like {'vehicle_rq': [('id', 'in', vehicle_models)]}

Gustavo Adrian Marino

 

Mobile:  +54 911 5498 2515

Email: gamarino@numaes.com

Skype: gustavo.adrian.marino

 

Descripción: Numa Logo V 1-0



2016-06-04 10:57 GMT-03:00 Pedro Manuel Baeza Romero <pedro.baeza@gmail.com>:

Don't put @api.one, but @api.multi, because the return value is enclosed in a list, and thus, not parsed.

Regards.

El 04/06/2016 14:47, "MD Tanzilul Hasan Khan" <ponkhi403@gmail.com> escribió:
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.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_from],['req_to','>=',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


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
MD. Tanzilul Hasan Khan.