In Odoo when you have an xpath you can add "attrs" to a field like required or invisible, when a condition is met. This works fine.
在Odoo中,当您有xpath时,您可以在满足条件时向字段添加“attrs”,如required或invisible。这是很好。
I'm trying to combine those 2. I can't get it to work and can't find anywhere how to do it.
我要把这两个结合起来。我无法让它工作,也找不到任何方法去做它。
For example this is possible:
例如,这是可能的:
<field name="name" attrs="{'invisible': [('condition', '=', False)]}"/>
<field name="name2" attrs="{'readonly': [('condition', '=', False)]}"/>
<field name="name3" attrs="{'required': [('condition', '=', False)]}"/>
But what I can't get to work is something like:
但是我不能去工作的是:
<field name="name" attrs="{'invisible': [('condition1', '=', False)]}, 'required': [('condition2', '=', True)]}"/>
I want one field to be invisible when condition 1 is met and (also) required when condition 2 is met. I've tried different syntaxes but don't know how to do it.
我希望当条件1满足时,一个字段是不可见的,当条件2满足时,这个字段也是必需的。我尝试过不同的语法,但不知道怎么做。
What is the correct way to do it?
正确的方法是什么?
1 个解决方案
#1
4
Just remove the }
symbol. I think that's your mistake
只需删除}符号。我想那是你的错。
<field name="name" attrs="{'invisible': [('condition1', '=', False)], 'required': [('condition2', '=', True)]}"/>
#1
4
Just remove the }
symbol. I think that's your mistake
只需删除}符号。我想那是你的错。
<field name="name" attrs="{'invisible': [('condition1', '=', False)], 'required': [('condition2', '=', True)]}"/>