From fee1504c4e8fe803ad9e39b696e8e61162b70ef6 Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Tue, 13 Oct 2009 02:42:23 +0000 Subject: [PATCH] Forecast Line not validated the warehouse with Organization https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2877525&group_id=176962 kind regards Victor Perez www.e-evolution.com --- base/src/org/compiere/model/MForecast.java | 55 +++++++++++++++++++ .../src/org/compiere/model/MForecastLine.java | 40 +++++++++++++- .../oracle/596_BF2877525_FixForecast.sql | 5 ++ .../postgresql/596_BF2877525_FixForecast.sql | 5 ++ 4 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 base/src/org/compiere/model/MForecast.java create mode 100644 migration/354a-trunk/oracle/596_BF2877525_FixForecast.sql create mode 100644 migration/354a-trunk/postgresql/596_BF2877525_FixForecast.sql diff --git a/base/src/org/compiere/model/MForecast.java b/base/src/org/compiere/model/MForecast.java new file mode 100644 index 0000000000..506d3ead2f --- /dev/null +++ b/base/src/org/compiere/model/MForecast.java @@ -0,0 +1,55 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. * + * Contributor(s): Victor Perez www.e-evolution.com * + *****************************************************************************/ +package org.compiere.model; + +import java.sql.ResultSet; +import java.util.Properties; + + +/** + * Forecast Model + * + * @author victor.perez@e-evolution.com, www.e-evolution.com + */ +public class MForecast extends X_M_Forecast +{ + + + /** + * + */ + private static final long serialVersionUID = 66771328316032322L; + + /** + * Standard Constructor + * @param ctx context + * @param M_ForecastLine_ID id + */ + public MForecast (Properties ctx, int M_Forecast_ID, String trxName) + { + super (ctx, M_Forecast_ID, trxName); + } // MForecastLine + + /** + * Load Constructor + * @param ctx context + * @param rs result set + */ + public MForecast (Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } // MForecast +} // MForecast diff --git a/base/src/org/compiere/model/MForecastLine.java b/base/src/org/compiere/model/MForecastLine.java index 8105bfa9c2..11d1fc37c3 100644 --- a/base/src/org/compiere/model/MForecastLine.java +++ b/base/src/org/compiere/model/MForecastLine.java @@ -17,6 +17,7 @@ package org.compiere.model; import java.sql.ResultSet; import java.util.Properties; +import org.adempiere.exceptions.WarehouseInvalidForOrgException; /** @@ -27,10 +28,14 @@ import java.util.Properties; */ public class MForecastLine extends X_M_ForecastLine { + + /** * */ - private static final long serialVersionUID = -4757137580071600111L; + private static final long serialVersionUID = -3420900505079279058L; + /** Parent */ + private MForecast m_parent = null; /** * Standard Constructor @@ -50,5 +55,36 @@ public class MForecastLine extends X_M_ForecastLine public MForecastLine (Properties ctx, ResultSet rs, String trxName) { super(ctx, rs, trxName); - } // MRequisitionLine + } // MForecastLine + + /************************************************************************** + * Before Save + * @param newRecord + * @return true if it can be saved + */ + protected boolean beforeSave (boolean newRecord) + { + if (newRecord + || is_ValueChanged("AD_Org_ID") || is_ValueChanged("M_Warehouse_ID")) + { + MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID()); + if (wh.getAD_Org_ID() != getAD_Org_ID()) + { + throw new WarehouseInvalidForOrgException(wh.getName(), MOrg.get(getCtx(), getAD_Org_ID()).getName()); + } + } + return true; + } + + /** + * Get Parent + * @return parent + */ + public MForecast getParent() + { + if (m_parent == null) + m_parent = new MForecast(getCtx(), getM_Forecast_ID(), get_TrxName()); + return m_parent; + } // getParent + } // MForecastLine diff --git a/migration/354a-trunk/oracle/596_BF2877525_FixForecast.sql b/migration/354a-trunk/oracle/596_BF2877525_FixForecast.sql new file mode 100644 index 0000000000..2eb010b474 --- /dev/null +++ b/migration/354a-trunk/oracle/596_BF2877525_FixForecast.sql @@ -0,0 +1,5 @@ +-- Oct 12, 2009 9:06:07 PM CDT +-- Forecast +UPDATE AD_Column SET AD_Val_Rule_ID=189,Updated=TO_DATE('2009-10-12 21:06:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53411 +; + diff --git a/migration/354a-trunk/postgresql/596_BF2877525_FixForecast.sql b/migration/354a-trunk/postgresql/596_BF2877525_FixForecast.sql new file mode 100644 index 0000000000..2fe7c68baa --- /dev/null +++ b/migration/354a-trunk/postgresql/596_BF2877525_FixForecast.sql @@ -0,0 +1,5 @@ +-- Oct 12, 2009 9:06:07 PM CDT +-- Forecast +UPDATE AD_Column SET AD_Val_Rule_ID=189,Updated=TO_TIMESTAMP('2009-10-12 21:06:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53411 +; +