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

I'm trying to update context from within class DataSet(http.Controller) (web module)


I want the do_search_read method to change the context of the caller. However, although everything seems to be fine, the context is not updated.


Here's my code:


if model == 'mymodel':

     request.context['result_ids'] = [x.product_tmpl_id.id for x in Model.browse(aux)]

 

request.context is, indeed, updated but the caller's context remains the same.

아바타
취소
작성자

NOTE: I've already tried the "antidote" to the "frozen dictionary" problem.

The code here is just that an example.

베스트 답변

Hello Rui Franco

context is a frozen dictionary. so, we can not directly change.

you can try this.    

     request.with_context({'result_ids':[x.product_tmpl_id.id for x in Model.browse(aux)]})


Hope this help.

아바타
취소
작성자

Thanks but it won't work:

AttributeError: 'JsonRequest' object has no attribute 'with_context'

베스트 답변

ctx = dict (request.context)


ctx.update ({'bin_size': True})


request.context = ctx


Thats it!!

아바타
취소

ctx = (request.context.copy())

ctx.update(lang=ticket.partner_id.lang)

request.context = ctx

관련 게시물 답글 화면 활동
0
7월 17
3240
0
3월 15
2975
2
3월 15
17214
0
9월 17
10699
2
7월 25
1365