无法添加计算方法

can not add compute method

问题很简单,我只需要创建一个计算字段。这是我的:

class MyModel(models.Model):
    _name = 'my.model'

    a = fields.Float()
    b = fields.Float()
    value = fields.Float(compute='_compute_value')

    @api.depends('a','b')
    def _compute_value(self):
        for record in self:
            record.value = a/b

但是当我想从数据库上的网络浏览器检查它时,我发现它没有添加到计算中

(法语中的计算器代表空的计算)

可能是什么问题?

要创建 my.model 字段,Odoo 将执行以下查询:

INSERT INTO ir_model_fields (model_id,model,name,field_description,help,ttype,state,relation,index,store,copied,on_delete,related,readonly,required,selectable,size,translate,relation_field,relation_table,column1,column2,track_visibility) 
VALUES 
(390, 'my.model', 'a', 'A', NULL, 'float', 'base', NULL, false, true, true, NULL, NULL, false, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'b', 'B', NULL, 'float', 'base', NULL, false, true, true, NULL, NULL, false, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'value', 'Value', NULL, 'float', 'base', NULL, false, false, false, NULL, NULL, true, false, false, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'id', 'ID', NULL, 'integer', 'base', NULL, false, true, true, NULL, NULL, true, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'display_name', 'Display Name', NULL, 'char', 'base', NULL, false, false, false, NULL, NULL, true, false, false, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'create_uid', 'Created by', NULL, 'many2one', 'base', 'res.users', false, true, true, 'set null', NULL, true, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'create_date', 'Created on', NULL, 'datetime', 'base', NULL, false, true, true, NULL, NULL, true, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'write_uid', 'Last Updated by', NULL, 'many2one', 'base', 'res.users', false, true, true, 'set null', NULL, true, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', 'write_date', 'Last Updated on', NULL, 'datetime', 'base', NULL, false, true, true, NULL, NULL, true, false, true, NULL, false, NULL, NULL, NULL, NULL, NULL),
(390, 'my.model', '__last_update', 'Last Modified on', NULL, 'datetime', 'base', NULL, false, false, false, NULL, NULL, true, false, false, NULL, false, NULL, NULL, NULL, NULL, NULL) RETURNING id

您可以看到 compute 没有出现在列名中。它的值没有存储在数据库中