如何在旧的api函数中调用新的api函数?

时间:2018-04-30 09:52:04

标签: python-2.7 odoo-8

我想从旧api中的write()函数调用新api中定义的函数。

def write(self, cr, uid, ids, vals, context=None): self.compute_amount()

这是新的api功能

@api.one @api.depends('tax_id','price_subtotal','od_month','product_uom_qty','price_unit','discount') def compute_amount(self): sum=0 for tax in self.tax_id: sum=sum+(tax.amount*self.price_subtotal) self.od_tax_amount=sum

1 个答案:

答案 0 :(得分:1)

只需使用旧的api格式调用新的api函数self.compute_amount(self)

def write(self, cr, uid, ids, vals, context=None): 
     self.compute_amount(self, cr, uid, ids, context=None)