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

Module: Recurring - Product Contract

Entity: sale.order

Compute Method: _compute_need_contract_creation

Inputs Method Outputs
  • state
  • order_line
self.update({"need_contract_creation": False})
for rec in self:
            if rec.state in ("sale", "done"):
                line_to_create_contract = rec.order_line.filtered(
                    lambda r: not r.contract_id and r.product_id.is_contract
                )
                line_to_update_contract = rec.order_line.filtered(
                    lambda r: r.contract_id
                    and r.product_id.is_contract
                    and r
                    not in r.contract_id.contract_line_ids.mapped("sale_order_line_id")
                )
                if line_to_create_contract or line_to_update_contract:
                    rec.need_contract_creation = True

Back to entity