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

Module: Members

Entity: membership.membership_line

Compute Method: _compute_state

Inputs Method Outputs
"""Compute the state lines """
if not self:
            return
groups = self.env['account.move'].sudo().read_group(
            domain=[('reversed_entry_id', 'in', self.account_invoice_id.ids)],
            fields=['reversed_entry_id'],
            groupby=['reversed_entry_id']
        )
reverse_map = {g['reversed_entry_id'][0]: g['reversed_entry_id_count'] for g in groups}
for line in self:
            move_state = line.account_invoice_id.state
            payment_state = line.account_invoice_id.payment_state

            line.state = 'none'
            if move_state == 'draft':
                line.state = 'waiting'
            elif move_state == 'posted':
                if payment_state == 'paid':
                    if reverse_map.get(line.account_invoice_id.id):
                        line.state = 'canceled'
                    else:
                        line.state = 'paid'
                elif payment_state == 'in_payment':
                    line.state = 'paid'
                elif payment_state in ('not_paid', 'partial'):
                    line.state = 'invoiced'
            elif move_state == 'cancel':
                line.state = 'canceled'

Back to entity