Odoo Help


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.


How to pass context values to _constraints methods via XMLRPC calls ?

Henri-Maxime Ducoulombier
on 11/5/14, 4:42 AM 1,217 views


I have a _constraint defined with a method :

def _check_me(self, cr, uid, ids, context=None):

context = context or {}

print context


_constraints = [(_check_me, 'This is my validation error message', ['field_name'])]

I call the write method on my object using XMLRPC like this, with a context :

socket.execute(db, uid, pwd, 'my_object', 'write', ids, {'field_name':field_value}, {'foo':'bar'})

And it matches the write method signature. But my context is always empty.

It is because context is not passed to methods used for _constraints ? Or am I missing something ?





| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 11/5/14, 5:22 AM

socket.execute(db, uid, pwd, 'my_object', 'write', ids, {'field_name':field_value}, context={'foo':'bar'})

Won't work. You can't actually name variables in xmlrpc calls. Besides, the context is sent to the write method. Problem is : it appears that it does propagate to the method defined in the _contraints.

Henri-Maxime Ducoulombier
on 11/5/14, 5:25 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

2 follower(s)


Asked: 11/5/14, 4:42 AM
Seen: 1217 times
Last updated: 3/16/15, 8:10 AM