Odoo:onchange中的Override Integer字段无效,而Float已更改-为什么?

Odoo:onchange中的Override Integer字段无效,而Float已更改-为什么?,odoo,Odoo,我已使用以下字段扩展了product.template: length = fields.Integer("Length", default=0) length_float = fields.Float("Float", default=0.0) 此外,我还使用以下字段和onchange方法扩展了product.packaging模型: product_id_ref = fields.Many2one('product.product', string=

我已使用以下字段扩展了product.template:

length = fields.Integer("Length", default=0)
length_float = fields.Float("Float", default=0.0)
此外,我还使用以下字段和onchange方法扩展了product.packaging模型:

product_id_ref = fields.Many2one('product.product', string="Product Reference")
length = fields.Integer('Length')
length_float = fields.Float('Length_Float')

@api.onchange("product_id_ref")
def _onchange_product(self):        
    if self.product_id_ref:
        self.length_float = self.product_id_ref.length_float
        self.length = self.product_id_ref.length
有趣的是,浮动字段长度\u浮动按预期更改,并显示在视图中。整数字段未更改

更令人惊讶的是,如果我改变onchange方法的顺序

@api.onchange("product_id_ref")
def _onchange_product(self):        
    if self.product_id_ref:
        self.length = self.product_id_ref.length
        self.length_float = self.product_id_ref.length_float
未更改任何值

这怎么可能??有人有主意吗


谢谢

问题出在“长度”字段本身。这个名称会导致javascript方面的问题。重命名将导致所需的结果。

是否有一个onchange事件,可能是另一个onchange事件取消了修改请确保
product\u id\u ref
length
length\u float