Comment 2 for bug 313339

Revision history for this message
Jordi Esteve (www.zikzakmedia.com) (jesteve-zikzakmedia) wrote :

I have tested and it is not completely fixed.

I you change the invoice of a member (draft->open->canceled->draft), his membership state changes but not the state of the associated members of him.

I think the following code must be add in lines 230 and 237 of membership/membership.py:

        ids2 = list_partner
        while ids2:
            ids2 = self.pool.get('res.partner').search(cr, uid, [('associate_member','in',ids2)], context=context)
            list_partner += ids2

The complete code is:

    def _get_partner_id(self, cr, uid, ids, context=None):
        data_inv = self.pool.get('membership.membership_line').browse(cr, uid, ids, context)
        list_partner = []
        for data in data_inv:
            list_partner.append(data.partner.id)
        ids2 = list_partner
        while ids2:
            ids2 = self.pool.get('res.partner').search(cr, uid, [('associate_member','in',ids2)], context=context)
            list_partner += ids2
        return list_partner

    def _get_invoice_partner(self, cr, uid, ids, context=None):
        data_inv = self.pool.get('account.invoice').browse(cr, uid, ids, context)
        list_partner = []
        for data in data_inv:
            list_partner.append(data.partner_id.id)
        ids2 = list_partner
        while ids2:
            ids2 = self.pool.get('res.partner').search(cr, uid, [('associate_member','in',ids2)], context=context)
            list_partner += ids2
        return list_partner

Also the state of associated members that computes the method _membership_state is wrong, because it takes the state of the associated member (line 288 res[id] = partner_data.associate_member.membership_state) and sometimes this state has not been computed yet.

I think this line must be changed by a recursive call:
                state = self._membership_state(cr, uid, [partner_data.associate_member.id], name, args, context)
                res[id] = state[partner_data.associate_member.id]

I attach the membership/membership.py with all the changes.

Jordi