Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8566 Lượt xem

Hello,

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 ?

Thanks

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
4170
3
thg 7 25
2760
1
thg 1 25
1280
1
thg 10 24
1970
1
thg 4 24
2015