这是Odoo 中ORM的产品线模型
class productline(models.Model):
_name = 'product.line'
actual_total = fields.Float(string="Actual Total")
Odoo中笔记本的XML文件,我在其中输入实际字段总值
<notebook>
<page string="Indent details">
<field name="roni">
<tree editable="bottom">
<!-- Actual total field of the notebook -->
<field name="actual_total"/>
</tree>
</field>
</page>
</notebook>
也许是这样的:
roni = fields.One2many(...
another_field = fields.Float(string="Actual Total", compute='_compute_total')
@api.depends('roni.actual_total')
def _compute_total(self):
for record in self:
record.another_field = sum(record.roni.mapped('actual_total'))
<notebook>
<page string="Indent details">
<field name="roni">
<tree editable="bottom">
#actual total field of the notebook
<field name="actual_total"/>
</tree>
</field>
<field name="another_field"/>
</page>
</notebook>