hg merge release-5.1 (merge release5.1 into default)

This commit is contained in:
Carlos Ruiz 2018-02-24 12:25:39 +01:00
commit e4118787d8
13 changed files with 119 additions and 124 deletions

View File

@ -92,7 +92,10 @@ public class OrderRePrice extends SvrProcess
for (int i = 0; i < lines.length; i++)
{
lines[i].setPrice(invoice.getM_PriceList_ID(), invoice.getC_BPartner_ID());
lines[i].saveEx();
if (lines[i].is_Changed()) {
lines[i].setTaxAmt();
lines[i].saveEx();
}
}
invoice = new MInvoice (getCtx(), p_C_Invoice_ID, null);
BigDecimal newPrice = invoice.getGrandTotal();

View File

@ -181,6 +181,8 @@ public class DBException extends AdempiereException
* @param e exception
*/
public static boolean isInvalidIdentifierError(Exception e) {
if (DB.isPostgreSQL())
return isSQLState(e, "42P01");
return isErrorCode(e, 904);
}

View File

@ -1312,9 +1312,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
public void setLinkColumnName (String linkColumnName)
{
// set parent column name
String sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?";
if (m_vo.Parent_Column_ID > 0)
m_parentColumnName = DB.getSQLValueString(null, sql, m_vo.Parent_Column_ID );
m_parentColumnName = MColumn.getColumnName(m_vo.ctx, m_vo.Parent_Column_ID);
if ( m_parentColumnName == null )
m_parentColumnName = "";
@ -1329,27 +1328,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
// we have a link column identified (primary parent column)
else
{
String SQL = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, m_vo.AD_Column_ID); // Parent Link Column
rs = pstmt.executeQuery();
if (rs.next())
m_linkColumnName = rs.getString(1);
}
catch (SQLException e)
{
log.log(Level.SEVERE, "", e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_linkColumnName = MColumn.getColumnName(m_vo.ctx, m_vo.AD_Column_ID); // Parent Link Column
if (log.isLoggable(Level.FINE)) log.fine("AD_Column_ID=" + m_vo.AD_Column_ID + " - " + m_linkColumnName);
}
}

View File

@ -49,6 +49,7 @@ import java.util.logging.Level;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException;
import org.adempiere.util.ServerContext;
import org.compiere.Adempiere;
@ -3542,7 +3543,7 @@ public class GridTable extends AbstractTableModel
if (DBException.isInvalidIdentifierError(e0))
log.warning("Count - " + e0.getLocalizedMessage() + "\nSQL=" + m_SQL_Count);
else
log.log(Level.SEVERE, "Count SQL=" + m_SQL_Count, e0);
throw new AdempiereException(e0);
return 0;
}
finally

View File

@ -457,7 +457,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
BigDecimal TaxAmt = Env.ZERO;
if (getC_Tax_ID() == 0)
return;
// setLineNetAmt();
setLineNetAmt();
MTax tax = MTax.get (getCtx(), getC_Tax_ID());
if (tax.isDocumentLevel() && m_IsSOTrx) // AR Inv Tax
return;

View File

@ -91,42 +91,18 @@ public class MLookupFactory
public static MLookupInfo getLookupInfo(Properties ctx, int WindowNo, int TabNo, int Column_ID, int AD_Reference_ID)
{
String ColumnName = "";
int AD_Reference_Value_ID = 0;
boolean IsParent = false;
MColumn column = MColumn.get(ctx, Column_ID);
if (column.get_ID() == 0)
s_log.log(Level.SEVERE, "Column Not Found - AD_Column_ID=" + Column_ID);
String ColumnName = column.getColumnName();
int AD_Reference_Value_ID = column.getAD_Reference_Value_ID();
boolean IsParent = column.isParent();
String ValidationCode = "";
//
String sql = "SELECT c.ColumnName, c.AD_Reference_Value_ID, c.IsParent, vr.Code "
+ "FROM AD_Column c"
+ " LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) "
+ "WHERE c.AD_Column_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Column_ID);
//
rs = pstmt.executeQuery();
if (rs.next())
{
ColumnName = rs.getString(1);
AD_Reference_Value_ID = rs.getInt(2);
IsParent = "Y".equals(rs.getString(3));
ValidationCode = rs.getString(4);
}
else
s_log.log(Level.SEVERE, "Column Not Found - AD_Column_ID=" + Column_ID);
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, "create", ex);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
if (column.getAD_Val_Rule_ID() > 0) {
MValRule valRule = MValRule.get(ctx, column.getAD_Val_Rule_ID());
ValidationCode = valRule.getCode();
}
//
MLookupInfo info = getLookupInfo (ctx, WindowNo, TabNo, Column_ID, AD_Reference_ID,
@ -993,41 +969,12 @@ public class MLookupFactory
} // getLookup_TableDirEmbed
private static ArrayList<LookupDisplayColumn> getListIdentifiers(String TableName) {
// get display column name (first identifier column)
String sql = "SELECT c.ColumnName,c.IsTranslated,c.AD_Reference_ID,c.AD_Reference_Value_ID "
+ ", c.ColumnSQL " // 5
+ "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) "
+ "WHERE TableName=?"
+ " AND c.IsIdentifier='Y' "
+ "ORDER BY c.SeqNo";
//
ArrayList<LookupDisplayColumn> list = new ArrayList<LookupDisplayColumn>();
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, TableName);
rs = pstmt.executeQuery();
while (rs.next())
{
LookupDisplayColumn ldc = new LookupDisplayColumn (rs.getString(1),
rs.getString(5),
"Y".equals(rs.getString(2)), rs.getInt(3), rs.getInt(4));
list.add (ldc);
}
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, sql, e);
return null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
MTable table = MTable.get(Env.getCtx(), TableName);
for (String idColumnName : table.getIdentifierColumns()) {
MColumn column = table.getColumn(idColumnName);
LookupDisplayColumn ldc = new LookupDisplayColumn(column.getColumnName(), column.getColumnSQL(), column.isTranslated(), column.getAD_Reference_ID(), column.getAD_Reference_Value_ID());
list.add (ldc);
}
return list;
}

View File

@ -15,16 +15,18 @@ import org.compiere.util.Env;
*
*/
public class MStyle extends X_AD_Style {
/**
*
*/
private static final long serialVersionUID = -5183438249097292583L;
private static final long serialVersionUID = 4988653330824933725L;
/** Cache */
private static CCache<Integer,MStyle> s_cache = new CCache<Integer,MStyle>(Table_Name, 30, 60);
private X_AD_StyleLine[] m_lines = null;
public static final String SCLASS_PREFIX = "@sclass=";
public static final String ZCLASS_PREFIX = "@zclass=";
public MStyle(Properties ctx, int AD_Style_ID, String trxName) {
super(ctx, AD_Style_ID, trxName);
}

View File

@ -20,6 +20,8 @@ package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -33,6 +35,7 @@ import org.adempiere.model.GenericPO;
import org.compiere.util.CCache;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.KeyNamePair;
/**
* Persistent Table Model
@ -356,19 +359,26 @@ public class MTable extends X_AD_Table
* Get Identifier Columns of Table
* @return Identifier columns
*/
public String[] getIdentifierColumns()
{
getColumns(false);
ArrayList<String> list = new ArrayList<String>();
//
for (int i = 0; i < m_columns.length; i++)
{
MColumn column = m_columns[i];
public String[] getIdentifierColumns() {
ArrayList<KeyNamePair> listkn = new ArrayList<KeyNamePair>();
for (MColumn column : getColumns(false)) {
if (column.isIdentifier())
list.add(column.getColumnName());
listkn.add(new KeyNamePair(column.getSeqNo(), column.getColumnName()));
}
// Order by SeqNo
Collections.sort(listkn, new Comparator<KeyNamePair>(){
public int compare(KeyNamePair s1,KeyNamePair s2){
if (s1.getKey() < s2.getKey())
return -1;
else if (s1.getKey() > s2.getKey())
return 1;
else
return 0;
}});
String[] retValue = new String[listkn.size()];
for (int i = 0; i < listkn.size(); i++) {
retValue[i] = listkn.get(i).getName();
}
String[] retValue = new String[list.size()];
retValue = list.toArray(retValue);
return retValue;
} // getIdentifierColumns

View File

@ -1047,6 +1047,8 @@ public class AdempiereMonitor extends HttpServlet
for (int i = 0; i < clients.length; i++)
{
MClient client = clients[i];
if (!client.isActive())
continue;
if (i > 0)
p.addElement(" - ");
p.addElement(new a("idempiereMonitor?EMail=" + client.getAD_Client_ID(), client.getName()));

View File

@ -299,7 +299,28 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
styleBuilder.append("; ");
styleBuilder.append(inlineStyle);
}
component.setStyle(styleBuilder.toString());
setComponentStyle(component, styleBuilder.toString());
}
protected void setComponentStyle(HtmlBasedComponent component, String style) {
if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = style.substring(MStyle.SCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setSclass(sclass);
else
component.setSclass(sclass);
} else if (style != null && style.startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = style.substring(MStyle.ZCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setZclass(zclass);
else
component.setZclass(zclass);
} else {
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setStyle(style);
else
component.setStyle(style);
}
}
/**

View File

@ -593,9 +593,18 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
}
}
protected void setLabelStyle(String style) {
if (label != null)
label.setStyle(style);
protected void setLabelStyle(String style) {
if (label != null) {
if (style != null && style.toLowerCase().startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = style.substring(MStyle.SCLASS_PREFIX.length());
label.setSclass(sclass);
} else if (style != null && style.toLowerCase().startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = style.substring(MStyle.ZCLASS_PREFIX.length());
label.setZclass(zclass);
} else {
label.setStyle(style);
}
}
}
protected void applyFieldStyles(boolean applyDictionaryStyle) {
@ -607,12 +616,26 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
setFieldStyle(style);
}
protected void setFieldStyle(String style) {
protected void setFieldStyle(String style) {
HtmlBasedComponent component = (HtmlBasedComponent) getComponent();
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setStyle(style);
else
component.setStyle(style);
if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = style.substring(MStyle.SCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setSclass(sclass);
else
component.setSclass(sclass);
} else if (style != null && style.startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = style.substring(MStyle.ZCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setZclass(zclass);
else
component.setZclass(zclass);
} else {
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setStyle(style);
else
component.setStyle(style);
}
}
protected String buildStyle(int AD_Style_ID) {

View File

@ -27,6 +27,8 @@ import org.adempiere.webui.window.WFieldSuggestion;
import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
import org.compiere.model.MZoomCondition;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -134,16 +136,14 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
this.updateEnabled = false;
// check possible zoom conditions to enable back zoom
for (int zoomCondWinID :
DB.getIDsEx(null,
"SELECT AD_Window_ID FROM AD_ZoomCondition WHERE IsActive='Y' AND AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE TableName=?)",
tableName)) {
Boolean canAccessZoom = MRole.getDefault().getWindowAccess(zoomCondWinID);
MTable table = MTable.get(Env.getCtx(), tableName);
for (MZoomCondition zoomCondition : MZoomCondition.getConditions(table.getAD_Table_ID())) {
Boolean canAccessZoom = MRole.getDefault().getWindowAccess(zoomCondition.getAD_Window_ID());
if (canAccessZoom != null && canAccessZoom) {
this.zoomEnabled = true;
break;
}
}
}
} else {
int cnt = DB.getSQLValueEx(null,
"SELECT COUNT(*) "

View File

@ -667,7 +667,12 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
GridField mField = m_findFields[i];
boolean isDisplayed = mField.isDisplayed();
if (mField.getVO().displayType == DisplayType.YesNo) {
if (DisplayType.isText(mField.getVO().displayType)) {
// for string fields allow searching long strings - useful for like and similar to searches
mField.getVO().FieldLength = 32767; // a conservative max literal string - like oracle extended
mField.getVO().DisplayLength = mField.getVO().FieldLength;
}
if (mField.getVO().displayType == DisplayType.YesNo) {
// Make Yes-No searchable as list
GridFieldVO vo = mField.getVO();
GridFieldVO ynvo = vo.clone(m_simpleCtx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);