stock.quant 中的 Odoo 变化 inventory_value

Odoo change inventory_value in stock.quant

我需要在stock.quant中更改库存价值,我想添加运费和技术人员成本(每个销售订单行中指定了技术人员,他有检查产品的成本)。我已经覆盖了 stock.py

中的 '_get_inventory_value' 函数
def _get_inventory_value(self, cr, uid, quant, context=None):
        print quant.reservation_id.procurement_id.sale_line_id.technician_sale.price
        return (quant.product_id.standard_price + quant.reservation_id.procurement_id.sale_line_id.technician_sale.price)* quant.qty

此代码仅适用于已确认的销售订单,这是因为对于已确认的订单,将有一个 resevation_id 从那里我可以获得销售订单行和技术人员成本 (quant.reservation_id.procurement_id.sale_line_id.technician_sale.price)。但是对于已交付的订单,没有 reservation_ids,因此我无法获得 sale_order_line。有没有什么方法可以从已交付订单的 stock.quant 中获取 sale_order_line。

delivered order (model stock.picking) 有一个字段 Source Document (origin),所以使用 origin 可以得到sale.ordersale.order.line的记录