To Compute the quantity invoiced If case of a refund in openerp to Compute the quantity invoiced. If case of a refund, the quantity invoiced is decreased. Note that this is the case only if the refund is generated from and function given below to use this code in .py file.
@api.depends('invoice_lines.invoice_id.state', 'invoice_lines.quantity')
def _get_invoice_qty(self):
for line in self:
qty_invoiced = 0.0
for invoice_line in line.invoice_lines:
if invoice_line.invoice_id.state != 'cancel':
if invoice_line.invoice_id.type == 'out_invoice':
qty_invoiced += invoice_line.quantity
elif invoice_line.invoice_id.type == 'out_refund':
qty_invoiced -= invoice_line.quantity
line.qty_invoiced = qty_invoiced
0 Comment(s)