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

Module: Sales Margins in Projects

Entity: project.project

Compute Method: _compute_estimated_cost

Inputs Method Outputs
for project in self:
            all_sale_orders_lines = project._fetch_sale_order_items({'project.task': [('is_closed', '=', False)]})
            total_sold = sum(all_sale_orders_lines.mapped('price_subtotal'))
            project.estimated_cost = sum(all_sale_orders_lines.mapped(lambda line: line.purchase_price * line.product_uom_qty))
            project.estimated_cost_ratio = 100 * (project.estimated_cost / total_sold) if total_sold else 0.0

Back to entity