openerp when in view mode fields lose context

大城市里の小女人 提交于 2019-12-24 05:33:14

问题


From a form "A" I want to open a specific form "B" when I click on a Many2One field. I placed into the context of this field the usual

'form_view_ref': 'model.form_id'

but this works only when "A" is in edit mode. If it is in view mode it opens instead the "C" form. I noticed that JSON request just "lose" the context i set and send the standard empty one (with just timezone/uid etc.)

I never realized this before. Is it some kind of bug?


回答1:


@Alessandro Ruffolo,

context is variable between server client, and context has common attributes like uid, active_d, active_ids, active_model, User timezone, user lang. When calling an ORM method, you will probably already have a context - for example the framework will provide you with one as a parameter of almost every method.

If you do have a context, it is very important that you always pass it through to every single method you call. But when you don't pass context somewhere on any method in python or js client side server will generate new context, and their are so many place with old in core code that context is broken by not passing. When you don't pass context, it breaks context and prepare new context.

With New v8 API context is more consistent as that’s not required.

Bests



来源:https://stackoverflow.com/questions/31677549/openerp-when-in-view-mode-fields-lose-context

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!