From c663b563b43c321d063bc4e963f73ff3a511248d Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 3 Aug 2017 14:05:44 +0200 Subject: [PATCH] IDEMPIERE-3443 Payment Schedule leading to -> Current record was changed by another user, please ReQuery --- .../i4.1/oracle/201708031402_IDEMPIERE-3443.sql | 15 +++++++++++++++ .../postgresql/201708031402_IDEMPIERE-3443.sql | 12 ++++++++++++ .../src/org/compiere/model/CalloutInvoice.java | 3 ++- .../src/org/compiere/model/CalloutOrder.java | 2 ++ .../src/org/compiere/model/MInvoice.java | 14 ++++++++++++++ .../src/org/compiere/model/MOrder.java | 16 +++++++++++++++- 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 migration/i4.1/oracle/201708031402_IDEMPIERE-3443.sql create mode 100644 migration/i4.1/postgresql/201708031402_IDEMPIERE-3443.sql diff --git a/migration/i4.1/oracle/201708031402_IDEMPIERE-3443.sql b/migration/i4.1/oracle/201708031402_IDEMPIERE-3443.sql new file mode 100644 index 0000000000..e1df99b3fd --- /dev/null +++ b/migration/i4.1/oracle/201708031402_IDEMPIERE-3443.sql @@ -0,0 +1,15 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3443 +-- Aug 3, 2017 2:01:39 PM CEST +UPDATE AD_Column SET Callout=NULL,Updated=TO_DATE('2017-08-03 14:01:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2187 +; + +-- Aug 3, 2017 2:02:05 PM CEST +UPDATE AD_Column SET Callout=NULL,Updated=TO_DATE('2017-08-03 14:02:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3500 +; + +SELECT register_migration_script('201708031402_IDEMPIERE-3443.sql') FROM dual +; + diff --git a/migration/i4.1/postgresql/201708031402_IDEMPIERE-3443.sql b/migration/i4.1/postgresql/201708031402_IDEMPIERE-3443.sql new file mode 100644 index 0000000000..f5b6eb6d64 --- /dev/null +++ b/migration/i4.1/postgresql/201708031402_IDEMPIERE-3443.sql @@ -0,0 +1,12 @@ +-- IDEMPIERE-3443 +-- Aug 3, 2017 2:01:39 PM CEST +UPDATE AD_Column SET Callout=NULL,Updated=TO_TIMESTAMP('2017-08-03 14:01:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2187 +; + +-- Aug 3, 2017 2:02:05 PM CEST +UPDATE AD_Column SET Callout=NULL,Updated=TO_TIMESTAMP('2017-08-03 14:02:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3500 +; + +SELECT register_migration_script('201708031402_IDEMPIERE-3443.sql') FROM dual +; + diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java index d937cafebc..a88914c794 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java @@ -275,7 +275,9 @@ public class CalloutInvoice extends CalloutEngine * @param mField field * @param value value * @return null or error message + * @Deprecated - business logic moved to MInvoice.beforeSave - must not create/delete external records with callouts */ + @Deprecated public String paymentTerm (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) { Integer C_PaymentTerm_ID = (Integer)value; @@ -290,7 +292,6 @@ public class CalloutInvoice extends CalloutEngine boolean valid = pt.apply (C_Invoice_ID); mTab.setValue("IsPayScheduleValid", valid ? "Y" : "N"); - return ""; } // paymentTerm diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 8600179ba8..89050f16d0 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -745,7 +745,9 @@ public class CalloutOrder extends CalloutEngine * @param mField field * @param value value * @return null or error message + * @Deprecated - business logic moved to MOrder.beforeSave - must not create/delete external records with callouts */ + @Deprecated public String paymentTerm (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) { Integer C_PaymentTerm_ID = (Integer)value; diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index c48ce7252d..c53c958515 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -927,6 +927,7 @@ public class MInvoice extends X_C_Invoice implements DocAction } // validatePaySchedule + private volatile static boolean recursiveCall = false; /************************************************************************** * Before Save * @param newRecord new @@ -1028,6 +1029,19 @@ public class MInvoice extends X_C_Invoice implements DocAction } } + if (! recursiveCall && (newRecord || is_ValueChanged(COLUMNNAME_C_PaymentTerm_ID))) { + recursiveCall = true; + try { + MPaymentTerm pt = new MPaymentTerm (getCtx(), getC_PaymentTerm_ID(), get_TrxName()); + boolean valid = pt.apply(this); + setIsPayScheduleValid(valid); + } catch (Exception e) { + throw e; + } finally { + recursiveCall = false; + } + } + return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index ed7a0e1021..55134abab9 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -71,7 +71,7 @@ public class MOrder extends X_C_Order implements DocAction /** * */ - private static final long serialVersionUID = -4032643956656204341L; + private static final long serialVersionUID = -7784588474522162502L; /** * Create new Order by copying @@ -921,6 +921,7 @@ public class MOrder extends X_C_Order implements DocAction } // validatePaySchedule + private volatile static boolean recursiveCall = false; /************************************************************************** * Before Save * @param newRecord new @@ -1089,6 +1090,19 @@ public class MOrder extends X_C_Order implements DocAction } } + if (! recursiveCall && (newRecord || is_ValueChanged(COLUMNNAME_C_PaymentTerm_ID))) { + recursiveCall = true; + try { + MPaymentTerm pt = new MPaymentTerm (getCtx(), getC_PaymentTerm_ID(), get_TrxName()); + boolean valid = pt.applyOrder(this); + setIsPayScheduleValid(valid); + } catch (Exception e) { + throw e; + } finally { + recursiveCall = false; + } + } + return true; } // beforeSave