在 Odoo 模块自定义中使用计算方法计算值?

Using compute Method for Calculating Values in Odoo Module customization?

我的目标是在 Odoo 中创建一个 CRM-Lead 扩展模块。我的模块旨在向 CRM Odoo 模块中的 Lead 部分添加更多字段。 我创建了一个工作正常的模块代码,但一个问题是我有一个名为 percentage 的字段,它应该像这样计算 数量 * 100 & 存储在数据库中。因此,为此我在模型中使用了计算属性。但它没有计算价值......我将在下面提供我的代码:-

从 openerp 导入模型、字段,api

class legacy_sales(models.Model):
    _inherit='crm.lead'

    legacy_description = fields.Text(string="Comments")
    legacy_amount = fields.Float(string="Amount")
    legacy_startdate = fields.Date(string="StartDate")
    legacy_percentage = fields.Float(compute='_compute_percentage',store=True)

    @api.depends('legacy_amount')
    def _compute_percentage(self):
        self.legacy_percentage = self.legacy_amount * 100


legacy_sales()  

这里legacy_percentage不是在数据库中存储计算值..请指教:-

浏览自身以设置字段值:

for record in self:
    record.legacy_percentage= record.legacy_amount * 100