Fixed issue 24520: Global Use Products are wrongly distributed
authorNaiara Garcia <naiara.garcia@openbravo.com>
Fri, 09 Aug 2013 12:33:56 +0200
changeset 9916 389534944830
parent 9915 b12ddee9c95c
child 9917 381dd8af30f9
Fixed issue 24520: Global Use Products are wrongly distributed
src-db/database/model/functions/MA_GLOBALUSE_DISTRIBUTE.xml
--- a/src-db/database/model/functions/MA_GLOBALUSE_DISTRIBUTE.xml	Tue Mar 26 17:14:14 2013 +0000
+++ b/src-db/database/model/functions/MA_GLOBALUSE_DISTRIBUTE.xml	Fri Aug 09 12:33:56 2013 +0200
@@ -25,7 +25,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) 2001-2006 Openbravo SLU
+* All portions are Copyright (C) 2001-2013 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -116,7 +116,14 @@
           AND pp.M_PRODUCTIONPLAN_ID=Cur_ProductionPlan.M_ProductionPlan_ID
           AND wp.GROUPUSE='Y'
           AND wpp.M_PRODUCT_ID=Cur_GlobalUse.M_Product_ID;
-        IF(v_Factor<>0) THEN
+
+        SELECT COUNT(*)
+        INTO v_Count
+        FROM M_PRODUCTIONLINE
+        WHERE M_PRODUCTIONPLAN_ID=Cur_ProductionPlan.M_ProductionPlan_ID
+        AND M_PRODUCT_ID=Cur_GlobalUse.M_Product_ID;
+        
+        IF(v_Factor<>0 AND v_Count = 0) THEN
           SELECT MAX(Line) +10
           INTO v_Line
           FROM M_PRODUCTIONLINE