Commit 6a11389e by François C.

Fix reception bug (if product are not configured with indicative_package, and order creation fails)

parent e180c8f7
Pipeline #2531 passed with stage
in 2 minutes 0 seconds
...@@ -97,6 +97,9 @@ def create_orders(request): ...@@ -97,6 +97,9 @@ def create_orders(request):
supplier_data["date_planned"], supplier_data["date_planned"],
supplier_data["lines"] supplier_data["lines"]
) )
if 'error' in res_created:
res["error"] = res_created['error']
return JsonResponse(res, status=500)
res["created"].append(res_created) res["created"].append(res_created)
except Exception as e: except Exception as e:
......
...@@ -42,7 +42,7 @@ class CagetteReception(models.Model): ...@@ -42,7 +42,7 @@ class CagetteReception(models.Model):
orders = api.search_read('purchase.order', c, f) orders = api.search_read('purchase.order', c, f)
except Exception as e: except Exception as e:
print(str(e)) coop_logger.error("get_orders : %s", str(e))
return orders return orders
def get_order_unprocessable_products(id_po): def get_order_unprocessable_products(id_po):
......
...@@ -2095,6 +2095,7 @@ function create_orders() { ...@@ -2095,6 +2095,7 @@ function create_orders() {
data: JSON.stringify(orders_data), data: JSON.stringify(orders_data),
success: (result) => { success: (result) => {
po_ids = []; po_ids = [];
//WARNING : if result.res.created content is rubbishes (as error dump for exemple) couchDB database will be filled with all available orders, with updated quantities equal to original order quantities !!
for (let po of result.res.created) { for (let po of result.res.created) {
po_ids.push(po.id_po); po_ids.push(po.id_po);
} }
...@@ -2679,7 +2680,6 @@ $(document).ready(function() { ...@@ -2679,7 +2680,6 @@ $(document).ready(function() {
// find order // find order
let order_id = group_ids[i]; let order_id = group_ids[i];
let order = result.rows.find(el => el.id == 'order_' + order_id); let order = result.rows.find(el => el.id == 'order_' + order_id);
order = order.doc; order = order.doc;
order.key = parseInt(i) + 1; order.key = parseInt(i) + 1;
orders[order_id] = order; orders[order_id] = order;
......
...@@ -46,7 +46,6 @@ def get_list_orders(request): ...@@ -46,7 +46,6 @@ def get_list_orders(request):
poids = [int(i) for i in request.GET.getlist('poids', [])] poids = [int(i) for i in request.GET.getlist('poids', [])]
get_order_lines = request.GET.get('get_order_lines', False) get_order_lines = request.GET.get('get_order_lines', False)
get_order_lines = get_order_lines == "true" get_order_lines = get_order_lines == "true"
ordersOdoo = CagetteReception.get_orders(poids) ordersOdoo = CagetteReception.get_orders(poids)
orders = [] orders = []
for order in ordersOdoo: for order in ordersOdoo:
......
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