如何基于其他字段值更改OpenERP选择字段中的选择? [英] How can I change the choices in an OpenERP selection field based on other field values?

查看:81
本文介绍了如何基于其他字段值更改OpenERP选择字段中的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含四个字段的表单:

I have a form with four fields:

  • 作物-选择
  • 有效期自-日期
  • 有效至-日期
  • 区域-选择

如何使块区域"中的可用选项取决于用户为其他字段选择的值?

How can I make the available options in Block Area depend on the values the user selects for the other fields?

推荐答案

我不知道是否可以使用选择字段来完成此操作,但是当另一个字段发生更改时,您可以更改多对一字段的域价值.您也许还可以只使用BlockArea字段的域中的其他字段,而不必完全更改它.看看此相关问题很有帮助.

I don't know if you can do it with a selection field, but you can change the domain of a many-to-one field when another field changes value. You might also be able to just use the other fields in your BlockArea field's domain, and not have to change it at all. Look at the way the partner address screen sets the domain for the state_id field. You might find this related question helpful.

如果确实需要在另一个字段更改时更改域,请 on_change事件可以在它返回的字典中包含一个domain条目.

If you do need to change the domain when another field changes, then the on_change event can include a domain entry in the dictionary it returns.

我发现了一个讨论线程,说您可以在多对一字段,因此如果您为该字段设置domain,则可能对您有用.我自己还没有尝试过.

I found a discussion thread that says you can use the selection widget on a many-to-one field, so that might work for you if you set a domain for the field. I haven't tried it myself.

这篇关于如何基于其他字段值更改OpenERP选择字段中的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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