【发布时间】:2019-09-26 03:02:05
【问题描述】:
我不明白,为什么按钮的不可见属性在相关字段中不起作用。但是,当基于另一个字段类型条件的不可见属性(例如布尔值)时,就可以了。
我的模块或 python 文件上的代码是
'location_id' : fields.many2one('stock.location', string='Storage'),
'measurement_type' : fields.related('location_id','measurement_id', type="many2one",
relation="flow.measure.type", string = "Measurement Type", readonly=True, store=True),
这是我在 xml 文件中的脚本
<field name="measurement_type" />
<field name="location_id" required="1" context="{'full':1}"
on_change="onchange_location(location_id,measure_date)"
domain="[('usage','not in',['view','transit','inventory']),
('location_id','child_of',parent.location_id)]" />
<button name="open_flowmeter" string="Flowmeter Measurement"
type="object" icon="fa-exchange"
attrs="{'invisible':[('measurement_type','!=',2)]}"/>
并且数据库中measurement_type字段的数据类型是整数。
我的目标是当记录(measurement_type)为2时,按钮出现。但是,发生的事情是按钮没有出现。而且无论获取到的记录值如何,按钮仍然没有出现
PS。对不起我的语法不好
【问题讨论】:
-
你升级模块了吗?你想要的是,当你选择一条 id != 2 的记录时,按钮就会消失?
-
是的,我做到了。是的当然。当记录不是 2 时,按钮消失。但是按钮上的不可见属性不能正常工作
-
即使选择其他记录,按钮仍然存在?
-
对不起。我的意思是,当记录为 2 时,会出现按钮。但发生的事情是按钮没有出现
-
如果你反转域会出现按钮,你确定记录ID是2吗?
标签: python xml odoo odoo-8 odoo-9