Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Sales

Entity: sale.order

Compute Method: _compute_amount_to_invoice

Inputs Method Outputs
for order in self:
            # If the invoice status is 'Fully Invoiced' force the amount to invoice to equal zero and return early.
            if order.invoice_status == 'invoiced':
                order.amount_to_invoice = 0.0
                continue

            invoices = order.invoice_ids.filtered(lambda x: x.state == 'posted' or x.payment_state == 'invoicing_legacy')
            # Note: A negative amount can happen, since we can invoice more than the sales order amount.
            # Care has to be taken when summing amount_to_invoice of multiple orders.
            # E.g. consider one invoiced order with -100 and one uninvoiced order of 100: 100 + -100 = 0
            order.amount_to_invoice = order.amount_total - invoices._get_sale_order_invoiced_amount(order)

Back to entity