在查看模式下,openerp字段丢失上下文 [英] openerp when in view mode fields lose context

查看:65
本文介绍了在查看模式下,openerp字段丢失上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表单"A"上单击"Many2One"字段时,我想打开特定的表单"B". 我通常将这个字段放在上下文中

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'

但这仅在"A"处于编辑模式时有效.如果它处于查看模式,则将打开"C"窗体.我注意到JSON请求只是丢失"了我设置的上下文,并发送了标准的空字段(仅包含时区/uid等)

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?

推荐答案

@Alessandro Ruffolo,

@Alessandro Ruffolo,

context在服务器客户端之间是可变的,并且context具有通用属性,例如uid,active_d,active_ids,active_model,用户时区和用户lang.调用ORM方法时,您可能已经有一个上下文-例如,框架将为您提供一个几乎所有方法的参数.

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.

如果确实有上下文,则务必始终将其传递给调用的每个方法,这一点非常重要.但是,当您不在python或js中的任何方法上的任何地方传递上下文时,客户端服务器会生成新的上下文,而它们在核心代码中的位置已经很旧了,上下文会因不传递而被破坏. 当您不传递上下文时,它将破坏上下文并准备新的上下文.

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.

使用新的v8 API上下文更加一致,因为这不是必需的.

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

最佳

这篇关于在查看模式下,openerp字段丢失上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆