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

Hi friends,

I tried to update context in Odoo8 API i got below error and i also try to update self.with_context but it not display when i print self._context.

So i want to know what is difference between self.with_context and self._context?

Any have solution for below error?

File "/home/workspace/erp/openerp/addon/training/registration.py", line 106, in action_open_survey
    self._context['survey_token'] = response_id.token
  File "/home/workspace/erp/openerp/tools/misc.py", line 1250, in __setitem__
    raise NotImplementedError("'__setitem__' not supported on frozendict")
NotImplementedError: '__setitem__' not supported on frozendict

 

Thanks in advance

 

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

you can try this : 

new_context = dict(self.env.context).copy()

new_context.update( { 'Key' : Value } )

and pass new_context in function...

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

in case of that error you can update context like:

dict(context).update({'key' : value})
Ảnh đại diện
Huỷ bỏ

That doesn't work. The change doesn't show up in the dict but the error message neither.

Are you sure that this doesnt work? context=dict(context) context.update({'key' :value}) before using context in a function.

Câu trả lời hay nhất

Hi..

in odoo-7 i used to add in xml file like this..

<field name="pricelist_id"  context="{'prod_id': product_id,'c_id':id}" options='{"always_reload": True}' on_change="onchange_price(product_id,pricelist_id)" />

it works good.....

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

Thanks for your answer anand :) can you please explain in brief? Ans i am using odoo8 api to update context in .py file not in xml because of business login.

have u seen this.. https://www.odoo.com/forum/help-1/question/whats-the-context-2236

Tác giả

Hi anand, i seen that one i tried that one but still i got error msg.

post the code which throws error...

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 15
3658
2
thg 5 15
4586
1
thg 3 15
3571
1
thg 3 21
9194
0
thg 4 20
2694