Python 属性不可见在odoo中不起作用

Python 属性不可见在odoo中不起作用,python,xml,odoo,odoo-8,odoo-9,Python,Xml,Odoo,Odoo 8,Odoo 9,我不明白,为什么按钮的不可见属性不能在相关字段中工作。但是,当基于另一个字段类型条件的不可见属性(如boolean)起作用时 我的模块或python文件上的代码是 'location_id' : fields.many2one('stock.location', string='Storage'), 'measurement_type' : fields.related('location_id','measurement_id', type="many2one",

我不明白,为什么按钮的不可见属性不能在相关字段中工作。但是,当基于另一个字段类型条件的不可见属性(如boolean)起作用时

我的模块或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)]}"/>


数据库中测量类型字段的数据类型为整数

我的目标是当记录(测量类型)为2时,按钮出现。但是,发生的事情是按钮没有出现。无论获得的记录值如何,该按钮仍不会出现

对不起,我语法不好


更新您的代码以使用当前的ORMAPI。不应再使用声明列和相关字段的旧API方式。您的代码只显示片段,并且没有确切地公开自定义模型,因此我们无法知道您应该如何定义相关字段。转换后,它应该如下所示:

location_id = fields.Many2one('stock.location', string='Storage')
measurement_type = fields.Integer(related='location_id.measurement_id.type', string = "Measurement Type", readonly=True, store=True)
如有必要,修复测量类型字段的
相关
参数('location\u id.measurement\u id.type'),以反映模型结构以获取类型值


您可以在此处找到ODOOV9 ORMAPI开发人员指南:。您可以找到关于新api不支持旧api定义相关字段方式的github问题:

更新代码以使用当前ORMAPI。不应再使用声明列和相关字段的旧API方式。您的代码只显示片段,并且没有确切地公开自定义模型,因此我们无法知道您应该如何定义相关字段。转换后,它应该如下所示:

location_id = fields.Many2one('stock.location', string='Storage')
measurement_type = fields.Integer(related='location_id.measurement_id.type', string = "Measurement Type", readonly=True, store=True)
如有必要,修复测量类型字段的
相关
参数('location\u id.measurement\u id.type'),以反映模型结构以获取类型值


您可以在此处找到ODOOV9 ORMAPI开发人员指南:。您可以找到github关于新api不支持旧api定义相关字段的问题:

您是否升级了模块?您想要的是当您选择id为的记录时!=按钮不见了?是的,我不见了。当然可以。当记录不是2时,按钮消失。但是按钮上的“不可见”属性无法正常工作。即使选择了其他记录,按钮仍然存在?对不起。我的意思是,当记录为2时,按钮就会出现。但是出现的情况是按钮没有出现如果你反转域,按钮会出现吗?你确定记录Id是2吗?你升级了模块吗?您想要的是当您选择id为的记录时!=按钮不见了?是的,我不见了。当然可以。当记录不是2时,按钮消失。但是按钮上的“不可见”属性无法正常工作。即使选择了其他记录,按钮仍然存在?对不起。我的意思是,当记录为2时,按钮就会出现。但是发生的事情是按钮没有出现如果你反转域,按钮会出现吗?你确定记录Id是2吗?