details: https://code.openbravo.com/erp/devel/pi/rev/3886c94b14d9 changeset: 30002:3886c94b14d9 user: Mark <markmm82 <at> gmail.com> date: Fri Sep 02 12:10:01 2016 -0400 summary: Fixes issue 33752: Can be closed an order with reserved stock
If the stock was reserved and the associated goods shipment voided, the order was raising an error when trying to close it. When reservations are retrieved, C_ORDER_POST1 trigger doesn't takes into account the status of previously released reservations. To make this validation works homogeneously just like is now in other areas where this validation is executed (C_ORDER_POST1, M_INOUT_CREATE, M_INOUT_POST, M_RESERVATION_POST) the query that retrieves the count of reservations of the line also takes into account those lines with status different than 'CL'. Also validates that is created a new reservation for the line only if doesn't exists any reservation for it. diffstat: src-db/database/model/functions/C_ORDER_POST1.xml | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diffs (41 lines): diff -r 3b4758dcc61a -r 3886c94b14d9 src-db/database/model/functions/C_ORDER_POST1.xml --- a/src-db/database/model/functions/C_ORDER_POST1.xml Wed Sep 07 12:18:54 2016 +0000 +++ b/src-db/database/model/functions/C_ORDER_POST1.xml Fri Sep 02 12:10:01 2016 -0400 @@ -1265,9 +1265,10 @@ ) ) LOOP SELECT count(*), max(m_reservation_id) - INTO v_aux, v_reservation_id + INTO v_aux, v_reservation_id FROM m_reservation - WHERE c_orderline_id = cur_orderline.c_orderline_id; + WHERE c_orderline_id = cur_orderline.c_orderline_id + AND res_status <> 'CL'; -- Initialize so_res_status UPDATE c_orderline SET so_res_status = 'NR' @@ -1342,10 +1343,20 @@ END WHERE c_orderline_id = cur_orderline.c_orderline_id; END IF; - ELSIF (cur_orderline.create_reservation = 'CRP') THEN - M_CREATE_RESERVE_FROM_SOL(cur_orderline.c_orderline_id, 'Y', v_user, v_reservation_id); - ELSIF (cur_orderline.create_reservation = 'CR') THEN - M_CREATE_RESERVE_FROM_SOL(cur_orderline.c_orderline_id, 'N', v_user, v_reservation_id); + ELSE + SELECT count(*) + INTO v_aux + FROM dual + WHERE EXISTS ( + SELECT 1 + FROM m_reservation + WHERE c_orderline_id = cur_orderline.c_orderline_id + ); + IF (v_aux = 0 AND cur_orderline.create_reservation = 'CRP') THEN + M_CREATE_RESERVE_FROM_SOL(cur_orderline.c_orderline_id, 'Y', v_user, v_reservation_id); + ELSIF (v_aux = 0 AND cur_orderline.create_reservation = 'CR') THEN + M_CREATE_RESERVE_FROM_SOL(cur_orderline.c_orderline_id, 'N', v_user, v_reservation_id); + END IF; END IF; END LOOP; SELECT COUNT(*), SUM(CASE ol.so_res_status WHEN 'CR' THEN 1 ELSE 0 END), SUM(CASE ol.so_res_status WHEN 'PR' THEN 1 ELSE 0 END) ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits