Search code examples
python-2.7odoo-8

How to call new api function in old api function?


I want to call a function defined in new api from write() function which is in old api.

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

This is the new api function

@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


Solution

  • Just call the new api function self.compute_amount(self) in old api format.

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