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

DOMAIN FUNCTION ISNT WORKING

By
Phillip
on 4/21/15, 1:17 PM 639 views

I am trying to use a method to return my domain. Any advice?

Not working this way.

The client_id and client_id.id both return integers. When I hard code an example such as 

domain="[('client_id.id','=', 5)]"

Everything works. I think it is an encoding thing or formatting issue of what I am returning. 

#################################

#################################

@api.model

def _getClientId(self):

    client_id = self.client_id.id

    domain = "[('client_id.id','='," + " " + str(client_id) + ")]"

    return domain

selected_review = fields.Many2one('something.something', domain=_getClientId)

The last character ) in domain=... is probably redundant?

zbik
on 4/22/15, 3:45 AM

You are right. That may have been a residual typo. Thank you for letting me know. I turned out to be the id's I was using were not the correct ones.

Phillip
on 4/22/15, 11:32 AM
0
Phillip
On 4/22/15, 11:31 AM

Alright. So here is what worked for me in the end. 

#####################

@api.model

def _getClientId(self):

    if len(self.search_read([],[])) == 0:

        return [('client_id','=','client_id')]

    else:

        client_id = self.search_read([],['id'])[0].get('id')

        domain = "[('client_id','='," + " " + str(client_id) + ")]"

        return domain

selected_review = fields.Many2one('sentry.review',

domain=_getClientId,

string="Selected Review")

####################################

The issue is that I was referring to the wrong id.

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

1 follower(s)

Stats

Asked: 4/21/15, 1:17 PM
Seen: 639 times
Last updated: 4/22/15, 11:32 AM