Attached Files | outbound_un_solo_mov.diff [^] (8,287 bytes) 2016-12-23 01:21 [Show Content] [Hide Content]diff --git a/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/OBWPL_Utils.java b/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/OBWPL_Utils.java
index 22a46e7..4f4e898 100644
--- a/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/OBWPL_Utils.java
+++ b/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/OBWPL_Utils.java
@@ -127,39 +127,91 @@ public class OBWPL_Utils {
return (DocumentType) critDoc.uniqueResult();
}
- public static void createGoodMovement(ReservationStock resStock, PickingList picking,
- PickingList groupPicking, BigDecimal quantity) {
+ // =============================================================
+ // MODIFIED BY vforner on 21/12/2016.
+ // Description:
+ //public static void createGoodMovement(ReservationStock resStock, PickingList picking,
+ // PickingList groupPicking, BigDecimal quantity) {
+ // InternalMovement move = OBProvider.getInstance().get(InternalMovement.class);
+ // Map<String, String> map = new HashMap<String, String>();
+ // map.put("picking", picking.getDocumentNo());
+
+ // move.setOrganization(picking.getOrganization());
+ // move.setMovementDate(new Date());
+ // String name = OBMessageUtils.parseTranslation(MOVEMENT_NAME, map);
+ // move.setName(name.length() > 60 ? name.substring(0, 59) : name);
+ // OBDal.getInstance().save(move);
+
+ // InternalMovementLine mvLine = OBProvider.getInstance().get(InternalMovementLine.class);
+ // mvLine.setOrganization(picking.getOrganization());
+ // mvLine.setMovement(move);
+ // mvLine.setLineNo(10L);
+ // mvLine.setStockReservation(resStock.getReservation());
+ // mvLine.setOBWPLWarehousePickingList(picking);
+ // mvLine.setOBWPLGroupPickinglist(groupPicking);
+ // mvLine.setOBWPLAllowDelete(false);
+
+ // mvLine.setProduct(resStock.getReservation().getProduct());
+ // mvLine.setUOM(resStock.getReservation().getUOM());
+ // mvLine.setAttributeSetValue(resStock.getAttributeSetValue());
+ // mvLine.setStorageBin(resStock.getStorageBin());
+ // mvLine.setNewStorageBin(picking.getOutboundStorageBin());
+ // BigDecimal resStockReleasedQty = resStock.getReleased() == null ? BigDecimal.ZERO : resStock
+ // .getReleased();
+ // BigDecimal qty = quantity;
+ // if (qty == null) {
+ // qty = resStock.getQuantity().subtract(resStockReleasedQty);
+ // }
+ // mvLine.setMovementQuantity(qty);
+ // OBDal.getInstance().save(mvLine);
+ //}
+
+ public static void createGoodMovement(ReservationStock resStock, PickingList picking, PickingList groupPicking, BigDecimal quantity) {
+
+ InternalMovement move = createGoodMovement(picking);
+ OBDal.getInstance().save(move);
+
+ InternalMovementLine mvLine = createGoodMovementLine(move, 10L, resStock, picking, groupPicking, quantity);
+ OBDal.getInstance().save(mvLine);
+ }
+
+ public static InternalMovement createGoodMovement(PickingList picking) {
+
InternalMovement move = OBProvider.getInstance().get(InternalMovement.class);
Map<String, String> map = new HashMap<String, String>();
map.put("picking", picking.getDocumentNo());
-
move.setOrganization(picking.getOrganization());
move.setMovementDate(new Date());
String name = OBMessageUtils.parseTranslation(MOVEMENT_NAME, map);
move.setName(name.length() > 60 ? name.substring(0, 59) : name);
- OBDal.getInstance().save(move);
+ return move;
+ }
+
+ public static InternalMovementLine createGoodMovementLine(InternalMovement move, Long lineNo, ReservationStock resStock, PickingList picking,
+ PickingList groupPicking, BigDecimal quantity) {
InternalMovementLine mvLine = OBProvider.getInstance().get(InternalMovementLine.class);
mvLine.setOrganization(picking.getOrganization());
mvLine.setMovement(move);
- mvLine.setLineNo(10L);
+ mvLine.setLineNo(lineNo);
mvLine.setStockReservation(resStock.getReservation());
mvLine.setOBWPLWarehousePickingList(picking);
mvLine.setOBWPLGroupPickinglist(groupPicking);
mvLine.setOBWPLAllowDelete(false);
-
mvLine.setProduct(resStock.getReservation().getProduct());
mvLine.setUOM(resStock.getReservation().getUOM());
mvLine.setAttributeSetValue(resStock.getAttributeSetValue());
mvLine.setStorageBin(resStock.getStorageBin());
mvLine.setNewStorageBin(picking.getOutboundStorageBin());
- BigDecimal resStockReleasedQty = resStock.getReleased() == null ? BigDecimal.ZERO : resStock
- .getReleased();
+ BigDecimal resStockReleasedQty = resStock.getReleased() == null ? BigDecimal.ZERO : resStock.getReleased();
BigDecimal qty = quantity;
if (qty == null) {
- qty = resStock.getQuantity().subtract(resStockReleasedQty);
+ qty = resStock.getQuantity().subtract(resStockReleasedQty);
}
mvLine.setMovementQuantity(qty);
- OBDal.getInstance().save(mvLine);
+ return mvLine;
}
+
+ // END OF MODIFICATION
+ // =============================================================
}
diff --git a/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/Utilities.java b/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/Utilities.java
index 0c54e94..544e918 100644
--- a/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/Utilities.java
+++ b/modules/org.openbravo.warehouse.pickinglist/src/org/openbravo/warehouse/pickinglist/Utilities.java
@@ -59,6 +59,7 @@ import org.openbravo.model.materialmgmt.onhandquantity.Reservation;
import org.openbravo.model.materialmgmt.onhandquantity.ReservationStock;
import org.openbravo.model.materialmgmt.onhandquantity.StockProposed;
import org.openbravo.model.materialmgmt.onhandquantity.StorageDetail;
+import org.openbravo.model.materialmgmt.transaction.InternalMovement;
import org.openbravo.model.materialmgmt.transaction.InternalMovementLine;
import org.openbravo.model.materialmgmt.transaction.ShipmentInOut;
import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine;
@@ -574,16 +575,36 @@ public class Utilities {
OBDal.getInstance().flush();
List<ReservationStock> rsToRemove = new ArrayList<ReservationStock>();
+ // =============================================================
+ // MODIFIED BY vforner on 21/12/2016.
+ // Description:
+ //for (ReservationStock resStock : res.getMaterialMgmtReservationStockList()) {
+ // BigDecimal resStockReleasedQty = resStock.getReleased() == null ? BigDecimal.ZERO
+ // : resStock.getReleased();
+ // BigDecimal qty = resStock.getQuantity().subtract(resStockReleasedQty);
+ // if (qty.signum() > 0) {
+ // OBWPL_Utils.createGoodMovement(resStock, picking, null, null);
+ // } else if (qty.signum() == 0) {
+ // rsToRemove.add(resStock);
+ // }
+ //}
+ InternalMovement movement = OBWPL_Utils.createGoodMovement(picking);
+ OBDal.getInstance().save(movement);
+ Long lineNo = 10L;
for (ReservationStock resStock : res.getMaterialMgmtReservationStockList()) {
- BigDecimal resStockReleasedQty = resStock.getReleased() == null ? BigDecimal.ZERO
- : resStock.getReleased();
+ BigDecimal resStockReleasedQty = resStock.getReleased() == null ? BigDecimal.ZERO : resStock.getReleased();
BigDecimal qty = resStock.getQuantity().subtract(resStockReleasedQty);
if (qty.signum() > 0) {
- OBWPL_Utils.createGoodMovement(resStock, picking, null, null);
+ //OBWPL_Utils.createGoodMovement(resStock, picking, null, null);
+ InternalMovementLine movementLine = OBWPL_Utils.createGoodMovementLine(movement, lineNo, resStock, picking, null, null);
+ OBDal.getInstance().save(movementLine);
+ lineNo += 10L;
} else if (qty.signum() == 0) {
rsToRemove.add(resStock);
}
}
+ // END OF MODIFICATION
+ // =============================================================
res.getMaterialMgmtReservationStockList().removeAll(rsToRemove);
OBDal.getInstance().save(res);
OBDal.getInstance().flush();
|