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

Module: Purchase

Entity: purchase.order

Compute Method: _compute_bill_matched_ratio

Inputs Method Outputs
def get_line_invoiced_ratio(line):
            base_quantity = line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received
            return line.qty_invoiced / base_quantity if base_quantity else 0
for order in self:
            product_lines = order.order_line.filtered(lambda pol: not pol.display_type)
            invoiced_ratio = [get_line_invoiced_ratio(line) for line in product_lines]
            order.bill_matched_ratio = sum(invoiced_ratio) / len(product_lines) * 100 if product_lines else 0

Back to entity