[英]How can I add an auto increment field in a model based on total count of objects with same field value?
[英]How can I calculate total value of actual total field and store this value in another field in model in odoo?
這是Odoo中ORM的產品線model
class productline(models.Model):
_name = 'product.line'
actual_total = fields.Float(string="Actual Total")
XML 在 Odoo 中輸入實際總字段值的筆記本文件
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.