details: https://code.openbravo.com/erp/devel/pi/rev/cd8309678ebc changeset: 34837:cd8309678ebc user: Nono Carballo <nonofce <at> gmail.com> date: Thu Oct 11 08:57:47 2018 +0200 summary: Fixes issue 39355: Issue a partial sales order line if there is a reservation
* Checks the reservation exists before reallocate it if it does not have enough stock reserved. diffstat: src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml | 14 ++++++++-- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (46 lines): diff -r 874862309622 -r cd8309678ebc src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml --- a/src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml Fri Oct 05 11:41:53 2018 +0200 +++ b/src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml Thu Oct 11 08:57:47 2018 +0200 @@ -34,7 +34,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2012-2013 Openbravo SLU +* All portions are Copyright (C) 2012-2018 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -55,6 +55,7 @@ v_product_value VARCHAR2(40); v_locator_value VARCHAR2(40); v_uom_value VARCHAR2(3); + v_res_stock_exists NUMBER; TYPE RECORD IS REF CURSOR; cur_reserved_stock RECORD; @@ -116,8 +117,15 @@ WHERE rs.m_locator_id = p_locator_id AND rs.m_reservation_id = p_reservation_id AND COALESCE(rs.m_attributesetinstance_id, '0') = COALESCE(p_attributesetinstance_id, '0'); + + SELECT 1 + INTO v_res_stock_exists + FROM dual + WHERE EXISTS (SELECT 1 FROM m_reservation_stock rs WHERE rs.m_locator_id = p_locator_id + AND rs.m_reservation_id = p_reservation_id + AND COALESCE(rs.m_attributesetinstance_id, '0') = COALESCE(p_attributesetinstance_id, '0')); - IF (v_pendingtorelease > v_this_sd_reserved) THEN + IF (v_pendingtorelease > v_this_sd_reserved AND v_res_stock_exists IS NOT NULL) THEN -- The reservation does not have enough stock reserved on given locator and attributes, reallocation is needed. M_RESERVATION_REALLOCATE(p_reservation_id, p_locator_id, p_attributesetinstance_id, p_qty, p_user_id, p_result, p_message); END IF; @@ -146,7 +154,7 @@ END IF; END LOOP; - IF (v_pendingtorelease > 0) THEN + IF (v_pendingtorelease > 0 AND v_res_stock_exists IS NOT NULL) THEN RAISE_APPLICATION_ERROR(-20000, '@CannotConsumeAllStock@'||' @of@'||' @Product@: '||v_product_value||', @AttributeSetInstance@: '||COALESCE(v_attr_description, '-')||', @UOM@: '||v_uom_value||' @And@'||' @StorageBin@: '||COALESCE(v_locator_value, '-')); END IF; EXCEPTION _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits