我想从旧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
答案 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)