hg merge release-2.1 (merge release2.1 into development)

This commit is contained in:
Carlos Ruiz 2015-03-25 19:02:45 -05:00
commit e4c0fdd849
12 changed files with 217 additions and 29 deletions

View File

@ -0,0 +1,28 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-2540: Allowing Vendor qty break to specify breaks for all customers
-- Mar 25, 2015 12:46:56 PM IST
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2015-03-25 12:46:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56928
;
-- Mar 25, 2015 12:46:59 PM IST
ALTER TABLE M_ProductPriceVendorBreak MODIFY C_BPartner_ID NUMBER(10) DEFAULT NULL
;
-- Mar 25, 2015 12:47:00 PM IST
ALTER TABLE M_ProductPriceVendorBreak MODIFY C_BPartner_ID NULL
;
-- Mar 25, 2015 12:47:00 PM IST
ALTER TABLE M_ProductPriceVendorBreak DROP CONSTRAINT cbpartner_mproductpricevendorb
;
-- Mar 25, 2015 12:47:00 PM IST
ALTER TABLE M_ProductPriceVendorBreak ADD CONSTRAINT cbpartner_mproductpricevendorb FOREIGN KEY (C_BPartner_ID) REFERENCES c_bpartner(c_bpartner_id) DEFERRABLE INITIALLY DEFERRED
;
SELECT register_migration_script('201503251255_IDEMPIERE-2540.sql') FROM dual
;

View File

@ -0,0 +1,25 @@
-- IDEMPIERE-2540: Allowing Vendor qty break to specify breaks for all customers
-- Mar 25, 2015 12:46:56 PM IST
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2015-03-25 12:46:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56928
;
-- Mar 25, 2015 12:46:59 PM IST
INSERT INTO t_alter_column values('m_productpricevendorbreak','C_BPartner_ID','NUMERIC(10)',null,'NULL')
;
-- Mar 25, 2015 12:47:00 PM IST
INSERT INTO t_alter_column values('m_productpricevendorbreak','C_BPartner_ID',null,'NULL',null)
;
-- Mar 25, 2015 12:47:00 PM IST
ALTER TABLE M_ProductPriceVendorBreak DROP CONSTRAINT cbpartner_mproductpricevendorb
;
-- Mar 25, 2015 12:47:00 PM IST
ALTER TABLE M_ProductPriceVendorBreak ADD CONSTRAINT cbpartner_mproductpricevendorb FOREIGN KEY (C_BPartner_ID) REFERENCES c_bpartner(c_bpartner_id) DEFERRABLE INITIALLY DEFERRED
;
SELECT register_migration_script('201503251255_IDEMPIERE-2540.sql') FROM dual
;

View File

@ -1101,7 +1101,14 @@ public class CalloutOrder extends CalloutEngine
if (log.isLoggable(Level.FINE)) log.fine("QtyChanged -> PriceActual=" + pp.getPriceStd()
+ ", PriceEntered=" + PriceEntered + ", Discount=" + pp.getDiscount());
PriceActual = pp.getPriceStd();
PriceEntered = pp.getPriceStd();
Discount = pp.getDiscount();
PriceLimit = pp.getPriceLimit();
PriceList = pp.getPriceList();
mTab.setValue("PriceList", pp.getPriceList());
mTab.setValue("PriceLimit", pp.getPriceLimit());
mTab.setValue("PriceActual", pp.getPriceStd());
mTab.setValue("PriceEntered", pp.getPriceStd());
mTab.setValue("Discount", pp.getDiscount());
mTab.setValue("PriceEntered", PriceEntered);
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");

View File

@ -21,6 +21,7 @@ import java.util.logging.Level;
import org.compiere.model.MField;
import org.compiere.model.MTab;
import org.compiere.util.AdempiereUserError;
import org.compiere.util.DB;
/**
@ -62,6 +63,40 @@ public class TabCopy extends SvrProcess
*/
protected String doIt() throws Exception
{
final String sqluptrltab = ""
+ "UPDATE ad_tab_trl "
+ "SET name = (SELECT name "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " description = (SELECT description "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " help = (SELECT help "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " commitwarning = (SELECT commitwarning "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " istranslated = (SELECT istranslated "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language) "
+ "WHERE ad_tab_id = ?";
final String sqluptrlfld = ""
+ "UPDATE ad_field_trl "
+ "SET name = (SELECT name "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language), "
+ " description = (SELECT description "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language), "
+ " help = (SELECT help "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language), "
+ " istranslated = (SELECT istranslated "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language) "
+ "WHERE ad_field_id = ?";
if (log.isLoggable(Level.INFO)) log.info("To AD_Tab_ID=" + p_AD_TabTo_ID + ", From=" + p_AD_TabFrom_ID);
MTab from = new MTab (getCtx(), p_AD_TabFrom_ID, get_TrxName());
if (from.get_ID() == 0)
@ -71,6 +106,7 @@ public class TabCopy extends SvrProcess
throw new AdempiereUserError("@NotFound@ (to<-) @AD_Tab_ID@");
if (from.getAD_Table_ID() != to.getAD_Table_ID())
throw new AdempiereUserError("@Error@ @AD_Table_ID@");
DB.executeUpdateEx(sqluptrltab, new Object[]{from.get_ID(),from.get_ID(),from.get_ID(),from.get_ID(),from.get_ID(),to.get_ID()}, get_TrxName());
int count = 0;
for (MField oldField : from.getFields(false, get_TrxName()))
@ -78,10 +114,12 @@ public class TabCopy extends SvrProcess
MField newField = new MField (to, oldField);
if (! oldField.isActive())
newField.setIsActive(false);
if (newField.save())
if (newField.save()) {
DB.executeUpdateEx(sqluptrlfld, new Object[]{oldField.get_ID(),oldField.get_ID(),oldField.get_ID(),oldField.get_ID(),newField.get_ID()}, get_TrxName());
count++;
else
} else {
throw new AdempiereUserError("@Error@ @AD_Field_ID@");
}
}
StringBuilder msgreturn = new StringBuilder("@Copied@ #").append(count);
return msgreturn.toString();

View File

@ -22,6 +22,7 @@ import org.compiere.model.MField;
import org.compiere.model.MTab;
import org.compiere.model.MWindow;
import org.compiere.util.AdempiereUserError;
import org.compiere.util.DB;
/**
@ -63,6 +64,55 @@ public class WindowCopy extends SvrProcess
*/
protected String doIt() throws Exception
{
final String sqluptrlwin = ""
+ "UPDATE ad_window_trl "
+ "SET name = (SELECT name "
+ " FROM ad_window_trl t2 "
+ " WHERE t2.ad_window_id = ? AND t2.ad_language = ad_window_trl.ad_language), "
+ " description = (SELECT description "
+ " FROM ad_window_trl t2 "
+ " WHERE t2.ad_window_id = ? AND t2.ad_language = ad_window_trl.ad_language), "
+ " help = (SELECT help "
+ " FROM ad_window_trl t2 "
+ " WHERE t2.ad_window_id = ? AND t2.ad_language = ad_window_trl.ad_language), "
+ " istranslated = (SELECT istranslated "
+ " FROM ad_window_trl t2 "
+ " WHERE t2.ad_window_id = ? AND t2.ad_language = ad_window_trl.ad_language) "
+ "WHERE ad_window_id = ?";
final String sqluptrltab = ""
+ "UPDATE ad_tab_trl "
+ "SET name = (SELECT name "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " description = (SELECT description "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " help = (SELECT help "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " commitwarning = (SELECT commitwarning "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language), "
+ " istranslated = (SELECT istranslated "
+ " FROM ad_tab_trl t2 "
+ " WHERE t2.ad_tab_id = ? AND t2.ad_language = ad_tab_trl.ad_language) "
+ "WHERE ad_tab_id = ?";
final String sqluptrlfld = ""
+ "UPDATE ad_field_trl "
+ "SET name = (SELECT name "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language), "
+ " description = (SELECT description "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language), "
+ " help = (SELECT help "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language), "
+ " istranslated = (SELECT istranslated "
+ " FROM ad_field_trl t2 "
+ " WHERE t2.ad_field_id = ? AND t2.ad_language = ad_field_trl.ad_language) "
+ "WHERE ad_field_id = ?";
if (log.isLoggable(Level.INFO)) log.info("doIt - To AD_Window_ID=" + p_AD_WindowTo_ID + ", From=" + p_AD_WindowFrom_ID);
MWindow from = new MWindow (getCtx(), p_AD_WindowFrom_ID, get_TrxName());
if (from.get_ID() == 0)
@ -70,6 +120,7 @@ public class WindowCopy extends SvrProcess
MWindow to = new MWindow (getCtx(), p_AD_WindowTo_ID, get_TrxName());
if (to.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ (to<-) @AD_Window_ID@");
DB.executeUpdateEx(sqluptrlwin, new Object[]{from.get_ID(),from.get_ID(),from.get_ID(),from.get_ID(),to.get_ID()}, get_TrxName());
int tabCount = 0;
int fieldCount = 0;
@ -80,6 +131,7 @@ public class WindowCopy extends SvrProcess
MTab newTab = new MTab (to, oldTab);
if (newTab.save())
{
DB.executeUpdateEx(sqluptrltab, new Object[]{oldTab.get_ID(),oldTab.get_ID(),oldTab.get_ID(),oldTab.get_ID(),oldTab.get_ID(),newTab.get_ID()}, get_TrxName());
tabCount++;
// Copy Fields
for (MField oldField : oldTab.getFields(false, get_TrxName()))
@ -87,10 +139,12 @@ public class WindowCopy extends SvrProcess
MField newField = new MField (newTab, oldField);
if (! oldField.isActive())
newField.setIsActive(false);
if (newField.save())
if (newField.save()) {
DB.executeUpdateEx(sqluptrlfld, new Object[]{oldField.get_ID(),oldField.get_ID(),oldField.get_ID(),oldField.get_ID(),newField.get_ID()}, get_TrxName());
fieldCount++;
else
} else {
throw new AdempiereUserError("@Error@ @AD_Field_ID@");
}
}
}
else

View File

@ -528,6 +528,10 @@ public abstract class Doc
// post
p_Status = postLogic ();
}
else
{
p_Status = STATUS_Posted; // skipped is OK
}
}
catch (Exception e)
{

View File

@ -56,7 +56,7 @@ public class MClient extends X_AD_Client
/**
*
*/
private static final long serialVersionUID = -4479164806149932775L;
private static final long serialVersionUID = -4420908648355523008L;
/**
* Get client
@ -82,7 +82,19 @@ public class MClient extends X_AD_Client
*/
public static MClient[] getAll (Properties ctx)
{
return getAll(ctx, "");
} // getAll
/**
* Get all clients
* @param ctx context
* @param order by clause
* @return clients
*/
public static MClient[] getAll (Properties ctx, String orderBy)
{
List<MClient> list = new Query(ctx,I_AD_Client.Table_Name,null,null)
.setOrderBy(orderBy)
.list();
for(MClient client:list ){
s_cache.put (new Integer (client.getAD_Client_ID()), client);

View File

@ -52,7 +52,7 @@ public class MProductPricing
m_Qty = Qty;
m_isSOTrx = isSOTrx;
int thereAreVendorBreakRecords = DB.getSQLValue(null,
"SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND C_BPartner_ID=?",
"SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND (C_BPartner_ID=? OR C_BPartner_ID is NULL)",
m_M_Product_ID, m_C_BPartner_ID);
m_useVendorBreak = thereAreVendorBreakRecords > 0;
} // MProductPricing
@ -440,9 +440,9 @@ public class MProductPricing
+ " AND pp.IsActive='Y'"
+ " AND p.M_Product_ID=?" // #1
+ " AND pv.M_PriceList_Version_ID=?" // #2
+ " AND pp.C_BPartner_ID=?" // #3
+ " AND (pp.C_BPartner_ID=? OR pp.C_BPartner_ID is NULL)" // #3
+ " AND ?>=pp.BreakValue" // #4
+ " ORDER BY BreakValue DESC";
+ " ORDER BY pp.C_BPartner_ID, BreakValue DESC";
m_calculated = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -561,9 +561,9 @@ public class MProductPricing
+ " AND pp.IsActive='Y'"
+ " AND p.M_Product_ID=?" // #1
+ " AND pv.M_PriceList_ID=?" // #2
+ " AND pp.C_BPartner_ID=?" // #3
+ " AND (pp.C_BPartner_ID=? OR pp.C_BPartner_ID is NULL)" // #3
+ " AND ?>=pp.BreakValue" // #4
+ " ORDER BY pv.ValidFrom DESC, BreakValue DESC";
+ " ORDER BY pp.C_BPartner_ID, pv.ValidFrom DESC, BreakValue DESC";
m_calculated = false;
if (m_PriceDate == null)
m_PriceDate = new Timestamp (System.currentTimeMillis());
@ -646,9 +646,9 @@ public class MProductPricing
+ " AND pp.IsActive='Y'"
+ " AND p.M_Product_ID=?" // #1
+ " AND pl.M_PriceList_ID=?" // #2
+ " AND pp.C_BPartner_ID=?" // #3
+ " AND (pp.C_BPartner_ID=? OR pp.C_BPartner_ID is NULL)" // #3
+ " AND ?>=pp.BreakValue" // #4
+ " ORDER BY pv.ValidFrom DESC, BreakValue DESC";
+ " ORDER BY pp.C_BPartner_ID, pv.ValidFrom DESC, BreakValue DESC";
m_calculated = false;
if (m_PriceDate == null)
m_PriceDate = new Timestamp (System.currentTimeMillis());

View File

@ -684,7 +684,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
Record_ID = -1;
}
Boolean canAccess = null;
if (Record_ID >= 0) {
if (Record_ID >= 0 && mTable != null) {
int AD_Window_ID = Env.getZoomWindowID(mTable.get_ID(), Record_ID);
canAccess = MRole.getDefault().getWindowAccess(AD_Window_ID);
}

View File

@ -771,7 +771,9 @@ public class Login
// IDEMPIERE-1717 Maintenance mode
if (! MRole.get(m_ctx, AD_Role_ID).isAccessAdvanced()) {
if (MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, AD_Client_ID))
if (MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, 0))
return Msg.getMsg(m_ctx, "SystemInMaintenance");
if (AD_Client_ID != 0 && MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, AD_Client_ID))
return Msg.getMsg(m_ctx, "SystemInMaintenance");
}

View File

@ -866,7 +866,7 @@ public class TimeUtil
calEnd.set(Calendar.MILLISECOND, 0);
while (cal.before(calEnd) || cal.equals(calEnd)) {
if (!nbd.contains(new Timestamp(cal.getTimeInMillis()))) {
if (nbd == null || !nbd.contains(new Timestamp(cal.getTimeInMillis()))) {
if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
retValue++;
}

View File

@ -65,6 +65,7 @@ import org.compiere.model.AdempiereProcessorLog;
import org.compiere.model.MClient;
import org.compiere.model.MSession;
import org.compiere.model.MStore;
import org.compiere.model.MSysConfig;
import org.compiere.model.MSystem;
import org.compiere.model.Query;
import org.compiere.server.AdempiereServerGroup;
@ -95,7 +96,8 @@ public class AdempiereMonitor extends HttpServlet
/**
*
*/
private static final long serialVersionUID = -387582087015910664L;
private static final long serialVersionUID = -7455613826465213838L;
/** Logger */
private static CLogger log = CLogger.getCLogger(AdempiereMonitor.class);
/** The Server */
@ -1005,7 +1007,7 @@ public class AdempiereMonitor extends HttpServlet
table.setCellPadding(2);
//
line = new tr();
MClient[] clients = MClient.getAll(ctx);
MClient[] clients = MClient.getAll(ctx, "AD_Client_ID");
line.addElement(new th().addElement("Client #" + clients.length + " - EMail Test:"));
p = new p();
for (int i = 0; i < clients.length; i++)
@ -1044,6 +1046,8 @@ public class AdempiereMonitor extends HttpServlet
p = new p();
for (int i = 0; i < clients.length; i++) {
MClient client = clients[i];
if (!client.isActive())
continue;
if (i > 0)
p.addElement(" - ");
int count = 0;
@ -1059,20 +1063,34 @@ public class AdempiereMonitor extends HttpServlet
table.addElement(line);
//
line = new tr();
int inMaintenanceClients[] = DB.getIDsEx(null, "SELECT AD_Client_ID FROM AD_SysConfig WHERE Name = 'SYSTEM_IN_MAINTENANCE_MODE' AND Value = 'Y'");
line.addElement(new th().addElement("Maintenance Mode #"+inMaintenanceClients.length));
boolean isSystemInMaintenance = MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, 0);
List<Integer> inMaintenanceClients = new ArrayList<Integer>();
if (isSystemInMaintenance)
line.addElement(new th().addElement("Maintenance Mode"));
else {
int possiblyInMaintenanceClients[] = DB.getIDsEx(null, "SELECT AD_Client_ID FROM AD_SysConfig WHERE AD_Client_ID!=0 AND IsActive='Y' AND Name=?", MSysConfig.SYSTEM_IN_MAINTENANCE_MODE);
for (int clientId : possiblyInMaintenanceClients) {
boolean isTenantInMaintenance = MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, clientId);
if (isTenantInMaintenance)
inMaintenanceClients.add(clientId);
}
line.addElement(new th().addElement("Maintenance Mode #"+inMaintenanceClients.size()));
}
p = new p();
if (inMaintenanceClients.length > 0) {
for (int i = 0; i < clients.length; i++) {
MClient client = clients[i];
if (i > 0)
if (isSystemInMaintenance)
p.addElement("All clients are in maintenance mode");
else if (inMaintenanceClients.size() > 0) {
boolean first = true;
for (int clientID : inMaintenanceClients) {
MClient client = MClient.get(ctx, clientID);
if (!client.isActive())
continue;
if (!first)
p.addElement(" - ");
for (int clientID : inMaintenanceClients) {
if (client.getAD_Client_ID() == clientID)
p.addElement(client.getName() + " : Yes");
else
p.addElement(client.getName() + " : No");
}
p.addElement(client.getName());
first = false;
}
}
else