Fixed issue 28673:It should be possible to allow partial shipments on book process
authorGuillermo Gil <guillermo.gil@openbravo.com>
Mon, 19 Jan 2015 12:53:22 +0100
changeset 25724 0b32a498249d
parent 25723 b4f4fca525d7
child 25725 ee576d07c86c
Fixed issue 28673:It should be possible to allow partial shipments on book process

AllowPartialShipment preference created
If Y, c_order_post would ship all the available items
src-db/database/model/functions/M_INOUT_CREATE.xml
src-db/database/sourcedata/AD_REF_LIST.xml
--- a/src-db/database/model/functions/M_INOUT_CREATE.xml	Mon Jan 19 12:35:25 2015 +0100
+++ b/src-db/database/model/functions/M_INOUT_CREATE.xml	Mon Jan 19 12:53:22 2015 +0100
@@ -143,6 +143,10 @@
   NEXT_PRODUCT BOOLEAN:=false;
   Cur_Storage_ISOPEN BOOLEAN:=false;
   Cur_OrderLine_ISOPEN BOOLEAN:=false;
+
+  v_dummy VARCHAR2(2000);
+  v_ForceDelivery CHAR(1);
+  v_DeliveryRule CHAR(1);
 BEGIN
   -- Process Parameters
   IF (p_pinstance_id IS NOT NULL) THEN
@@ -299,16 +303,33 @@
              o.DELIVERY_LOCATION_ID -- Added by Rafa Roda to include delivery location
         ORDER BY o.PriorityRule,o.DocumentNo
     ) LOOP
+      if (p_ForceDelivery = 'Y') THEN
+        SELECT COUNT(1) INTO v_count
+        FROM ad_preference
+        WHERE property = 'AllowPartialShipment';
+        IF (v_count > 0) THEN
+          v_dummy := AD_GET_PREFERENCE_VALUE('AllowPartialShipment', 'Y', v_AD_Client_ID, v_AD_Org_ID, NULL, NULL, NULL);
+        ELSE
+          v_dummy := 'N';
+        END IF;
+      END IF;
+      IF (v_dummy = 'Y') THEN
+        v_ForceDelivery := 'N';
+        v_DeliveryRule := 'A';
+      ELSE
+        v_ForceDelivery := 'Y';
+        v_DeliveryRule := Cur_Order.DeliveryRule;
+      END IF;
       v_DocumentNo:='';
       v_order_count := v_order_count +1;
-      DBMS_OUTPUT.PUT_LINE('Order ' || Cur_Order.DocumentNo || '/' || Cur_Order.C_Order_ID || ', Wh=' || Cur_Order.M_Warehouse_ID || ', Force=' || p_ForceDelivery || ', Delivery=' || Cur_Order.DeliveryRule) ;
+      DBMS_OUTPUT.PUT_LINE('Order ' || Cur_Order.DocumentNo || '/' || Cur_Order.C_Order_ID || ', Wh=' || Cur_Order.M_Warehouse_ID || ', Force=' || v_ForceDelivery || ', Delivery=' || v_DeliveryRule) ;
       -- Delivery Rules
       --  (A)vailability
       --  Complete (L)ine
       --  Complete (O)rder
       --  After (R)eceipt
       -- (A)vailability (L)ine   -- Do we have something to ship ?
-      IF (Cur_Order.DeliveryRule IN('A', 'L', 'R', 'O')) THEN
+      IF (v_DeliveryRule IN('A', 'L', 'R', 'O')) THEN
         v_ResultStr:='CheckSomethingToShip';
         OPEN Cur_OrderLine(Cur_Order.C_Order_ID, Cur_Order.M_Warehouse_ID) ;
         Cur_OrderLine_ISOPEN:=true;
@@ -319,7 +340,7 @@
           Next_Order:=true;
         END IF;
       ELSE
-        DBMS_OUTPUT.PUT_LINE('** DeliveryRule=' || Cur_Order.DeliveryRule || ' not implemented') ;
+        DBMS_OUTPUT.PUT_LINE('** DeliveryRule=' || v_DeliveryRule || ' not implemented') ;
         Next_Order:=true;
       END IF;
 
@@ -372,7 +393,7 @@
             now(), v_User_ID, v_DocumentNo, v_DocType_ID,
             Cur_Order.Description, 'N', 'C-', v_NEWORDERDATE,
             TRUNC(now()), Cur_Order.C_BPartner_ID, Cur_Order.C_BPartner_Location_ID, Cur_Order.AD_User_ID,
-            Cur_Order.M_Warehouse_ID, Cur_Order.POReference, Cur_Order.DateOrdered, Cur_Order.DeliveryRule,
+            Cur_Order.M_Warehouse_ID, Cur_Order.POReference, Cur_Order.DateOrdered, v_DeliveryRule,
             Cur_Order.FreightCostRule, Cur_Order.FreightAmt, Cur_Order.C_Project_ID, Cur_Order.C_Activity_ID,
             Cur_Order.C_Campaign_ID, Cur_Order.AD_OrgTrx_ID, Cur_Order.User1_ID, Cur_Order.User2_ID,
             Cur_Order.DeliveryViaRule, Cur_Order.M_Shipper_ID, Cur_Order.C_Charge_ID, Cur_Order.ChargeAmt,
@@ -583,7 +604,7 @@
                 END IF;--NEXT_PRODUCT
                 --<<NEXT_PRODUCT>>
                 NEXT_PRODUCT:=false;
-                IF (v_Qty<>0 AND (p_ForceDelivery='Y' OR v_allownegativestock = 'Y')) THEN
+                IF (v_Qty<>0 AND (v_ForceDelivery='Y' OR v_allownegativestock = 'Y')) THEN
                   -- Create InOut Line
                   Ad_Sequence_Next('M_InOutLine', Cur_Order.C_Order_ID, v_NextNo) ;
                   IF (v_ProductUOM IS NOT NULL) THEN
@@ -632,12 +653,12 @@
                                        and c_orderline_id = (SELECT BOM_parent_id from c_orderline WHERE c_orderline_id = ol.C_OrderLine_ID)));
                   v_lines:=v_lines + 10;
                 ELSIF (v_qty <> 0) THEN
-                  IF (cur_order.deliveryrule = 'O') THEN
+                  IF (v_DeliveryRule = 'O') THEN
                     DBMS_OUTPUT.PUT_LINE('Not enough stocked products, delivery type Order');
                     next_order := true;
                     v_lines := 0;
                     EXIT;
-                  ELSIF (Cur_order.deliveryrule = 'L') THEN
+                  ELSIF (v_DeliveryRule = 'L') THEN
                     DBMS_OUTPUT.PUT_LINE('Not enough stocked products, delivery type Line');
                     v_lines := v_lines - v_lines_per_orderline;
                     IF (LENGTH(v_resultlinesstr || '<br>@OrderLine@: ' || ol.Line || ' @ForProduct@ ' || ol.name || ': @notEnoughStockDeliveryRuleLine@.') <= 1800 ) THEN
@@ -710,7 +731,7 @@
         DELETE FROM M_INOUT
         WHERE M_INOUT_ID = p_InOut_ID;
         next_order := TRUE;
-        IF (Cur_Order.DeliveryRule='O') THEN
+        IF (v_DeliveryRule='O') THEN
           result_String := '@OrderDocumentno@ ' || cur_order.DocumentNo || ': ' || '@ShipmentError@. @notEnoughStockDeliveryRuleOrder@.';
         ELSE
           result_String := '@OrderDocumentno@ ' || cur_order.DocumentNo || ': ' || '@ShipmentError@.' || v_resultlinesstr;
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Jan 19 12:35:25 2015 +0100
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Jan 19 12:53:22 2015 +0100
@@ -9356,6 +9356,18 @@
 <!--5289DAE7C319465D95714A7A1A78B486-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--5289DAE7C319465D95714A7A1A78B486--></AD_REF_LIST>
 
+<!--5293CE35218F4294BF4C225512082108--><AD_REF_LIST>
+<!--5293CE35218F4294BF4C225512082108-->  <AD_REF_LIST_ID><![CDATA[5293CE35218F4294BF4C225512082108]]></AD_REF_LIST_ID>
+<!--5293CE35218F4294BF4C225512082108-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5293CE35218F4294BF4C225512082108-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5293CE35218F4294BF4C225512082108-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5293CE35218F4294BF4C225512082108-->  <VALUE><![CDATA[AllowPartialShipment]]></VALUE>
+<!--5293CE35218F4294BF4C225512082108-->  <NAME><![CDATA[Allow Partial Shipment]]></NAME>
+<!--5293CE35218F4294BF4C225512082108-->  <DESCRIPTION><![CDATA[If the value is Y it allows a partial shipment on Booking process in case of do not have enough stock]]></DESCRIPTION>
+<!--5293CE35218F4294BF4C225512082108-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--5293CE35218F4294BF4C225512082108-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--5293CE35218F4294BF4C225512082108--></AD_REF_LIST>
+
 <!--52FADEF40F2344519D2BFB50489714A9--><AD_REF_LIST>
 <!--52FADEF40F2344519D2BFB50489714A9-->  <AD_REF_LIST_ID><![CDATA[52FADEF40F2344519D2BFB50489714A9]]></AD_REF_LIST_ID>
 <!--52FADEF40F2344519D2BFB50489714A9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>