details:   https://code.openbravo.com/erp/devel/pi/rev/a69810747c37
changeset: 27320:a69810747c37
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Aug 11 10:56:53 2015 +0200
summary:   Fixes issue 30526: Unneeded storage detail updates on changes for 
MovementLines

Some checks have been added to M_MOVEMENTLINE_TRG trigger to update 
M_Storage_Detail only when it is necesary.

details:   https://code.openbravo.com/erp/devel/pi/rev/86f2c21db489
changeset: 27321:86f2c21db489
user:      David Miguelez <david.miguelez <at> openbravo.com>
date:      Thu Aug 13 13:07:02 2015 +0200
summary:   Related to Issue 30526: Code Review Changes.
Modifes ELSEIF sentence to make sure the trigger will be fired
for both locator_ID's if both are changed.

diffstat:

 src-db/database/model/triggers/M_MOVEMENTLINE_TRG.xml |  33 +++++++++++++++++-
 1 files changed, 30 insertions(+), 3 deletions(-)

diffs (64 lines):

diff -r 9bb014254be7 -r 86f2c21db489 
src-db/database/model/triggers/M_MOVEMENTLINE_TRG.xml
--- a/src-db/database/model/triggers/M_MOVEMENTLINE_TRG.xml     Thu Aug 13 
12:41:06 2015 +0200
+++ b/src-db/database/model/triggers/M_MOVEMENTLINE_TRG.xml     Thu Aug 13 
13:07:02 2015 +0200
@@ -24,7 +24,7 @@
   * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, 
parts
   * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights 
Reserved.
   * Contributor(s): Openbravo SLU
-  * Contributions are Copyright (C) 2001-2014 Openbravo S.L.U.
+  * Contributions are Copyright (C) 2001-2015 Openbravo S.L.U.
   
******************************************************************************/
     
 BEGIN
@@ -54,7 +54,7 @@
     RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
   END IF;
   -- Updating inventory
-  IF UPDATING OR DELETING THEN
+  IF DELETING THEN
     SELECT COUNT(*)
     INTO V_STOCKED
     FROM M_PRODUCT
@@ -66,7 +66,7 @@
       M_UPDATE_INVENTORY(:OLD.AD_CLIENT_ID, :OLD.AD_ORG_ID, :OLD.UPDATEDBY, 
:OLD.M_PRODUCT_ID, :OLD.M_LOCATORTO_ID, :OLD.M_ATTRIBUTESETINSTANCE_ID, 
:OLD.C_UOM_ID, :OLD.M_PRODUCT_UOM_ID, NULL, NULL, NULL, -:OLD.MOVEMENTQTY, 
-:OLD.QUANTITYORDER) ;
     END IF;
   END IF;
-  IF INSERTING OR UPDATING THEN
+  IF INSERTING THEN
     SELECT COUNT(*)
     INTO V_STOCKED
     FROM M_PRODUCT
@@ -78,6 +78,33 @@
       M_UPDATE_INVENTORY(:NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.UPDATEDBY, 
:NEW.M_PRODUCT_ID, :NEW.M_LOCATORTO_ID, :NEW.M_ATTRIBUTESETINSTANCE_ID, 
:NEW.C_UOM_ID, :NEW.M_PRODUCT_UOM_ID, NULL, NULL, NULL, :NEW.MOVEMENTQTY, 
:NEW.QUANTITYORDER) ;
     END IF;
   END IF;
+  IF UPDATING THEN
+    SELECT COUNT(*)
+    INTO V_STOCKED
+    FROM M_PRODUCT
+    WHERE M_Product_ID=:NEW.M_PRODUCT_ID
+      AND IsStocked='Y'
+      AND ProductType='I';
+    IF V_STOCKED > 0 THEN
+      IF (:Old.M_Product_ID <> :New.M_Product_ID OR :Old.C_UOM_ID <> 
:New.C_UOM_ID OR 
+      :Old.M_AttributeSetInstance_ID <> :New.M_AttributeSetInstance_ID OR 
:Old.MovementQty <> :New.MovementQty OR 
+      :Old.M_Product_UOM_ID <> :New.M_Product_UOM_ID OR :Old.QuantityOrder <> 
:New.QuantityOrder OR :Old.M_Reservation_ID <> :New.M_Reservation_ID) THEN
+        M_UPDATE_INVENTORY(:OLD.AD_CLIENT_ID, :OLD.AD_ORG_ID, :OLD.UPDATEDBY, 
:OLD.M_PRODUCT_ID, :OLD.M_LOCATOR_ID, :OLD.M_ATTRIBUTESETINSTANCE_ID, 
:OLD.C_UOM_ID, :OLD.M_PRODUCT_UOM_ID, NULL, NULL, NULL, :OLD.MOVEMENTQTY, 
:OLD.QUANTITYORDER) ;
+        M_UPDATE_INVENTORY(:OLD.AD_CLIENT_ID, :OLD.AD_ORG_ID, :OLD.UPDATEDBY, 
:OLD.M_PRODUCT_ID, :OLD.M_LOCATORTO_ID, :OLD.M_ATTRIBUTESETINSTANCE_ID, 
:OLD.C_UOM_ID, :OLD.M_PRODUCT_UOM_ID, NULL, NULL, NULL, -:OLD.MOVEMENTQTY, 
-:OLD.QUANTITYORDER) ;
+        M_UPDATE_INVENTORY(:NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.UPDATEDBY, 
:NEW.M_PRODUCT_ID, :NEW.M_LOCATOR_ID, :NEW.M_ATTRIBUTESETINSTANCE_ID, 
:NEW.C_UOM_ID, :NEW.M_PRODUCT_UOM_ID, NULL, NULL, NULL, -:NEW.MOVEMENTQTY, 
-:NEW.QUANTITYORDER) ;
+        M_UPDATE_INVENTORY(:NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.UPDATEDBY, 
:NEW.M_PRODUCT_ID, :NEW.M_LOCATORTO_ID, :NEW.M_ATTRIBUTESETINSTANCE_ID, 
:NEW.C_UOM_ID, :NEW.M_PRODUCT_UOM_ID, NULL, NULL, NULL, :NEW.MOVEMENTQTY, 
:NEW.QUANTITYORDER) ;
+      ELSE
+        IF (:Old.M_Locator_ID <> :New.M_Locator_ID) THEN
+          M_UPDATE_INVENTORY(:OLD.AD_CLIENT_ID, :OLD.AD_ORG_ID, 
:OLD.UPDATEDBY, :OLD.M_PRODUCT_ID, :OLD.M_LOCATOR_ID, 
:OLD.M_ATTRIBUTESETINSTANCE_ID, :OLD.C_UOM_ID, :OLD.M_PRODUCT_UOM_ID, NULL, 
NULL, NULL, :OLD.MOVEMENTQTY, :OLD.QUANTITYORDER) ;
+          M_UPDATE_INVENTORY(:NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, 
:NEW.UPDATEDBY, :NEW.M_PRODUCT_ID, :NEW.M_LOCATOR_ID, 
:NEW.M_ATTRIBUTESETINSTANCE_ID, :NEW.C_UOM_ID, :NEW.M_PRODUCT_UOM_ID, NULL, 
NULL, NULL, -:NEW.MOVEMENTQTY, -:NEW.QUANTITYORDER) ;
+        END IF;
+        IF (:Old.M_LocatorTo_ID <> :New.M_LocatorTo_ID) THEN
+          M_UPDATE_INVENTORY(:OLD.AD_CLIENT_ID, :OLD.AD_ORG_ID, 
:OLD.UPDATEDBY, :OLD.M_PRODUCT_ID, :OLD.M_LOCATORTO_ID, 
:OLD.M_ATTRIBUTESETINSTANCE_ID, :OLD.C_UOM_ID, :OLD.M_PRODUCT_UOM_ID, NULL, 
NULL, NULL, -:OLD.MOVEMENTQTY, -:OLD.QUANTITYORDER) ;               
+          M_UPDATE_INVENTORY(:NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, 
:NEW.UPDATEDBY, :NEW.M_PRODUCT_ID, :NEW.M_LOCATORTO_ID, 
:NEW.M_ATTRIBUTESETINSTANCE_ID, :NEW.C_UOM_ID, :NEW.M_PRODUCT_UOM_ID, NULL, 
NULL, NULL, :NEW.MOVEMENTQTY, :NEW.QUANTITYORDER) ; 
+        END IF;     
+      END IF;
+    END IF;
+  END IF;
   IF (INSERTING OR UPDATING) THEN
    --Does not allow to change the attribute set value
    -- for products which attribute set value type is Fixed

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to