콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
47707 화면

hello I try to add new values in the context with the new api but after many try we did'nt sucess.

What we have try :

self.with_context(get_sizes=True)
print self.env.context
self.with_context({'get_sizes': True, 'free_ref': free_ref}) 
self.with_context().create(get_sizes=True)
아바타
취소

you can use

self.with_context(key='value').do_something

for old version 

self._context.update( { 'key': 'val' } ) 

or  

self.env.context.update( { 'key': 'val' } )

that will add values in context 


베스트 답변

Try this:

 self = self.with_context(get_sizes=True)
print self.env.context

or

self.with_context(get_sizes=True).create()

아바타
취소
작성자

This works ! self = self.with_context(get_sizes=True) Thank you very much !

베스트 답변

@Mohit, that's not true.  As of Odoo 11 anyway, a context is a Python frozendict, which cannot be updated.

And even if you were to do something like:

 self.env.context = dict(self.env.context)
self.env.context.update({'key': 'val'})

the effect would only affect the context associated with recordset passed to the method where this code appears.

아바타
취소
관련 게시물 답글 화면 활동
1
12월 17
5929
3
4월 17
24552
1
1월 25
1513
0
7월 22
2544
1
11월 21
6210