如何在旧的 api 函数中调用新的 api 函数?
How to call new api function in old api function?
我想从旧 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
只需以旧 api 格式调用新 api 函数 self.compute_amount(self)
。
def write(self, cr, uid, ids, vals, context=None):
self.compute_amount(self, cr, uid, ids, context=None)
我想从旧 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
只需以旧 api 格式调用新 api 函数 self.compute_amount(self)
。
def write(self, cr, uid, ids, vals, context=None):
self.compute_amount(self, cr, uid, ids, context=None)