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

Hello Everyone,

How to pass value(information) in context to access the information passed in conext to callable method?

For Example:

I have called write method of X object and i want to pass the extra value in context within write method.

So, I can get the passed the value vai context in overriden write method of X object.

How Can I achive this via v8 API Coding stndard?

Regards,

Anil.


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Hi Everyone,

Here is the solution for this.

You can use with_context  to achive this.

For Eg:

I have browse records for Y object and Now i am calling the write method of relation field of Y object which is X.

In simple term I have SO object and Partner object.

I have order (sale.order) browe record now I want to update the value of partner so I can directly update the value of partner using order

syntaxt :order.partner.with_context(key=value).write({'field':latest updated value.})

EG: sale_order.partner_id.with_context('abc':True).write({'email':'anil.r.kesariya@gmail.com'})

Now, write method of partner will be called and use can access the value from context in overriden write method of partner. which is passed using with_context.

you can get the context value in overriden write method like this

@api.multi


def write(self, vals)

----------------

res = super(res_partner, self).write(vals)

self._context.get('abc')

-------------------

return res

Regards,

Anil




อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 24
1576
1
ก.พ. 22
3543
1
ก.พ. 22
6307
0
พ.ย. 21
3973
3
ธ.ค. 17
11190