亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

One2Many 在 Odoo 中獲得價值

One2Many 在 Odoo 中獲得價值

慕村9548890 2021-05-30 11:45:33
我有個問題。我創建了一個one2many,它是銷售模塊的one2many預算字段的副本。好吧,我想服從one2many內部的字段的所有值的總和例子 :這是我的 one2many:order_line = fields.One2many ('sale.order.line', 'order_id', string = 'Orders', copy = True)在視覺層面是這樣的:我想要小計的總和,以便在獲得總金額后將其放在其表示的位置(總計:),到目前為止,我已經對此表示贊同,但是這種行為是不合適的: @api.multi    @api.depends('order_line.price_unit')    def _total(self):        total = 0        for element in self.order_line:            total = total + element.prince_unit        self.total = total最后,它在總計字段中不顯示任何內容,如果我打印self.order_line,則顯示以下內容:sale.order (<odoo.models.NewId object at 0x000000000A9CD630>,)我不明白
查看完整描述

1 回答

?
qq_花開花謝_0

TA貢獻1835條經驗 獲得超7個贊

嘗試以下代碼:


@api.multi

@api.depends('order_line.price_unit')

def _total(self):

    for order in self:

        total = 0

        for element in order.order_line:

            total += element.price_unit

        order.total = total


查看完整回答
反對 回復 2021-06-01
  • 1 回答
  • 0 關注
  • 238 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號