IDEMPIERE-1649 Reference of User1_id, User2_id in new table is create incorrect / based on patch from Hiep
This commit is contained in:
parent
bc9b8049bc
commit
b90759bae2
|
@ -0,0 +1,19 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Mar 12, 2014 4:51:42 PM COT
|
||||||
|
-- IDEMPIERE-1649 set tab default
|
||||||
|
UPDATE AD_Column SET DefaultValue='Y',Updated=TO_DATE('2014-03-12 16:51:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=166
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Mar 12, 2014 4:52:00 PM COT
|
||||||
|
ALTER TABLE AD_Tab MODIFY IsSingleRow CHAR(1) DEFAULT 'Y'
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Mar 12, 2014 4:52:02 PM COT
|
||||||
|
UPDATE AD_Tab SET IsSingleRow='Y' WHERE IsSingleRow IS NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201403121652_IDEMPIERE-1649.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
-- Mar 12, 2014 4:51:42 PM COT
|
||||||
|
-- IDEMPIERE-1649 set tab default
|
||||||
|
UPDATE AD_Column SET DefaultValue='Y',Updated=TO_TIMESTAMP('2014-03-12 16:51:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=166
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Mar 12, 2014 4:52:00 PM COT
|
||||||
|
INSERT INTO t_alter_column values('ad_tab','IsSingleRow','CHAR(1)',null,'Y')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Mar 12, 2014 4:52:02 PM COT
|
||||||
|
UPDATE AD_Tab SET IsSingleRow='Y' WHERE IsSingleRow IS NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201403121652_IDEMPIERE-1649.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.compiere.util.DisplayType;
|
||||||
public class Callout_AD_Column extends CalloutEngine
|
public class Callout_AD_Column extends CalloutEngine
|
||||||
{
|
{
|
||||||
public String columnName (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
|
public String columnName (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
|
||||||
{
|
{ // IDEMPIERE-1011 - dup code on MColumn.setmartDefaults
|
||||||
I_AD_Column column = GridTabWrapper.create(mTab, I_AD_Column.class);
|
I_AD_Column column = GridTabWrapper.create(mTab, I_AD_Column.class);
|
||||||
if (MColumn.isSuggestSelectionColumn(column.getColumnName(), true))
|
if (MColumn.isSuggestSelectionColumn(column.getColumnName(), true))
|
||||||
column.setIsSelectionColumn(true);
|
column.setIsSelectionColumn(true);
|
||||||
|
|
|
@ -157,6 +157,21 @@ public class TabCreateFields extends SvrProcess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set display logic for accounting dimensions
|
||||||
|
if (column.getColumnName().equalsIgnoreCase("AD_OrgTrx_ID")){
|
||||||
|
field.setDisplayLogic("@$Element_OT@=Y");
|
||||||
|
} else if (column.getColumnName().equalsIgnoreCase("C_Campaign_ID")) {
|
||||||
|
field.setDisplayLogic("@$Element_MC@=Y");
|
||||||
|
} else if (column.getColumnName().equalsIgnoreCase("C_Activity_ID")) {
|
||||||
|
field.setDisplayLogic("@$Element_AY@=Y");
|
||||||
|
} else if (column.getColumnName().equalsIgnoreCase("C_Project_ID")) {
|
||||||
|
field.setDisplayLogic("@$Element_PJ@=Y");
|
||||||
|
} else if (column.getColumnName().equalsIgnoreCase("User1_ID")) {
|
||||||
|
field.setDisplayLogic("@$Element_U1@=Y");
|
||||||
|
} else if (column.getColumnName().equalsIgnoreCase("User2_ID")) {
|
||||||
|
field.setDisplayLogic("@$Element_U2@=Y");
|
||||||
|
}
|
||||||
|
|
||||||
if (field.save())
|
if (field.save())
|
||||||
{
|
{
|
||||||
addLog(0, null, null, column.getName());
|
addLog(0, null, null, column.getName());
|
||||||
|
|
|
@ -273,38 +273,12 @@ public class TableCreateColumns extends SvrProcess
|
||||||
column.setAD_Element_ID (element.getAD_Element_ID ());
|
column.setAD_Element_ID (element.getAD_Element_ID ());
|
||||||
//
|
//
|
||||||
column.setIsMandatory ("NO".equals (nullable));
|
column.setIsMandatory ("NO".equals (nullable));
|
||||||
// Key
|
|
||||||
if (columnName.equalsIgnoreCase (tableName + "_ID"))
|
|
||||||
{
|
|
||||||
column.setIsKey (true);
|
|
||||||
column.setAD_Reference_ID (DisplayType.ID);
|
|
||||||
column.setIsUpdateable(false);
|
|
||||||
}
|
|
||||||
//handle uuid column xolali bug IDEMPIERE-971
|
|
||||||
if (columnName.equalsIgnoreCase (PO.getUUIDColumnName(table.getTableName())))
|
|
||||||
{
|
|
||||||
column.setAD_Reference_ID (DisplayType.String);
|
|
||||||
column.setIsUpdateable(false);
|
|
||||||
column.setIsAllowCopy(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
// bug [ 1637912 ]
|
// bug [ 1637912 ]
|
||||||
else if (columnName.toUpperCase ().endsWith("_ACCT")
|
if (columnName.toUpperCase ().endsWith("_ACCT")
|
||||||
&& size == 10)
|
&& size == 10)
|
||||||
column.setAD_Reference_ID (DisplayType.Account);
|
column.setAD_Reference_ID (DisplayType.Account);
|
||||||
// Account
|
|
||||||
else if (columnName.equalsIgnoreCase ("C_Location_ID"))
|
|
||||||
column.setAD_Reference_ID (DisplayType.Location);
|
|
||||||
// Product Attribute
|
|
||||||
else if (columnName.equalsIgnoreCase ("M_AttributeSetInstance_ID"))
|
|
||||||
column.setAD_Reference_ID (DisplayType.PAttribute);
|
|
||||||
// SalesRep_ID (=User)
|
|
||||||
else if (columnName.equalsIgnoreCase ("SalesRep_ID"))
|
|
||||||
{
|
|
||||||
column.setAD_Reference_ID (DisplayType.Table);
|
|
||||||
column.setAD_Reference_Value_ID (190);
|
|
||||||
}
|
|
||||||
// ID
|
// ID
|
||||||
else if (columnName.toUpperCase().endsWith ("_ID"))
|
else if (columnName.toUpperCase().endsWith ("_ID"))
|
||||||
column.setAD_Reference_ID (DisplayType.TableDir);
|
column.setAD_Reference_ID (DisplayType.TableDir);
|
||||||
|
@ -315,20 +289,6 @@ public class TableCreateColumns extends SvrProcess
|
||||||
|| columnName.equalsIgnoreCase ("Created")
|
|| columnName.equalsIgnoreCase ("Created")
|
||||||
|| columnName.equalsIgnoreCase ("Updated"))
|
|| columnName.equalsIgnoreCase ("Updated"))
|
||||||
column.setAD_Reference_ID (DisplayType.DateTime);
|
column.setAD_Reference_ID (DisplayType.DateTime);
|
||||||
// CreatedBy/UpdatedBy (=User)
|
|
||||||
else if (columnName.equalsIgnoreCase ("CreatedBy")
|
|
||||||
|| columnName.equalsIgnoreCase ("UpdatedBy"))
|
|
||||||
{
|
|
||||||
column.setAD_Reference_ID (DisplayType.Table);
|
|
||||||
column.setAD_Reference_Value_ID (110);
|
|
||||||
column.setIsUpdateable(false);
|
|
||||||
}
|
|
||||||
// Entity Type
|
|
||||||
else if (columnName.equalsIgnoreCase ("EntityType"))
|
|
||||||
{
|
|
||||||
column.setAD_Reference_ID (DisplayType.Table);
|
|
||||||
column.setAD_Reference_Value_ID (389);
|
|
||||||
}
|
|
||||||
// CLOB
|
// CLOB
|
||||||
else if (dataType == Types.CLOB)
|
else if (dataType == Types.CLOB)
|
||||||
column.setAD_Reference_ID (DisplayType.TextLong);
|
column.setAD_Reference_ID (DisplayType.TextLong);
|
||||||
|
@ -348,14 +308,6 @@ public class TableCreateColumns extends SvrProcess
|
||||||
// List
|
// List
|
||||||
else if (size < 4 && dataType == Types.CHAR)
|
else if (size < 4 && dataType == Types.CHAR)
|
||||||
column.setAD_Reference_ID (DisplayType.List);
|
column.setAD_Reference_ID (DisplayType.List);
|
||||||
// Name, DocumentNo
|
|
||||||
else if (columnName.equalsIgnoreCase ("Name")
|
|
||||||
|| columnName.equals ("DocumentNo"))
|
|
||||||
{
|
|
||||||
column.setAD_Reference_ID (DisplayType.String);
|
|
||||||
column.setIsIdentifier (true);
|
|
||||||
column.setSeqNo (1);
|
|
||||||
}
|
|
||||||
// String, Text
|
// String, Text
|
||||||
else if (dataType == Types.CHAR || dataType == Types.VARCHAR
|
else if (dataType == Types.CHAR || dataType == Types.VARCHAR
|
||||||
|| typeName.startsWith ("NVAR")
|
|| typeName.startsWith ("NVAR")
|
||||||
|
@ -381,6 +333,8 @@ public class TableCreateColumns extends SvrProcess
|
||||||
else
|
else
|
||||||
column.setAD_Reference_ID (DisplayType.String);
|
column.setAD_Reference_ID (DisplayType.String);
|
||||||
|
|
||||||
|
column.setSmartDefaults();
|
||||||
|
|
||||||
column.setFieldLength (size);
|
column.setFieldLength (size);
|
||||||
if (column.isUpdateable()
|
if (column.isUpdateable()
|
||||||
&& (table.isView()
|
&& (table.isView()
|
||||||
|
@ -390,10 +344,6 @@ public class TableCreateColumns extends SvrProcess
|
||||||
|| columnName.toUpperCase().equals("UPDATED") ))
|
|| columnName.toUpperCase().equals("UPDATED") ))
|
||||||
column.setIsUpdateable(false);
|
column.setIsUpdateable(false);
|
||||||
|
|
||||||
// Check if is a possible selection column
|
|
||||||
if (MColumn.isSuggestSelectionColumn(column.getColumnName(), false))
|
|
||||||
column.setIsSelectionColumn(true);
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
if (column.save ())
|
if (column.save ())
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class MColumn extends X_AD_Column
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 4321132594207949196L;
|
private static final long serialVersionUID = -4372212315789445915L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MColumn from Cache
|
* Get MColumn from Cache
|
||||||
|
@ -734,4 +734,100 @@ public class MColumn extends X_AD_Column
|
||||||
return foreignTable;
|
return foreignTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSmartDefaults() { // IDEMPIERE-1649 - dup code on Callout_AD_Column.columnName
|
||||||
|
if (MColumn.isSuggestSelectionColumn(getColumnName(), true))
|
||||||
|
setIsSelectionColumn(true);
|
||||||
|
|
||||||
|
// IDEMPIERE-1011
|
||||||
|
if (PO.getUUIDColumnName(getAD_Table().getTableName()).equals(getColumnName())) {
|
||||||
|
// UUID column
|
||||||
|
setAD_Reference_ID(DisplayType.String);
|
||||||
|
setAD_Val_Rule_ID(0);
|
||||||
|
setAD_Reference_Value_ID(0);
|
||||||
|
setFieldLength(36);
|
||||||
|
setDefaultValue(null);
|
||||||
|
setMandatoryLogic(null);
|
||||||
|
setReadOnlyLogic(null);
|
||||||
|
setIsIdentifier(false);
|
||||||
|
setIsUpdateable(false);
|
||||||
|
setIsAlwaysUpdateable(false);
|
||||||
|
setIsKey(true);
|
||||||
|
} else if (getAD_Table().getTableName().concat("_ID").equals(getColumnName())) {
|
||||||
|
// ID key column
|
||||||
|
setAD_Reference_ID(DisplayType.ID);
|
||||||
|
setAD_Val_Rule_ID(0);
|
||||||
|
setAD_Reference_Value_ID(0);
|
||||||
|
setFieldLength(22);
|
||||||
|
setDefaultValue(null);
|
||||||
|
setMandatoryLogic(null);
|
||||||
|
setReadOnlyLogic(null);
|
||||||
|
setIsIdentifier(false);
|
||||||
|
setIsUpdateable(false);
|
||||||
|
setIsAlwaysUpdateable(false);
|
||||||
|
} else {
|
||||||
|
// get defaults from most used case
|
||||||
|
String sql = ""
|
||||||
|
+ "SELECT AD_Reference_ID, "
|
||||||
|
+ " AD_Val_Rule_ID, "
|
||||||
|
+ " AD_Reference_Value_ID, "
|
||||||
|
+ " FieldLength, "
|
||||||
|
+ " DefaultValue, "
|
||||||
|
+ " MandatoryLogic, "
|
||||||
|
+ " ReadOnlyLogic, "
|
||||||
|
+ " IsIdentifier, "
|
||||||
|
+ " IsUpdateable, "
|
||||||
|
+ " IsAlwaysUpdateable, "
|
||||||
|
+ " FKConstraintType,"
|
||||||
|
+ " COUNT(*) "
|
||||||
|
+ "FROM AD_Column "
|
||||||
|
+ "WHERE ColumnName = ? "
|
||||||
|
+ "GROUP BY AD_Reference_ID, "
|
||||||
|
+ " AD_Val_Rule_ID, "
|
||||||
|
+ " AD_Reference_Value_ID, "
|
||||||
|
+ " FieldLength, "
|
||||||
|
+ " DefaultValue, "
|
||||||
|
+ " MandatoryLogic, "
|
||||||
|
+ " ReadOnlyLogic, "
|
||||||
|
+ " IsIdentifier, "
|
||||||
|
+ " IsUpdateable, "
|
||||||
|
+ " IsAlwaysUpdateable, "
|
||||||
|
+ " FKConstraintType "
|
||||||
|
+ "ORDER BY COUNT(*) DESC ";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setString(1, getColumnName());
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
|
if (rs.next()) {
|
||||||
|
int ad_reference_id = rs.getInt(1);
|
||||||
|
if (ad_reference_id == DisplayType.ID)
|
||||||
|
ad_reference_id = DisplayType.TableDir;
|
||||||
|
setAD_Reference_ID(ad_reference_id);
|
||||||
|
setAD_Val_Rule_ID(rs.getInt(2));
|
||||||
|
setAD_Reference_Value_ID(rs.getInt(3));
|
||||||
|
setFieldLength(rs.getInt(4));
|
||||||
|
setDefaultValue(rs.getString(5));
|
||||||
|
setMandatoryLogic(rs.getString(6));
|
||||||
|
setReadOnlyLogic(rs.getString(7));
|
||||||
|
setIsIdentifier("Y".equals(rs.getString(8)));
|
||||||
|
setIsUpdateable("Y".equals(rs.getString(9)));
|
||||||
|
setIsAlwaysUpdateable("Y".equals(rs.getString(10)));
|
||||||
|
setFKConstraintType(rs.getString(11));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
throw new DBException(e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null;
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // MColumn
|
} // MColumn
|
||||||
|
|
Loading…
Reference in New Issue