Odoo-mobile / framework

Odoo Mobile Framework
https://play.google.com/store/apps/dev?id=8607973775002477408
Other
327 stars 374 forks source link

How to set domain on Many2One related to another Many2one #294

Open jzahid opened 7 years ago

jzahid commented 7 years ago

Hi all. I have this situation. I have three models all linked by a Many2one columns Attendance > Employee > Ressource I can retrieve only active employees, by setting a domain filter on resource_id column in my Employee model.

OColumn resource_id = new OColumn("resource_id", HrResource.class, OColumn.RelationType.ManyToOne).addDomain("active","=",true);

But now i want to retrieve only attendance of only active employees ( records that match previous domain). How can i achieve that on Attendance model ?

Thanks

jzahid commented 7 years ago

Hi all , nay advice about this @dpr-odoo i am tryning to fetch attenancde for active employee only. For Employee : OColumn resource_id = new OColumn("resource_id", HrResource.class, OColumn.RelationType.ManyToOne).addDomain("active","=",true);

It s working correctly. But when i add domaine on attendance OModel class like this :

OColumn employee_id = new OColumn("Employee", HrEmployee.class, OColumn.RelationType.ManyToOne).addDomain("resource_id.active","=",true);

I t has no effect, and my app still fectching attendances for archived employees.

What's the correct way to set this fliter ?

sehrishnaz commented 6 years ago

Try this one

student_id= fields.Many2one('student_model','Student',domain="[('session_id','=',session_id)]",default=default_student)

Here ('session_id','=',session_id) session_id on the right hand side is another model many2one field. For more detail: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html