Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
8605 มุมมอง

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

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

try:
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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 15
4201
3
ก.ค. 25
2794
1
ม.ค. 25
1323
1
ต.ค. 24
2034
1
เม.ย. 24
2059