From 0e03505f52f09c1846ee28bd4641210055674b10 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 8 Nov 2014 13:11:07 -0500 Subject: [PATCH 01/16] IDEMPIERE-2305 Cash/Check Payment button is ignoring amount entered --- .../src/org/compiere/model/MPayment.java | 32 +++++++++++++++++-- .../src/org/compiere/model/MSysConfig.java | 5 +-- .../webui/apps/form/WPaymentFormCash.java | 1 - .../adempiere/webui/component/Paymentbox.java | 4 +++ .../webui/editor/WPaymentEditor.java | 2 ++ .../org/compiere/grid/PaymentFormCheck.java | 4 +-- 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 4129b23b46..7d7158835a 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -83,7 +83,7 @@ public class MPayment extends X_C_Payment /** * */ - private static final long serialVersionUID = -3426445843281140181L; + private static final long serialVersionUID = -7646717328867858897L; /** * Get Payments Of BPartner @@ -654,6 +654,22 @@ public class MPayment extends X_C_Payment */ protected boolean beforeSave (boolean newRecord) { + if (isComplete() && + ( is_ValueChanged(COLUMNNAME_C_BankAccount_ID) + || is_ValueChanged(COLUMNNAME_C_BPartner_ID) + || is_ValueChanged(COLUMNNAME_C_Charge_ID) + || is_ValueChanged(COLUMNNAME_C_Currency_ID) + || is_ValueChanged(COLUMNNAME_C_DocType_ID) + || is_ValueChanged(COLUMNNAME_C_Invoice_ID) + || is_ValueChanged(COLUMNNAME_C_Order_ID) + || is_ValueChanged(COLUMNNAME_DateAcct) + || is_ValueChanged(COLUMNNAME_DateTrx) + || is_ValueChanged(COLUMNNAME_DiscountAmt) + || is_ValueChanged(COLUMNNAME_PayAmt) + || is_ValueChanged(COLUMNNAME_WriteOffAmt))) { + log.saveError("PaymentAlreadyProcessed", Msg.translate(getCtx(), "C_Payment_ID")); + return false; + } // @Trifon - CashPayments //if ( getTenderType().equals("X") ) { if ( isCashbookTrx()) { @@ -781,7 +797,19 @@ public class MPayment extends X_C_Payment return true; } // beforeSave - + + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isComplete + /** * Get Allocated Amt in Payment Currency * @return amount or null diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index b2a568335e..ccd8f61bcc 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -39,10 +39,10 @@ import org.compiere.util.DisplayType; */ public class MSysConfig extends X_AD_SysConfig { - /** + /** * */ - private static final long serialVersionUID = -5043918406658386237L; + private static final long serialVersionUID = 8965976274227777648L; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; @@ -78,6 +78,7 @@ public class MSysConfig extends X_AD_SysConfig public static final String DOCACTIONBUTTON_SHOWACTIONNAME = "DOCACTIONBUTTON_SHOWACTIONNAME"; public static final String DPVIEWS_SHOWINFOACCOUNT = "DPViews_ShowInfoAccount"; public static final String DPVIEWS_SHOWINFOSCHEDULE = "DPViews_ShowInfoSchedule"; + public static final String ENABLE_PAYMENTBOX_BUTTON = "ENABLE_PAYMENTBOX_BUTTON"; public static final String GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = "GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS"; public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber"; public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WPaymentFormCash.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WPaymentFormCash.java index f91a7221c9..25297fe00a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WPaymentFormCash.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WPaymentFormCash.java @@ -34,7 +34,6 @@ import org.adempiere.webui.window.FDialog; import org.compiere.grid.PaymentFormCash; import org.compiere.model.GridTab; import org.compiere.model.MConversionRate; -import org.compiere.model.MInvoice; import org.compiere.util.Env; import org.compiere.util.KeyNamePair; import org.compiere.util.Msg; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java index 0cd4b59c38..3ac006c3f3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java @@ -17,6 +17,8 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import org.adempiere.webui.LayoutUtils; +import org.compiere.model.MSysConfig; +import org.compiere.util.Env; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Comboitem; @@ -77,6 +79,8 @@ public class Paymentbox extends Div { } public void setEnabled(boolean isComboEnabled, boolean isBtnEnabled) { + if (! MSysConfig.getBooleanValue(MSysConfig.ENABLE_PAYMENTBOX_BUTTON, true, Env.getAD_Client_ID(Env.getCtx()))) + isBtnEnabled = false; combo.setEnabled(isComboEnabled); combo.setButtonVisible(isComboEnabled); btn.setEnabled(isBtnEnabled); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java index 99cb5cdc91..64f926476d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java @@ -181,6 +181,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener { if (!m_onlyRule // Only order has Warehouse && !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null) m_onlyRule = true; + if (!m_onlyRule && m_mTab.needSave(true, false)) // don't show button until change on payment rule is saved + m_onlyRule = true; } getComponent().setEnabled(readWrite, readWrite && !m_onlyRule); diff --git a/org.adempiere.ui/src/org/compiere/grid/PaymentFormCheck.java b/org.adempiere.ui/src/org/compiere/grid/PaymentFormCheck.java index ae994ea303..187ec31009 100644 --- a/org.adempiere.ui/src/org/compiere/grid/PaymentFormCheck.java +++ b/org.adempiere.ui/src/org/compiere/grid/PaymentFormCheck.java @@ -208,11 +208,11 @@ public abstract class PaymentFormCheck extends PaymentForm { if (invoice == null && C_Order_ID != 0) order = new MOrder (Env.getCtx(), C_Order_ID, null); - BigDecimal payAmount = m_Amount; + BigDecimal payAmount = amount; if (negateAmt) - payAmount = m_Amount.negate(); + payAmount = amount.negate(); // Info if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID + ", C_Invoice_ID=" + C_Invoice_ID + ", NegateAmt=" + negateAmt); From fe3ebcd1ae868a8a6ae1f2c4e72920adbec73455 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 10 Nov 2014 17:22:34 -0500 Subject: [PATCH 02/16] minor - fix a comment creating problems for javadoc --- org.adempiere.base/src/org/compiere/model/MAsset.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MAsset.java b/org.adempiere.base/src/org/compiere/model/MAsset.java index c24f5926ba..d0ee05e5b0 100644 --- a/org.adempiere.base/src/org/compiere/model/MAsset.java +++ b/org.adempiere.base/src/org/compiere/model/MAsset.java @@ -324,7 +324,7 @@ public class MAsset extends X_A_Asset // Copy fields from C_BPartner_Location if (is_ValueChanged(COLUMNNAME_C_BPartner_Location_ID) && getC_BPartner_Location_ID() > 0) { - // Goodwill BF: “Error: org.compiere.model.MAsset cannot be cast to org.compiere.model.SetGetModel” + // Goodwill BF: Error: org.compiere.model.MAsset cannot be cast to org.compiere.model.SetGetModel SetGetUtil.copyValues(SetGetUtil.wrap(this), MBPartnerLocation.Table_Name, getC_BPartner_Location_ID(), new String[]{MBPartnerLocation.COLUMNNAME_C_Location_ID} ); From ab37dd125809adb569d2e93ca146cd3bde984538 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 11 Nov 2014 14:19:02 -0500 Subject: [PATCH 03/16] IDEMPIERE-2057 Modify "Update Costing" process to create a cost adjustment document / IDEMPIERE-2306 Can't create cost detail when costing level is Batch/Lot from import inventory --- .../src/org/compiere/process/CostUpdate.java | 4 +-- .../org/compiere/process/ImportInventory.java | 12 ++++++--- .../src/org/compiere/model/MCost.java | 25 +++++++++++++------ .../src/org/compiere/model/MCostDetail.java | 16 +++++++++--- .../org/compiere/model/MInventoryLine.java | 2 +- .../src/org/compiere/model/MProduct.java | 2 +- .../src/org/compiere/model/ProductCost.java | 2 +- 7 files changed, 43 insertions(+), 20 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java b/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java index dce469dc4a..fff15e77eb 100644 --- a/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java +++ b/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java @@ -513,7 +513,7 @@ public class CostUpdate extends SvrProcess } if (retValue == null) { - MProduct product = MProduct.get(getCtx(), cost.getM_Product_ID()); + MProduct product = new MProduct(getCtx(), cost.getM_Product_ID(), get_TrxName()); MAcctSchema as = MAcctSchema.get(getCtx(), cost.getC_AcctSchema_ID()); retValue = MCost.getLastInvoicePrice(product, cost.getM_AttributeSetInstance_ID(), cost.getAD_Org_ID(), as.getC_Currency_ID()); @@ -532,7 +532,7 @@ public class CostUpdate extends SvrProcess } if (retValue == null) { - MProduct product = MProduct.get(getCtx(), cost.getM_Product_ID()); + MProduct product = new MProduct(getCtx(), cost.getM_Product_ID(), get_TrxName()); MAcctSchema as = MAcctSchema.get(getCtx(), cost.getC_AcctSchema_ID()); retValue = MCost.getLastPOPrice(product, cost.getM_AttributeSetInstance_ID(), cost.getAD_Org_ID(), as.getC_Currency_ID()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java index 4401be2e9d..bb937793bb 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java @@ -400,7 +400,7 @@ public class ImportInventory extends SvrProcess x_isInternalUse = isInternalUse; noInsert++; } - MProduct product = MProduct.get(getCtx(), imp.getM_Product_ID()); + MProduct product = new MProduct(getCtx(), imp.getM_Product_ID(), get_TrxName()); // Line int M_AttributeSetInstance_ID = 0; if ((imp.getLot() != null && imp.getLot().length() > 0) || (imp.getSerNo() != null && imp.getSerNo().length() > 0)) @@ -519,10 +519,13 @@ public class ImportInventory extends SvrProcess costASI = 0; } else if (MAcctSchema.COSTINGLEVEL_Organization.equals(costingLevel)) { costASI = 0; + } else if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(costingLevel)) { + costOrgID = 0; } - MCost cost = MCost.get (MProduct.get(getCtx(), imp.getM_Product_ID()), costASI + MCost cost = MCost.get (product, costASI , acctSchema, costOrgID, p_M_CostElement_ID, get_TrxName()); - + if (cost.is_new()) + cost.saveEx(); if (costingDoc == null) { costingDoc = new MInventory(getCtx(), 0, get_TrxName()); costingDoc.setC_DocType_ID(p_C_DocType_ID); @@ -539,7 +542,8 @@ public class ImportInventory extends SvrProcess costingLine.setNewCostPrice(imp.getCurrentCostPrice()); costingLine.setM_Locator_ID(0); costingLine.setAD_Org_ID(imp.getAD_Org_ID()); - costingLine.saveEx(); + costingLine.setM_AttributeSetInstance_ID(costASI); + costingLine.saveEx(); imp.setM_CostingLine_ID(costingLine.getM_InventoryLine_ID()); imp.saveEx(); diff --git a/org.adempiere.base/src/org/compiere/model/MCost.java b/org.adempiere.base/src/org/compiere/model/MCost.java index b9dd42fe44..9b4b65577e 100644 --- a/org.adempiere.base/src/org/compiere/model/MCost.java +++ b/org.adempiere.base/src/org/compiere/model/MCost.java @@ -55,14 +55,10 @@ import org.compiere.util.Trx; */ public class MCost extends X_M_Cost { - - - - /** - * - */ - private static final long serialVersionUID = -127982599769472918L; - + /** + * + */ + private static final long serialVersionUID = -8904980122276406878L; /** * Retrieve/Calculate Current Cost Price @@ -1520,6 +1516,19 @@ public class MCost extends X_M_Cost setCurrentQty(getCurrentQty().add(qty)); } // setWeightedAverage + /** + * @param amt unit amt + */ + public void setWeightedAverageInitial (BigDecimal amtUnit) + { + BigDecimal cost = amtUnit; + if (cost.scale() > (getPrecision()*2)) + { + cost = cost.setScale((getPrecision()*2), BigDecimal.ROUND_HALF_UP); + } + setCurrentCostPrice(cost); + } // setWeightedAverageInitial + /** * Get Costing Precision * @return precision (6) diff --git a/org.adempiere.base/src/org/compiere/model/MCostDetail.java b/org.adempiere.base/src/org/compiere/model/MCostDetail.java index 3591772bd1..24586d8816 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MCostDetail.java @@ -833,7 +833,7 @@ public class MCostDetail extends X_M_CostDetail // get costing level for product MAcctSchema as = MAcctSchema.get(getCtx(), getC_AcctSchema_ID()); - MProduct product = MProduct.get(getCtx(), getM_Product_ID()); + MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName()); String CostingLevel = product.getCostingLevel(as); // Org Element int Org_ID = getAD_Org_ID(); @@ -1152,7 +1152,12 @@ public class MCostDetail extends X_M_CostDetail costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod(); if (MCostElement.COSTINGMETHOD_AverageInvoice.equals(costingMethod)) { - cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty); + if (cost.getCurrentQty().signum() == 0 && qty.signum() == 0) { + // IDEMPIERE-2057 - this is a cost adjustment when there is no qty - setting the initial cost + cost.setWeightedAverageInitial(amt); + } else { + cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty); + } } } else if (addition) @@ -1177,7 +1182,12 @@ public class MCostDetail extends X_M_CostDetail costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod(); if (MCostElement.COSTINGMETHOD_AveragePO.equals(costingMethod)) { - cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty); + if (cost.getCurrentQty().signum() == 0 && qty.signum() == 0) { + // IDEMPIERE-2057 - this is a cost adjustment when there is no qty - setting the initial cost + cost.setWeightedAverageInitial(amt); + } else { + cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty); + } } } else if (addition) diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index 39cc9e6689..0f70e8131c 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -353,7 +353,7 @@ public class MInventoryLine extends X_M_InventoryLine } int M_ASI_ID = getM_AttributeSetInstance_ID(); - MProduct product = getProduct(); + MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName()); MClient client = MClient.get(getCtx()); MAcctSchema as = client.getAcctSchema(); String costingLevel = product.getCostingLevel(as); diff --git a/org.adempiere.base/src/org/compiere/model/MProduct.java b/org.adempiere.base/src/org/compiere/model/MProduct.java index ce10511096..8abfdcc2b2 100644 --- a/org.adempiere.base/src/org/compiere/model/MProduct.java +++ b/org.adempiere.base/src/org/compiere/model/MProduct.java @@ -910,7 +910,7 @@ public class MProduct extends X_M_Product if (ce == null) { return null; } - MCost cost = MCost.get(this, M_ASI_ID, as, AD_Org_ID, ce.getM_CostElement_ID(), (String)null); + MCost cost = MCost.get(this, M_ASI_ID, as, AD_Org_ID, ce.getM_CostElement_ID(), get_TrxName()); return cost.is_new() ? null : cost; } } // MProduct diff --git a/org.adempiere.base/src/org/compiere/model/ProductCost.java b/org.adempiere.base/src/org/compiere/model/ProductCost.java index 8195cbbb34..da243aab49 100644 --- a/org.adempiere.base/src/org/compiere/model/ProductCost.java +++ b/org.adempiere.base/src/org/compiere/model/ProductCost.java @@ -48,7 +48,7 @@ public class ProductCost { m_M_Product_ID = M_Product_ID; if (m_M_Product_ID != 0) - m_product = MProduct.get (ctx, M_Product_ID); + m_product = new MProduct(ctx, M_Product_ID, trxName); m_M_AttributeSetInstance_ID = M_AttributeSetInstance_ID; m_trxName = trxName; } // ProductCost From 792eb8c3689a3b4c4ee72ee177c28aaf6c0c4acc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 12 Nov 2014 18:57:40 -0500 Subject: [PATCH 04/16] IDEMPIERE-2311 bad behavior of info window when after select a record and push enter key / IDEMPIERE-2112 --- .../WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 5143bfbae3..5676622df4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -1390,7 +1390,7 @@ public abstract class InfoPanel extends Window implements EventListener, } else if (keyEvent.getKeyCode() == VK_ENTER) { // Enter // enter in contentpanel to select //when user push enter keyboard at input parameter field - if (contentPanel.getSelectedIndex() >= 0) { + if (m_lookup && contentPanel.getSelectedIndex() >= 0) { onOk(); } else { onUserQuery(); From 913b77387ba5814caddad4f3e1f7ef02c5a0f279 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 13 Nov 2014 13:01:31 -0500 Subject: [PATCH 05/16] IDEMPIERE-2312 Dcoument number can have 'null' in prefix or suffix / based on patch from Nicolas Micoud (nmicoud) --- .../src/org/compiere/model/MSequence.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MSequence.java b/org.adempiere.base/src/org/compiere/model/MSequence.java index 32c905d698..f1a0113477 100644 --- a/org.adempiere.base/src/org/compiere/model/MSequence.java +++ b/org.adempiere.base/src/org/compiere/model/MSequence.java @@ -41,6 +41,7 @@ import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Ini; import org.compiere.util.Trx; +import org.compiere.util.Util; /** * Sequence Model. @@ -519,15 +520,23 @@ public class MSequence extends X_AD_Sequence // create DocumentNo StringBuilder doc = new StringBuilder(); - if (prefix != null && prefix.length() > 0) - doc.append(Env.parseVariable(prefix, po, trxName, false)); - + if (prefix != null && prefix.length() > 0) { + String prefixValue = Env.parseVariable(prefix, po, trxName, false); + if (Util.isEmpty(prefixValue)) + doc.append(prefixValue); + } + if (decimalPattern != null && decimalPattern.length() > 0) doc.append(new DecimalFormat(decimalPattern).format(next)); else doc.append(next); - if (suffix != null && suffix.length() > 0) - doc.append(Env.parseVariable(suffix, po, trxName, false)); + + if (suffix != null && suffix.length() > 0) { + String suffixValue = Env.parseVariable(suffix, po, trxName, false); + if (Util.isEmpty(suffixValue)) + doc.append(suffixValue); + } + String documentNo = doc.toString(); if (s_log.isLoggable(Level.FINER)) s_log.finer (documentNo + " (" + incrementNo + ")" + " - Sequence=" + AD_Sequence_ID + " [" + trx + "]"); From 9e84bd7bb4be4a86f8140bfabcc60094da83ab79 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 14 Nov 2014 08:55:14 -0500 Subject: [PATCH 06/16] IDEMPIERE-2315 Performance issue: Bill BPartner in Purchase Order as Table (full list) --- migration/i2.1/oracle/201411140854_IDEMPIERE-2315.sql | 11 +++++++++++ .../i2.1/postgresql/201411140854_IDEMPIERE-2315.sql | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 migration/i2.1/oracle/201411140854_IDEMPIERE-2315.sql create mode 100644 migration/i2.1/postgresql/201411140854_IDEMPIERE-2315.sql diff --git a/migration/i2.1/oracle/201411140854_IDEMPIERE-2315.sql b/migration/i2.1/oracle/201411140854_IDEMPIERE-2315.sql new file mode 100644 index 0000000000..ca6b11d151 --- /dev/null +++ b/migration/i2.1/oracle/201411140854_IDEMPIERE-2315.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- 14/11/2014 08:54:12 AM COT +-- IDEMPIERE-2315 Performance issue: Bill BPartner in Purchase Order as Table (full list) +UPDATE AD_Field SET AD_Reference_ID=30,Updated=TO_DATE('2014-11-14 08:54:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6505 +; + +SELECT register_migration_script('201411140854_IDEMPIERE-2315.sql') FROM dual +; + diff --git a/migration/i2.1/postgresql/201411140854_IDEMPIERE-2315.sql b/migration/i2.1/postgresql/201411140854_IDEMPIERE-2315.sql new file mode 100644 index 0000000000..5740e69b31 --- /dev/null +++ b/migration/i2.1/postgresql/201411140854_IDEMPIERE-2315.sql @@ -0,0 +1,8 @@ +-- 14/11/2014 08:54:12 AM COT +-- IDEMPIERE-2315 Performance issue: Bill BPartner in Purchase Order as Table (full list) +UPDATE AD_Field SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-11-14 08:54:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6505 +; + +SELECT register_migration_script('201411140854_IDEMPIERE-2315.sql') FROM dual +; + From 4b70e8cdbe93346b450623233dbdf1e4e570d094 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 14 Nov 2014 09:16:25 -0500 Subject: [PATCH 07/16] IDEMPIERE-2316 Inventory Move allows to move to inactive warehouses --- .../src/org/compiere/model/MLocatorLookup.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java index c53d661c2d..391ffbde84 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java @@ -323,23 +323,25 @@ public final class MLocatorLookup extends Lookup implements Serializable int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error int local_only_product_id = getOnly_Product_ID(); - StringBuilder sql = new StringBuilder("SELECT * FROM M_Locator ") - .append(" WHERE IsActive='Y'"); + StringBuilder sql = new StringBuilder("SELECT M_Locator.* FROM M_Locator ") + .append(" INNER JOIN M_Warehouse wh ON (wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID) ") + .append(" WHERE M_Locator.IsActive='Y' ") + .append(" AND wh.IsActive='Y'"); if (local_only_warehouse_id != 0) - sql.append(" AND M_Warehouse_ID=?"); + sql.append(" AND M_Locator.M_Warehouse_ID=?"); if (local_only_product_id != 0) - sql.append(" AND (IsDefault='Y' ") // Default Locator + sql.append(" AND (M_Locator.IsDefault='Y' ") // Default Locator .append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator .append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)") .append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))"); sql.append(" ORDER BY "); if (local_only_warehouse_id == 0) - sql.append("(SELECT wh.Name FROM M_Warehouse wh WHERE wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID),"); + sql.append("wh.Name,"); sql.append("M_Locator.Value"); String finalSql = MRole.getDefault(m_ctx, false).addAccessSQL( - sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); + sql.toString(), "M_Locator", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); if (isInterrupted()) { log.log(Level.SEVERE, "Interrupted"); From 54a5e2dbd3d688e785ae9e866bac2f118eb35c57 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 14 Nov 2014 17:16:31 -0500 Subject: [PATCH 08/16] IDEMPIERE-2312 Dcoument number can have 'null' in prefix or suffix --- org.adempiere.base/src/org/compiere/model/MSequence.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MSequence.java b/org.adempiere.base/src/org/compiere/model/MSequence.java index f1a0113477..3e1ca23654 100644 --- a/org.adempiere.base/src/org/compiere/model/MSequence.java +++ b/org.adempiere.base/src/org/compiere/model/MSequence.java @@ -522,7 +522,7 @@ public class MSequence extends X_AD_Sequence StringBuilder doc = new StringBuilder(); if (prefix != null && prefix.length() > 0) { String prefixValue = Env.parseVariable(prefix, po, trxName, false); - if (Util.isEmpty(prefixValue)) + if (!Util.isEmpty(prefixValue)) doc.append(prefixValue); } @@ -533,7 +533,7 @@ public class MSequence extends X_AD_Sequence if (suffix != null && suffix.length() > 0) { String suffixValue = Env.parseVariable(suffix, po, trxName, false); - if (Util.isEmpty(suffixValue)) + if (!Util.isEmpty(suffixValue)) doc.append(suffixValue); } From 06bc792db536ccce8c8d6cd7ddc6cf615ce5de03 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 18 Nov 2014 18:45:28 -0500 Subject: [PATCH 09/16] IDEMPIERE-2322 Cannot search Date+Time with time portion --- .../src/org/compiere/model/MQuery.java | 4 ++-- .../org/adempiere/webui/window/FindWindow.java | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MQuery.java b/org.adempiere.base/src/org/compiere/model/MQuery.java index bbb0fde4e3..552f6a4a1f 100644 --- a/org.adempiere.base/src/org/compiere/model/MQuery.java +++ b/org.adempiere.base/src/org/compiere/model/MQuery.java @@ -1145,7 +1145,7 @@ class Restriction implements Serializable if (Code instanceof String) sb.append(DB.TO_STRING(Code.toString())); else if (Code instanceof Timestamp) - sb.append(DB.TO_DATE((Timestamp)Code)); + sb.append(DB.TO_DATE((Timestamp)Code, false)); else sb.append(Code); @@ -1157,7 +1157,7 @@ class Restriction implements Serializable if (Code_to instanceof String) sb.append(DB.TO_STRING(Code_to.toString())); else if (Code_to instanceof Timestamp) - sb.append(DB.TO_DATE((Timestamp)Code_to)); + sb.append(DB.TO_DATE((Timestamp)Code_to, false)); else sb.append(Code_to); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index f6fb44ad0d..1f4461e4f8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -1662,8 +1662,10 @@ public class FindWindow extends Window implements EventListener, ValueCha { if (valueTo != null && valueTo.toString().length() > 0) { // range - StringBuilder msglog = new StringBuilder(ColumnName).append(">=").append(value).append("<=").append(valueTo); - if (log.isLoggable(Level.FINE)) log.fine(msglog.toString()); + if (log.isLoggable(Level.FINE)) { + StringBuilder msglog = new StringBuilder(ColumnName).append(">=").append(value).append("<=").append(valueTo); + log.fine(msglog.toString()); + } GridField field = getTargetMField(ColumnName); StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false)); @@ -1671,8 +1673,10 @@ public class FindWindow extends Window implements EventListener, ValueCha ColumnName, wed.getDisplay(), wedTo.getDisplay(), true, 0); appendCode(code, ColumnName, MQuery.BETWEEN, value.toString(), valueTo.toString(), "AND", "", ""); } else { - StringBuilder msglog = new StringBuilder(ColumnName).append("=").append(value); - if (log.isLoggable(Level.FINE)) log.fine(msglog.toString()); + if (log.isLoggable(Level.FINE)) { + StringBuilder msglog = new StringBuilder(ColumnName).append("=").append(value); + log.fine(msglog.toString()); + } // globalqss - Carlos Ruiz - 20060711 // fix a bug with virtualColumn + isSelectionColumn not yielding results @@ -1723,8 +1727,10 @@ public class FindWindow extends Window implements EventListener, ValueCha } } else if (valueTo != null && valueTo.toString().length() > 0) { // filled upper limit without filling lower limit - StringBuilder msglog = new StringBuilder(ColumnName).append("<=").append(valueTo); - if (log.isLoggable(Level.FINE)) log.fine(msglog.toString()); + if (log.isLoggable(Level.FINE)) { + StringBuilder msglog = new StringBuilder(ColumnName).append("<=").append(valueTo); + log.fine(msglog.toString()); + } GridField field = getTargetMField(ColumnName); StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false)); From 7c106e3ddacc03a45879a118d5078e9dc5c81d23 Mon Sep 17 00:00:00 2001 From: Deepak Pansheriya Date: Mon, 17 Nov 2014 20:25:53 +0530 Subject: [PATCH 10/16] IDEMPIERE-2318: Handling NPE and providing meaning full error message --- migration/i2.1/oracle/201411170824_IDEMPIERE-2318.sql | 10 ++++++++++ .../i2.1/postgresql/201411170824_IDEMPIERE-2318.sql | 7 +++++++ org.adempiere.base/src/org/compiere/model/MInOut.java | 5 +++++ .../src/org/compiere/model/MInventoryLine.java | 4 ++++ .../src/org/compiere/model/MMovementLine.java | 4 ++++ org.adempiere.base/src/org/compiere/model/MOrder.java | 5 +++++ 6 files changed, 35 insertions(+) create mode 100644 migration/i2.1/oracle/201411170824_IDEMPIERE-2318.sql create mode 100644 migration/i2.1/postgresql/201411170824_IDEMPIERE-2318.sql diff --git a/migration/i2.1/oracle/201411170824_IDEMPIERE-2318.sql b/migration/i2.1/oracle/201411170824_IDEMPIERE-2318.sql new file mode 100644 index 0000000000..d70e47fcea --- /dev/null +++ b/migration/i2.1/oracle/201411170824_IDEMPIERE-2318.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Nov 17, 2014 6:27:47 PM IST +-- IDEMPIERE-2318: Handling NPE for Attribute not set on product and Batch level costing used +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated) VALUES ('E','No attribute set configured on product ',200328,'D','b8793354-b3b6-4106-8d8a-32d511d5b5d9','NoAttributeSet','Y',100,100,0,0,TO_DATE('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS')) +; + +SELECT register_migration_script('201411170824_IDEMPIERE-2318.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i2.1/postgresql/201411170824_IDEMPIERE-2318.sql b/migration/i2.1/postgresql/201411170824_IDEMPIERE-2318.sql new file mode 100644 index 0000000000..46fcbe6d12 --- /dev/null +++ b/migration/i2.1/postgresql/201411170824_IDEMPIERE-2318.sql @@ -0,0 +1,7 @@ +-- Nov 17, 2014 6:27:47 PM IST +-- IDEMPIERE-2318: Handling NPE for Attribute not set on product and Batch level costing used +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated) VALUES ('E','No attribute set configured on product ',200328,'D','b8793354-b3b6-4106-8d8a-32d511d5b5d9','NoAttributeSet','Y',100,100,0,0,TO_TIMESTAMP('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS')) +; + +SELECT register_migration_script('201411170824_IDEMPIERE-2318.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index f5f1418829..ab1be4ae26 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1190,6 +1190,11 @@ public class MInOut extends X_M_InOut implements DocAction continue; if (product != null && product.isASIMandatory(isSOTrx())) { + if(product.getAttributeSet()==null){ + m_processMsg = "@NoAttributeSet@=" + product.getValue(); + return DocAction.STATUS_Invalid; + + } if (! product.getAttributeSet().excludeTableEntry(MInOutLine.Table_ID, isSOTrx())) { m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() + ", @M_Product_ID@=" + product.getValue() + ")"; diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index 0f70e8131c..e6bf530dd9 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -268,6 +268,10 @@ public class MInventoryLine extends X_M_InventoryLine MProduct product = MProduct.get(getCtx(), getM_Product_ID()); if (product != null && product.isASIMandatory(isSOTrx())) { + if(product.getAttributeSet()==null){ + log.saveError("NoAttributeSet", product.getValue()); + return false; + } if (! product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, isSOTrx())) { log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID)); return false; diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLine.java b/org.adempiere.base/src/org/compiere/model/MMovementLine.java index 05c063fc08..0b704e8a2e 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLine.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLine.java @@ -211,6 +211,10 @@ public class MMovementLine extends X_M_MovementLine // Mandatory Instance MProduct product = getProduct(); if (getM_AttributeSetInstance_ID() == 0) { + if(product.getAttributeSet()==null){ + log.saveError("NoAttributeSet", product.getValue()); + return false; + } if (product != null && product.isASIMandatory(true)) { if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true /*outgoing*/)) { log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID)); diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index 2d4b64a396..ecedb713ce 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -1338,6 +1338,11 @@ public class MOrder extends X_C_Order implements DocAction if (line.getM_Product_ID() > 0 && line.getM_AttributeSetInstance_ID() == 0) { MProduct product = line.getProduct(); if (product.isASIMandatory(isSOTrx())) { + if(product.getAttributeSet()==null){ + m_processMsg = "@NoAttributeSet@=" + product.getValue(); + return DocAction.STATUS_Invalid; + + } if (! product.getAttributeSet().excludeTableEntry(MOrderLine.Table_ID, isSOTrx())) { StringBuilder msg = new StringBuilder("@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #") .append(line.getLine()) From a44979a33a8a53d86b496f8410b9239c1acf84ab Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Nov 2014 08:40:49 -0500 Subject: [PATCH 11/16] IDEMPIERE-2318: Handling NPE and providing meaning full error message --- .../src/org/compiere/model/MMovementLine.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLine.java b/org.adempiere.base/src/org/compiere/model/MMovementLine.java index 0b704e8a2e..fc6af5ec14 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLine.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLine.java @@ -211,7 +211,7 @@ public class MMovementLine extends X_M_MovementLine // Mandatory Instance MProduct product = getProduct(); if (getM_AttributeSetInstance_ID() == 0) { - if(product.getAttributeSet()==null){ + if (product != null && product.getAttributeSet()==null) { log.saveError("NoAttributeSet", product.getValue()); return false; } @@ -231,6 +231,10 @@ public class MMovementLine extends X_M_MovementLine setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID()); } + if (product != null && product.getAttributeSet()==null) { + log.saveError("NoAttributeSet", product.getValue()); + return false; + } if (product != null && product.isASIMandatory(false) && getM_AttributeSetInstanceTo_ID() == 0) { if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false /*incoming*/)) { From 68c97d203221b4cf299818b9c798bbaa7fde94b4 Mon Sep 17 00:00:00 2001 From: Deepak Pansheriya Date: Fri, 14 Nov 2014 13:25:02 +0530 Subject: [PATCH 12/16] IDEMPIERE-2314: Making import inventory process extendible --- .../org/compiere/process/ImportInventory.java | 76 ++++++++++++++----- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java index bb937793bb..841a9a3247 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java @@ -23,6 +23,8 @@ import java.sql.Timestamp; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; +import org.adempiere.model.ImportValidator; +import org.adempiere.process.ImportProcess; import org.compiere.model.I_C_DocType; import org.compiere.model.MAcctSchema; import org.compiere.model.MAttributeSet; @@ -32,6 +34,7 @@ import org.compiere.model.MInventory; import org.compiere.model.MInventoryLine; import org.compiere.model.MProduct; import org.compiere.model.MProductCategoryAcct; +import org.compiere.model.ModelValidationEngine; import org.compiere.model.PO; import org.compiere.model.X_I_Inventory; import org.compiere.util.AdempiereUserError; @@ -50,8 +53,9 @@ import org.compiere.util.ValueNamePair; * * Contributor: * Carlos Ruiz - globalqss - IDEMPIERE-281 Extend Import Inventory to support also internal use + * Deepak Pansheriya - logilite - IDEMPIERE-2314 Making import inventory process extendible */ -public class ImportInventory extends SvrProcess +public class ImportInventory extends SvrProcess implements ImportProcess { /** Client to be imported to */ private int p_AD_Client_ID = 0; @@ -184,6 +188,8 @@ public class ImportInventory extends SvrProcess no = DB.executeUpdate (sql.toString (), get_TrxName()); if (log.isLoggable(Level.INFO)) log.info ("Reset=" + no); + ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE); + sql = new StringBuilder ("UPDATE I_Inventory o ") .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '") .append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0") @@ -330,6 +336,8 @@ public class ImportInventory extends SvrProcess if (no != 0) log.warning ("Required charge=" + no); + ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE); + commitEx(); /*********************************************************************/ @@ -354,6 +362,8 @@ public class ImportInventory extends SvrProcess int x_C_DocType_ID = -1; Timestamp x_MovementDate = null; int x_isInternalUse = -1; + + X_I_Inventory lastImp=null; while (rs.next()) { X_I_Inventory imp = new X_I_Inventory (getCtx (), rs, get_TrxName()); @@ -367,6 +377,9 @@ public class ImportInventory extends SvrProcess || isInternalUse != x_isInternalUse) { if (inventory != null) { + + ModelValidationEngine.get().fireImportValidate(this, lastImp, inventory, ImportValidator.TIMING_AFTER_IMPORT); + if (m_docAction != null && m_docAction.length() > 0) { if (!inventory.processIt(m_docAction)) { log.warning("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); @@ -383,6 +396,8 @@ public class ImportInventory extends SvrProcess inventory.setDescription("I " + imp.getM_Warehouse_ID() + " " + MovementDate); inventory.setM_Warehouse_ID(imp.getM_Warehouse_ID()); inventory.setMovementDate(MovementDate); + + ModelValidationEngine.get().fireImportValidate(this, imp, inventory, ImportValidator.TIMING_BEFORE_IMPORT); // if (!inventory.save()) { @@ -402,23 +417,8 @@ public class ImportInventory extends SvrProcess } MProduct product = new MProduct(getCtx(), imp.getM_Product_ID(), get_TrxName()); // Line - int M_AttributeSetInstance_ID = 0; - if ((imp.getLot() != null && imp.getLot().length() > 0) || (imp.getSerNo() != null && imp.getSerNo().length() > 0)) - { - - if (product.isInstanceAttribute()) - { - MAttributeSet mas = product.getAttributeSet(); - MAttributeSetInstance masi = new MAttributeSetInstance(getCtx(), 0, mas.getM_AttributeSet_ID(), get_TrxName()); - if (mas.isLot() && imp.getLot() != null) - masi.setLot(imp.getLot(), imp.getM_Product_ID()); - if (mas.isSerNo() && imp.getSerNo() != null) - masi.setSerNo(imp.getSerNo()); - masi.setDescription(); - masi.saveEx(); - M_AttributeSetInstance_ID = masi.getM_AttributeSetInstance_ID(); - } - } + int M_AttributeSetInstance_ID = generateASI(product,imp); + MInventoryLine line = new MInventoryLine (inventory, imp.getM_Locator_ID(), imp.getM_Product_ID(), M_AttributeSetInstance_ID, imp.getQtyBook(), imp.getQtyCount(), imp.getQtyInternalUse()); @@ -428,6 +428,9 @@ public class ImportInventory extends SvrProcess else line.setInventoryType(MInventoryLine.INVENTORYTYPE_InventoryDifference); line.setC_Charge_ID(imp.getC_Charge_ID()); + + ModelValidationEngine.get().fireImportValidate(this, imp, line, ImportValidator.TIMING_BEFORE_IMPORT); + if (line.save()) { imp.setI_IsImported(true); @@ -450,6 +453,9 @@ public class ImportInventory extends SvrProcess log.log(Level.SEVERE, "Inventory Line not saved"); break; } + + ModelValidationEngine.get().fireImportValidate(this, imp, line, ImportValidator.TIMING_AFTER_IMPORT); + lastImp = imp; } if (inventory != null) { if (m_docAction != null && m_docAction.length() > 0) { @@ -499,8 +505,28 @@ public class ImportInventory extends SvrProcess return ""; } // doIt + protected int generateASI(MProduct product,X_I_Inventory imp){ + int M_AttributeSetInstance_ID = 0; + if ((imp.getLot() != null && imp.getLot().length() > 0) || (imp.getSerNo() != null && imp.getSerNo().length() > 0)) + { + + if (product.isInstanceAttribute()) + { + MAttributeSet mas = product.getAttributeSet(); + MAttributeSetInstance masi = new MAttributeSetInstance(getCtx(), 0, mas.getM_AttributeSet_ID(), get_TrxName()); + if (mas.isLot() && imp.getLot() != null) + masi.setLot(imp.getLot(), imp.getM_Product_ID()); + if (mas.isSerNo() && imp.getSerNo() != null) + masi.setSerNo(imp.getSerNo()); + masi.setDescription(); + masi.saveEx(); + M_AttributeSetInstance_ID = masi.getM_AttributeSetInstance_ID(); + } + } + return M_AttributeSetInstance_ID; + } - private void updateCosting(X_I_Inventory imp, MProduct product, + protected void updateCosting(X_I_Inventory imp, MProduct product, MInventoryLine line) { String costingLevel = null; if(product.getM_Product_Category_ID() > 0){ @@ -549,4 +575,16 @@ public class ImportInventory extends SvrProcess imp.saveEx(); } + + @Override + public String getImportTableName() { + return X_I_Inventory.Table_Name; + } + + + @Override + public String getWhereClause() { + StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(p_AD_Client_ID); + return msgreturn.toString(); + } } // ImportInventory From bd58ca4a3f8ac57579de3402af5f8cdf83554e04 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Nov 2014 10:01:05 -0500 Subject: [PATCH 13/16] IDEMPIERE-2323 Payment Rule editor doesn't have context menu --- .../webui/editor/WPaymentEditor.java | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java index 64f926476d..7b9ff39229 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java @@ -16,15 +16,19 @@ package org.adempiere.webui.editor; import javax.swing.event.ListDataListener; import org.adempiere.webui.AdempiereWebUI; +import org.adempiere.webui.ValuePreference; import org.adempiere.webui.adwindow.ADTabpanel; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.form.WPaymentFormFactory; import org.adempiere.webui.apps.form.WPaymentFormWindow; import org.adempiere.webui.component.Paymentbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.event.ContextMenuEvent; +import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.theme.ThemeManager; +import org.adempiere.webui.window.WFieldRecordInfo; import org.compiere.grid.IPaymentForm; import org.compiere.model.GridField; import org.compiere.model.GridTab; @@ -45,7 +49,7 @@ import org.zkoss.zul.Comboitem; * @author Elaine * */ -public class WPaymentEditor extends WEditor implements ListDataListener { +public class WPaymentEditor extends WEditor implements ListDataListener, ContextMenuListener { public final static String ON_SAVE_PAYMENT = "onSavePayment"; @@ -79,6 +83,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener { lookup.refresh(); refreshList(); } + popupMenu = new WEditorPopupMenu(false, true, isShowPreference()); + addChangeLogMenu(popupMenu); } @Override @@ -349,4 +355,41 @@ public class WPaymentEditor extends WEditor implements ListDataListener { public String[] getEvents() { return LISTENER_EVENTS; } + + @Override + public void onMenu(ContextMenuEvent evt) + { + if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent())) + { + actionRefresh(); + } + else if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent())) + { + if (isShowPreference()) + ValuePreference.start (getComponent(), this.getGridField(), getValue()); + return; + } + else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent())) + { + WFieldRecordInfo.start(gridField); + } + } + + public void actionRefresh() + { + if (lookup != null) + { + Object curValue = getValue(); + + if (isReadWrite()) + lookup.refresh(); + else + refreshList(); + if (curValue != null) + { + setValue(curValue); + } + } + } + } From 6be4c15be0b96506ce5d11067a2d08b3288cde43 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Nov 2014 11:33:36 -0500 Subject: [PATCH 14/16] IDEMPIERE-2324 Env.parseVariable(String, PO, String, boolean) doesn't use format when keepUnparseable / based on patch from Nicolas Micoud (nmicoud) --- org.adempiere.base/src/org/compiere/util/Env.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index f981e1d390..7d74195772 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -1480,8 +1480,12 @@ public final class Env String v = Env.getContext(ctx, token); if (v != null && v.length() > 0) outStr.append(v); - else if (keepUnparseable) - outStr.append("@"+token+"@"); + else if (keepUnparseable) { + outStr.append("@").append(token); + if (!Util.isEmpty(format)) + outStr.append("<").append(format).append(">"); + outStr.append("@"); + } } else if (po != null) { //take from po if (po.get_ColumnIndex(token) >= 0) { @@ -1525,7 +1529,10 @@ public final class Env } } } else if (keepUnparseable) { - outStr.append("@"+token+"@"); + outStr.append("@").append(token); + if (!Util.isEmpty(format)) + outStr.append("<").append(format).append(">"); + outStr.append("@"); } } From 1ed3200c50462bd2f7400b44a1fdb7c36a0d6d85 Mon Sep 17 00:00:00 2001 From: jan thielemann Date: Wed, 19 Nov 2014 13:51:54 -0500 Subject: [PATCH 15/16] IDEMPIERE-2288 Load custom ToolbarButton Images (IAction) from OSGi Bundle --- .../org/adempiere/webui/action/Actions.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java index 87e70ea264..1c8c95bdc8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java @@ -56,19 +56,21 @@ public class Actions { } if (aImage != null) return aImage; - - String path = ACTION_IMAGES_PATH + actionId + "24.png"; - InputStream inputStream = Actions.class.getClassLoader().getResourceAsStream(path); - if (inputStream != null) { - try { - aImage = new AImage(actionId, inputStream); - } catch (IOException e) { - } - } - if (aImage != null) { - synchronized (imageCache) { - imageCache.put(actionId, aImage); + + IServiceHolder action = Service.locator().locate(IAction.class, actionId, null); + if (action.getService() != null) { + String path = ACTION_IMAGES_PATH + actionId + "24.png"; + InputStream inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path); + if (inputStream != null) { + try { + aImage = new AImage(actionId, inputStream); + } catch (IOException e) { + } } + if (aImage != null) + synchronized (imageCache) { + imageCache.put(actionId, aImage); + } } return aImage; } From 9c62f0254b2ee972fbba75f1aec45632f7d73a1f Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Nov 2014 15:49:36 -0500 Subject: [PATCH 16/16] IDEMPIERE-2326 Deadlock on workflow email after complete --- org.adempiere.base/src/org/compiere/model/MClient.java | 2 +- org.adempiere.base/src/org/compiere/wf/MWFActivity.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MClient.java b/org.adempiere.base/src/org/compiere/model/MClient.java index 5aa4c532ce..b31296eb92 100644 --- a/org.adempiere.base/src/org/compiere/model/MClient.java +++ b/org.adempiere.base/src/org/compiere/model/MClient.java @@ -731,7 +731,7 @@ public class MClient extends X_AD_Client msg = email.send(); } // - X_AD_UserMail um = new X_AD_UserMail(getCtx(), 0, null); + X_AD_UserMail um = new X_AD_UserMail(getCtx(), 0, to.get_TrxName()); um.setClientOrg(this); um.setAD_User_ID(to.getAD_User_ID()); um.setSubject(email.getSubject()); diff --git a/org.adempiere.base/src/org/compiere/wf/MWFActivity.java b/org.adempiere.base/src/org/compiere/wf/MWFActivity.java index 6aea61a1ae..d38fc37c96 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWFActivity.java +++ b/org.adempiere.base/src/org/compiere/wf/MWFActivity.java @@ -1691,7 +1691,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable { if (AD_User_ID != 0) { - MUser user = MUser.get(getCtx(), AD_User_ID); + MUser user = new MUser(getCtx(), AD_User_ID, get_TrxName()); email = user.getEMail(); if (email != null && email.length() > 0) {