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

Module: Recurring - Contracts Management

Entity: contract.contract

Compute Method: _compute_group_id

Inputs Method Outputs
"""Compute the group_id based on the analytic_distribution
        in the contract lines.
        If all contract lines have the same analytic account, set it as group_id.
        Otherwise, set group_id to False.
        """
for record in self:
            record.group_id = False
            all_analytic_accounts = []
            contract_lines = record.contract_line_ids | record.contract_line_fixed_ids
            for line in contract_lines:
                if line.analytic_distribution:
                    all_analytic_accounts.extend(
                        int(acc_id)
                        for account_ids in line.analytic_distribution.keys()
                        for acc_id in account_ids.split(",")
                    )
            if len(set(all_analytic_accounts)) == 1:
                record.group_id = all_analytic_accounts[0]

Back to entity