简体   繁体   English

如何计算实际总字段的总值并将此值存储在 odoo 中 model 的另一个字段中?

[英]How can I calculate total value of actual total field and store this value in another field in model in odoo?

This is the product line model of ORM in Odoo这是Odoo中ORM的产品线model

class productline(models.Model):
    _name = 'product.line'
    
    actual_total = fields.Float(string="Actual Total")

XML file for notebook in Odoo where I input actual total field value 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>

Maybe something like that:也许是这样的:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM