Commit 3b99d988 by Yvon Kerdoncuff

move child status update 'associated' to the end of the create_pair process so that odoo accepts it

parent c9dbb00e
Pipeline #4100 failed with stage
in 0 seconds
...@@ -829,9 +829,7 @@ def create_pair(request): ...@@ -829,9 +829,7 @@ def create_pair(request):
child_id, 0, 'création de binôme (mise à zéro suppléant)' child_id, 0, 'création de binôme (mise à zéro suppléant)'
) )
m = CagetteMember(child_id).unsubscribe_member() CagetteMember(child_id).unsubscribe_member()
# update child base account state
api.update("res.partner", [child_id], {'cooperative_state': "associated"})
# get barcode rule id # get barcode rule id
bbcode_rule = api.search_read("barcode.rule", [['for_associated_people', "=", True]], ['id'])[0] bbcode_rule = api.search_read("barcode.rule", [['for_associated_people', "=", True]], ['id'])[0]
...@@ -850,6 +848,11 @@ def create_pair(request): ...@@ -850,6 +848,11 @@ def create_pair(request):
attached_account = api.create('res.partner', child) attached_account = api.create('res.partner', child)
# generate_base # generate_base
api.execute('res.partner', 'generate_base', [attached_account]) api.execute('res.partner', 'generate_base', [attached_account])
# update child base account state after contact is created otherwise odoo complains that
# setting status associated is not allowed
api.update("res.partner", [child_id], {'cooperative_state': "associated"})
response = JsonResponse({"message": "Succesfuly paired members"}, status=200) response = JsonResponse({"message": "Succesfuly paired members"}, status=200)
else: else:
response = JsonResponse({"message": "Unauthorized"}, status=403) response = JsonResponse({"message": "Unauthorized"}, status=403)
......
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