簡體   English   中英

如何計算實際總字段的總值並將此值存儲在 odoo 中 model 的另一個字段中?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM