diff --git a/base/src/org/compiere/model/MInOut.java b/base/src/org/compiere/model/MInOut.java
index 463da6ee56..42a4ad9ea9 100644
--- a/base/src/org/compiere/model/MInOut.java
+++ b/base/src/org/compiere/model/MInOut.java
@@ -32,6 +32,8 @@ import org.compiere.util.*;
* @version $Id: MInOut.java,v 1.4 2006/07/30 00:51:03 jjanke Exp $
*
* Modifications: Added the RMA functionality (Ashley Ramdass)
+ * @author Karsten Thiemann, Schaeffer AG
+ *
Bug [ 1759431 ] Problems with VCreateFrom
*/
public class MInOut extends X_M_InOut implements DocAction
{
@@ -1230,10 +1232,14 @@ public class MInOut extends X_M_InOut implements DocAction
{
log.fine("Material Transaction");
MTransaction mtrx = null;
+ //same warehouse in order and receipt?
+ boolean sameWarehouse = true;
// Reservation ASI - assume none
int reservationAttributeSetInstance_ID = 0; // sLine.getM_AttributeSetInstance_ID();
- if (oLine != null)
+ if (oLine != null) {
reservationAttributeSetInstance_ID = oLine.getM_AttributeSetInstance_ID();
+ sameWarehouse = oLine.getM_Warehouse_ID()==getM_Warehouse_ID();
+ }
//
if (sLine.getM_AttributeSetInstance_ID() == 0)
{
@@ -1254,16 +1260,33 @@ public class MInOut extends X_M_InOut implements DocAction
else
QtyPOMA = ma.getMovementQty();
}
+ BigDecimal diffQtyOrdered = QtyPOMA.negate();
+ if (!sameWarehouse) {
+ diffQtyOrdered = Env.ZERO;
+ }
// Update Storage - see also VMatch.createMatchRecord
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Locator_ID(),
sLine.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
- QtyMA, QtySOMA.negate(), QtyPOMA.negate(), get_TrxName()))
+ QtyMA, QtySOMA.negate(), diffQtyOrdered, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
}
+ if (!sameWarehouse) {
+ //correct qtyOrdered in warehouse of order
+ MWarehouse wh = MWarehouse.get(getCtx(), oLine.getM_Warehouse_ID());
+ if (!MStorage.add(getCtx(), oLine.getM_Warehouse_ID(),
+ wh.getDefaultLocator().getM_Locator_ID(),
+ sLine.getM_Product_ID(),
+ ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
+ Env.ZERO, Env.ZERO, QtyPOMA.negate(), get_TrxName()))
+ {
+ m_processMsg = "Cannot correct Inventory (MA) in order warehouse";
+ return DocAction.STATUS_Invalid;
+ }
+ }
// Create Transaction
mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
MovementType, sLine.getM_Locator_ID(),
@@ -1280,16 +1303,33 @@ public class MInOut extends X_M_InOut implements DocAction
// sLine.getM_AttributeSetInstance_ID() != 0
if (mtrx == null)
{
+ BigDecimal diffQtyOrdered = QtyPO.negate();
+ if (!sameWarehouse) {
+ diffQtyOrdered = Env.ZERO;
+ }
// Fallback: Update Storage - see also VMatch.createMatchRecord
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Locator_ID(),
sLine.getM_Product_ID(),
sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
- Qty, QtySO.negate(), QtyPO.negate(), get_TrxName()))
+ Qty, QtySO.negate(), diffQtyOrdered, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory";
return DocAction.STATUS_Invalid;
}
+ if (!sameWarehouse) {
+ //correct qtyOrdered in warehouse of order
+ MWarehouse wh = MWarehouse.get(getCtx(), oLine.getM_Warehouse_ID());
+ if (!MStorage.add(getCtx(), oLine.getM_Warehouse_ID(),
+ wh.getDefaultLocator().getM_Locator_ID(),
+ sLine.getM_Product_ID(),
+ sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
+ Env.ZERO, Env.ZERO, QtyPO.negate(), get_TrxName()))
+ {
+ m_processMsg = "Cannot correct Inventory";
+ return DocAction.STATUS_Invalid;
+ }
+ }
// FallBack: Create Transaction
mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
MovementType, sLine.getM_Locator_ID(),
diff --git a/client/src/org/compiere/grid/VCreateFrom.java b/client/src/org/compiere/grid/VCreateFrom.java
index 1265e70a9e..ed13670744 100644
--- a/client/src/org/compiere/grid/VCreateFrom.java
+++ b/client/src/org/compiere/grid/VCreateFrom.java
@@ -42,6 +42,8 @@ import org.compiere.util.*;
* FR [ 1794050 ] Usability: VCreateFrom OK button always enabled
* @author Victor Perez, e-Evolucion
* RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
+ * @author Karsten Thiemann, Schaeffer AG
+ * Bug [ 1759431 ] Problems with VCreateFrom
*/
public abstract class VCreateFrom extends CDialog
implements ActionListener, TableModelListener
@@ -137,6 +139,8 @@ public abstract class VCreateFrom extends CDialog
protected VString authorizationField = new VString();
private GridBagLayout parameterStdLayout = new GridBagLayout();
private GridBagLayout parameterBankLayout = new GridBagLayout();
+ // Bug [1759431]
+ protected JCheckBox sameWarehouseCb = new JCheckBox();
protected VLookup bPartnerField;
protected JLabel orderLabel = new JLabel();
protected JComboBox orderField = new JComboBox();
@@ -188,6 +192,9 @@ public abstract class VCreateFrom extends CDialog
shipmentLabel.setText(Msg.getElement(Env.getCtx(), "M_InOut_ID", false));
locatorLabel.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID"));
+ sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true));
+ sameWarehouseCb.setToolTipText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false));
+
//
this.getContentPane().add(parameterPanel, BorderLayout.NORTH);
parameterPanel.add(parameterBankPanel, BorderLayout.NORTH);
@@ -229,6 +236,8 @@ public abstract class VCreateFrom extends CDialog
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
parameterStdPanel.add(locatorField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
+ parameterStdPanel.add(sameWarehouseCb, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
+ ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
// Add RMA document selection to panel
parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
@@ -377,7 +386,7 @@ public abstract class VCreateFrom extends CDialog
{
log.config("C_BPartner_ID=" + C_BPartner_ID);
KeyNamePair pp = new KeyNamePair(0,"");
-
+ boolean sameWarehouseOnly = sameWarehouseCb.isVisible() && sameWarehouseCb.isSelected();
// load PO Orders - Closed, Completed
orderField.removeActionListener(this);
orderField.removeAllItems();
@@ -396,12 +405,19 @@ public abstract class VCreateFrom extends CDialog
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx='N' AND o.DocStatus IN ('CL','CO')"
+ " AND o.C_Order_ID IN "
+ "(SELECT ol.C_Order_ID FROM C_OrderLine ol"
- + " WHERE ol.QtyOrdered - ").append(column).append(" != 0) "
- + "ORDER BY o.DateOrdered");
+ + " WHERE ol.QtyOrdered - ").append(column).append(" != 0) ");
+ if(sameWarehouseOnly) {
+ sql = sql.append(" AND o.M_Warehouse_ID=? ");
+ }
+ sql = sql.append("ORDER BY o.DateOrdered");
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_BPartner_ID);
+ if(sameWarehouseOnly) {
+ //only active for material receipts
+ pstmt.setInt(2, Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_Warehouse_ID"));
+ }
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
@@ -417,6 +433,7 @@ public abstract class VCreateFrom extends CDialog
}
orderField.setSelectedIndex(0);
orderField.addActionListener(this);
+ this.pack();
initBPDetails(C_BPartner_ID);
} // initBPartnerOIS
diff --git a/client/src/org/compiere/grid/VCreateFromInvoice.java b/client/src/org/compiere/grid/VCreateFromInvoice.java
index 70139c0b0c..0e07dfdbc3 100644
--- a/client/src/org/compiere/grid/VCreateFromInvoice.java
+++ b/client/src/org/compiere/grid/VCreateFromInvoice.java
@@ -64,6 +64,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
invoiceField.setVisible(false);
locatorLabel.setVisible(false);
locatorField.setVisible(false);
+ sameWarehouseCb.setVisible(false);
// RMA Selection option should only be available for AP Credit Memo
Integer docTypeId = (Integer)p_mTab.getValue("C_DocTypeTarget_ID");
diff --git a/client/src/org/compiere/grid/VCreateFromRMA.java b/client/src/org/compiere/grid/VCreateFromRMA.java
index ea4e8fd229..3944ae269c 100644
--- a/client/src/org/compiere/grid/VCreateFromRMA.java
+++ b/client/src/org/compiere/grid/VCreateFromRMA.java
@@ -65,6 +65,7 @@ public class VCreateFromRMA extends VCreateFrom
shipmentLabel.setVisible(false);
shipmentField.setVisible(false);
+ sameWarehouseCb.setVisible(false);
rmaLabel.setVisible(false);
rmaField.setVisible(false);
diff --git a/client/src/org/compiere/grid/VCreateFromShipment.java b/client/src/org/compiere/grid/VCreateFromShipment.java
index bd2edb3638..f9c1477c0e 100644
--- a/client/src/org/compiere/grid/VCreateFromShipment.java
+++ b/client/src/org/compiere/grid/VCreateFromShipment.java
@@ -101,6 +101,8 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
parameterBankPanel.setVisible(false);
shipmentLabel.setVisible(false);
shipmentField.setVisible(false);
+ sameWarehouseCb.setSelected(true);
+ sameWarehouseCb.addActionListener(this);
// load Locator
int AD_Column_ID = 3537; // M_InOut.M_Locator_ID
@@ -285,6 +287,11 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
invoiceField.setSelectedIndex(-1);
loadRMA(M_RMA_ID);
}
+ }
+ //sameWarehouseCb
+ else if (e.getSource().equals(sameWarehouseCb))
+ {
+ initBPartnerOIS(((Integer)bPartnerField.getValue()).intValue(), false);
}
} // actionPerformed
diff --git a/client/src/org/compiere/grid/VCreateFromStatement.java b/client/src/org/compiere/grid/VCreateFromStatement.java
index dc5a8fd80c..bbf4786b31 100644
--- a/client/src/org/compiere/grid/VCreateFromStatement.java
+++ b/client/src/org/compiere/grid/VCreateFromStatement.java
@@ -64,6 +64,8 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
// Do not display RMA selection
rmaLabel.setVisible(false);
rmaField.setVisible(false);
+
+ sameWarehouseCb.setVisible(false);
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
parameterStdPanel.setVisible(false);
diff --git a/migration/331b-trunk/106_BF1759431.sql b/migration/331b-trunk/106_BF1759431.sql
new file mode 100644
index 0000000000..f8b6eedd8b
--- /dev/null
+++ b/migration/331b-trunk/106_BF1759431.sql
@@ -0,0 +1,11 @@
+
+-- Feb 21, 2008 12:53:15 PM CET
+-- Updated by Karsten Thiemann
+INSERT INTO AD_Message (AD_Org_ID,Value,UpdatedBy,Updated,MsgType,MsgTip,MsgText,IsActive,EntityType,CreatedBy,Created,AD_Message_ID,AD_Client_ID) VALUES (0,'FromSameWarehouseOnly',100,TO_DATE('2008-02-21 12:53:13','YYYY-MM-DD HH24:MI:SS'),'I','Show only orders with the same warehouse as selected in the material receipt','Only from same warehouse','Y','D',100,TO_DATE('2008-02-21 12:53:13','YYYY-MM-DD HH24:MI:SS'),53027,0)
+;
+
+-- Feb 21, 2008 12:53:15 PM CET
+-- Updated by Karsten Thiemann
+INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgTip,MsgText, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgTip,t.MsgText, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53027 AND EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Message_ID!=t.AD_Message_ID)
+;
+
diff --git a/migration/331b-trunk/postgresql/106_BF1759431.sql b/migration/331b-trunk/postgresql/106_BF1759431.sql
new file mode 100644
index 0000000000..a9831affb6
--- /dev/null
+++ b/migration/331b-trunk/postgresql/106_BF1759431.sql
@@ -0,0 +1,11 @@
+
+-- Feb 21, 2008 12:53:15 PM CET
+-- Updated by Karsten Thiemann
+INSERT INTO AD_Message (AD_Org_ID,Value,UpdatedBy,Updated,MsgType,MsgTip,MsgText,IsActive,EntityType,CreatedBy,Created,AD_Message_ID,AD_Client_ID) VALUES (0,'FromSameWarehouseOnly',100,TO_TIMESTAMP('2008-02-21 12:53:13','YYYY-MM-DD HH24:MI:SS'),'I','Show only orders with the same warehouse as selected in the material receipt','Only from same warehouse','Y','D',100,TO_TIMESTAMP('2008-02-21 12:53:13','YYYY-MM-DD HH24:MI:SS'),53027,0)
+;
+
+-- Feb 21, 2008 12:53:15 PM CET
+-- Updated by Karsten Thiemann
+INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgTip,MsgText, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgTip,t.MsgText, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53027 AND EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Message_ID!=t.AD_Message_ID)
+;
+