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.line

Compute Method: _compute_date_start

Inputs Method Outputs
today = fields.Date.context_today(self)
for sol in self:
            if sol.contract_start_date_method == "start_this":
                sol.date_start = today.replace(day=1)
            elif sol.contract_start_date_method == "end_this":
                sol.date_start = (
                    today
                    + self.get_relative_delta(
                        sol.recurring_rule_type, sol.product_id.default_qty
                    )
                ).replace(day=1) - relativedelta(days=1)
            elif sol.contract_start_date_method == "start_next":
                # Dia 1 del siguiente recurring_rule_type
                sol.date_start = (
                    today
                    + self.get_relative_delta(
                        sol.recurring_rule_type, sol.product_id.default_qty
                    )
                ).replace(day=1)
            elif sol.contract_start_date_method == "end_next":
                # Last day of next recurring period
                sol.date_start = (
                    today
                    + self.get_relative_delta(
                        sol.recurring_rule_type, sol.product_id.default_qty + 1
                    )
                ).replace(day=1) - relativedelta(days=1)
            else:
                # Manual method
                sol.date_start = False

Back to entity