Commit 8f66a9fe by Yvon Kerdoncuff

to perform stock change from third-party apps, call action_validate instead of…

to perform stock change from third-party apps, call action_validate instead of action_done (deleted) and show error if missing data are required
parent 0225baf2
Pipeline #3906 failed with stage
...@@ -418,17 +418,21 @@ class CagetteInventory(models.Model): ...@@ -418,17 +418,21 @@ class CagetteInventory(models.Model):
# Set inventory as 'done' even if some products missed # Set inventory as 'done' even if some products missed
res = api.execute('stock.inventory', 'action_validate', [inv]) res = api.execute('stock.inventory', 'action_validate', [inv])
if not res: if not res:
action_validate_issue = "Action validate did not return True" done.append('Closed inventory')
else:
action_validate_issue = "Action validate returned something."
coop_logger.error(action_validate_issue) coop_logger.error(action_validate_issue)
errors.append(action_validate_issue) errors.append(action_validate_issue)
if name in res: if isinstance(res, dict) and 'name' in res:
coop_logger.error('Action validate returned wizard named %s', res['name']) coop_logger.error('Action validate wanted to return wizard named %s which is not possible from third-party app.', res['name'])
error.extend( error.extend([
'Action validate wanted to return wizard named :', 'Action validate wanted to return wizard named :',
res['name'], res['name'],
'which is not possible from third-party app.' 'which is not possible from third-party app.'
) ])
done.append('Closed inventory') else: #well, in that case, just try to print the value returned by res to help debugging...
coop_logger.error(res)
errors.append(res)
except Exception as e: except Exception as e:
if not (MARSHALL_ERROR in str(e)): if not (MARSHALL_ERROR in str(e)):
coop_logger.error("update_stock_with_shelf_inventory_data %s",str(e)) coop_logger.error("update_stock_with_shelf_inventory_data %s",str(e))
......
...@@ -186,6 +186,8 @@ def commit_actions_on_product(request): ...@@ -186,6 +186,8 @@ def commit_actions_on_product(request):
if res_inventory['errors'] or res_inventory['missed']: if res_inventory['errors'] or res_inventory['missed']:
res["code"] = "error_stock_update" res["code"] = "error_stock_update"
res["error"] = res_inventory['errors'] res["error"] = res_inventory['errors']
res["done"] = res_inventory["done"]
res["inv_id"] = res_inventory["inv_id"]
return JsonResponse(res, status=500) return JsonResponse(res, status=500)
except Exception as e: except Exception as e:
res["code"] = "error_stock_update" res["code"] = "error_stock_update"
......
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