Commit 7fb3c6f4 by Thibault Grandjean

delete pair

parent f103fb03
...@@ -555,7 +555,7 @@ def delete_pair(request): ...@@ -555,7 +555,7 @@ def delete_pair(request):
POST: POST:
payload example: payload example:
{ {
"parent": {"id": 3075} "child": {"id": 3075}
} }
""" """
if request.method == 'GET': if request.method == 'GET':
...@@ -567,11 +567,10 @@ def delete_pair(request): ...@@ -567,11 +567,10 @@ def delete_pair(request):
if CagetteUser.are_credentials_ok(request): if CagetteUser.are_credentials_ok(request):
api = OdooAPI() api = OdooAPI()
data = json.loads(request.body.decode()) data = json.loads(request.body.decode())
parent_id = data['parent']['id'] child_id = data['child']['id']
# get attached account api.update('res.partner', [int(child_id)], {"parent_id": False, "is_associated_people": False})
child = api.search_read('res.partner', [['parent_id', '=', parent_id]], ['id'])[0]
api.delete('res.partner', [child['id']])
response = JsonResponse({"message": "Succesfuly unpaired members"}, status=200) response = JsonResponse({"message": "Succesfuly unpaired members"}, status=200)
else: else:
response = JsonResponse({"message": "Unauthorized"}, status=403) response = JsonResponse({"message": "Unauthorized"}, status=403)
return response return response
......
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