Commit c1486cb1 by Yvon Kerdoncuff

#7422 : change variable names in delete_pair_core and use suppleant_member_id to…

#7422 : change variable names in delete_pair_core and use suppleant_member_id to find member to unsubscribe instead of email matching
parent 72ed5ca6
......@@ -1005,17 +1005,14 @@ def delete_pair_core(data):
}
"""
api = OdooAPI()
child_id = int(data['child']['id'])
child = api.search_read('res.partner', [['id', '=', child_id]], ['email', 'id', 'parent_id'])[0]
child_accounts = api.search_read('res.partner', [['email', '=', child['email']]], ['id', 'email'])
prev_child = [x['id'] for x in child_accounts if x['id'] != child_id]
parent = api.search_read('res.partner', [['id', '=', child['parent_id'][0]]], ['cooperative_state'])[0]
api.update('res.partner', [child_id], {"parent_id": False, "is_associated_people": False, "active": False,
child_contact_id = int(data['child']['id'])
child_contact = api.search_read('res.partner', [['id', '=', child_contact_id]], ['email', 'id', 'parent_id', 'suppleant_member_id'])[0]
parent = api.search_read('res.partner', [['id', '=', child_contact['parent_id'][0]]], ['cooperative_state'])[0]
api.update('res.partner', [child_contact_id], {"parent_id": False, "is_associated_people": False, "active": False,
"is_former_associated_people": True})
child_update_fields = {'cooperative_state': "unsubscribed", "is_former_associated_people": True}
child_member_update_fields = {'cooperative_state': "unsubscribed", "is_former_associated_people": True}
if 'gone' in data and 'child' in data['gone']:
child_update_fields['cooperative_state'] = "gone"
for id in prev_child:
api.update("res.partner", [id], child_update_fields)
child_member_update_fields['cooperative_state'] = "gone"
api.update("res.partner", [child_contact['suppleant_member_id']], child_member_update_fields)
if 'gone' in data and 'parent' in data['gone']:
api.update("res.partner", [parent['id']], {'cooperative_state': "gone", "is_former_associated_people": True})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment