Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to use a var from another model in domain?

By
Bonnet Denis
on 4/8/13, 2:26 PM 2,995 views

I want to see all event/meeting where "user_id==uid" and "uid.name == partner_ids"?

I try to create a new filter :

domain=[|,('user_id','=',uid),('partner_ids','ilike',uid.name)]

But uid.name is not a variable. I try "uid.name", uid.name , "user_id.name" , user_id.name and domain="[('partner_ids','ilike',self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id.name)]" but no one work.

I think I'm misunderstanding the right way to use domain field, not just in search view.

How can I use a var that is not a field of model but from database like res_users.name or res_users.partner_id.name ?

0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/19/13, 8:05 AM

You can't use the dot notation in the domain. If you need to know che partner name, you must insert a related field in your classe (with store=True) and search the value in this one.

domain=[|,('user_id','=',uid),('partner_ids','ilike',your_related)]

Thanks but the related field depend of the current user. I can't store this. I edit my post with this: domain="[('partner_ids','ilike',self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id.name)]" Is it possible to have a var like this in a domain? Or maybe I 've to use a context but I don't know how.

Bonnet Denis
on 4/19/13, 8:09 AM

What kind of field is partner_ids? a one2many? What table point to?

Francesco OpenCode
on 4/19/13, 8:10 AM

In the xml view you can't use ORM method. So, self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id.name can't work in your case.

Francesco OpenCode
on 4/19/13, 8:13 AM

it's a many2many field. it point to crm_meeting_partner_rel table. If I set ('partner_ids','ilike','paul') I've the right filter.

Bonnet Denis
on 4/19/13, 8:15 AM

If you use domain=[|,('user_id','=',uid),('partner_ids','=',uid)] it works?

Francesco OpenCode
on 4/19/13, 8:24 AM

No, I've this error : "TypeError: results.group_by is undefined"

Bonnet Denis
on 4/19/13, 8:29 AM

Maybe domain=[|,('user_id','=',uid),('partner_ids','in',uid)] can works

Francesco OpenCode
on 4/19/13, 8:32 AM

no, I've the same error. Thanks a lot for trying to help me.

Bonnet Denis
on 4/19/13, 10:44 AM

There isn't document about it. This is the only link in the internet world...:D http://mohsinpage.wordpress.com/2011/09/29/openerp-many2many-domain-filtering-example/

Francesco OpenCode
on 4/19/13, 11:14 AM

I will try this solution.

Bonnet Denis
on 4/19/13, 11:34 AM

thanks for the link, can you post it as an answer to validate the solution?

Bonnet Denis
on 5/16/13, 6:05 AM

thanks for the link, can you post it as an answer to validate the solution?

Bonnet Denis
on 5/16/13, 6:07 AM

thanks for the link, can you post it as an answer to validate the solution?

Bonnet Denis
on 5/16/13, 6:07 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/8/13, 2:26 PM
Seen: 2995 times
Last updated: 3/22/16, 4:56 AM