I'm learning to customize again Odoo 9 system. Due to some characteristics of my own business I have to change some points in the account invoice template. I have created a new monetary filed with name total_residual and its value is computed by the function show bellow:
@api.multi
def _compute_all_residual(self):
for invoice in self:
invs = self.search([('state', '=', 'open'), ('partner_id', '=', invoice.partner_id.id)])
out_invoice = 0
in_invoice = 0
out_refund = 0
in_refund = 0
for inv in invs:
if inv.type == 'out_invoice':
out_invoice += inv.residual
if inv.type == 'in_invoice':
in_invoice += inv.residual
if inv.type == 'out_refund':
out_refund += inv.residual
if inv.type == 'in_refund':
in_refund += inv.residual
invoice.total_residual = out_invoice + in_refund - in_invoice - out_refund
now I would like to add a new field monetary field (old_residual) with value is total residual exclude the amount of current invoice. what is the right function to add on the module? and how come I show the value of old_residual to qweb report? thank for your time