IDEMPIERE-67 ProcessedOn should not be copied by MOrder.copyFrom / IDEMPIERE-922 / IDEMPIERE-938 / Restored backward compatibility on copying AD_Org_ID
This commit is contained in:
parent
131a60a9de
commit
470202287c
|
@ -0,0 +1,32 @@
|
||||||
|
-- Backward compatibility with old PO copyValues method
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND ColumnName IN (
|
||||||
|
'Created',
|
||||||
|
'CreatedBy',
|
||||||
|
'Updated',
|
||||||
|
'UpdatedBy',
|
||||||
|
'IsActive',
|
||||||
|
'AD_Client_ID',
|
||||||
|
'AD_Org_ID',
|
||||||
|
'Processing'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- new columns found to be problematic
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND ColumnName IN (
|
||||||
|
'ProcessedOn'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- key columns
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND IsKey='Y';
|
||||||
|
|
||||||
|
-- virtual columns
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND ColumnSQL IS NOT NULL;
|
||||||
|
|
||||||
|
-- UUID columns
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND columnname = (SELECT tablename||'_UU' FROM ad_table t where t.ad_table_id=ad_column.ad_table_id);
|
||||||
|
|
||||||
|
-- allow copy of AD_Org_ID on field but not on column (for backward compatibility)
|
||||||
|
UPDATE AD_Field SET IsAllowCopy='Y' WHERE COALESCE(IsAllowCopy,'N')='N' AND AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE ColumnName = 'AD_Org_ID');
|
||||||
|
|
||||||
|
SELECT register_migration_script('201306171349_IDEMPIERE-67.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- Backward compatibility with old PO copyValues method
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND ColumnName IN (
|
||||||
|
'Created',
|
||||||
|
'CreatedBy',
|
||||||
|
'Updated',
|
||||||
|
'UpdatedBy',
|
||||||
|
'IsActive',
|
||||||
|
'AD_Client_ID',
|
||||||
|
'AD_Org_ID',
|
||||||
|
'Processing'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- new columns found to be problematic
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND ColumnName IN (
|
||||||
|
'ProcessedOn'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- key columns
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND IsKey='Y';
|
||||||
|
|
||||||
|
-- virtual columns
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND ColumnSQL IS NOT NULL;
|
||||||
|
|
||||||
|
-- UUID columns
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N' WHERE IsAllowCopy='Y' AND columnname = (SELECT tablename||'_UU' FROM ad_table t where t.ad_table_id=ad_column.ad_table_id);
|
||||||
|
|
||||||
|
-- allow copy of AD_Org_ID on field but not on column (for backward compatibility)
|
||||||
|
UPDATE AD_Field SET IsAllowCopy='Y' WHERE COALESCE(IsAllowCopy,'N')='N' AND AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE ColumnName = 'AD_Org_ID');
|
||||||
|
|
||||||
|
SELECT register_migration_script('201306171349_IDEMPIERE-67.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class ColumnEncryption extends SvrProcess {
|
||||||
int dt = column.getAD_Reference_ID();
|
int dt = column.getAD_Reference_ID();
|
||||||
|
|
||||||
// Can it be enabled?
|
// Can it be enabled?
|
||||||
if (column.isKey() || column.isParent() || column.isStandardColumn()
|
if (column.isKey() || column.isParent() || column.isStandardColumn() || column.isUUIDColumn()
|
||||||
|| column.isVirtualColumn() || column.isIdentifier()
|
|| column.isVirtualColumn() || column.isIdentifier()
|
||||||
|| column.isTranslated() || DisplayType.isLookup(dt)
|
|| column.isTranslated() || DisplayType.isLookup(dt)
|
||||||
|| DisplayType.isLOB(dt) || DisplayType.isDate(dt) || DisplayType.isNumeric(dt)
|
|| DisplayType.isLOB(dt) || DisplayType.isDate(dt) || DisplayType.isNumeric(dt)
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class GridField
|
||||||
// Set Attributes
|
// Set Attributes
|
||||||
loadLookup();
|
loadLookup();
|
||||||
setError(false);
|
setError(false);
|
||||||
} // MField
|
} // GridField
|
||||||
|
|
||||||
/** Value Object */
|
/** Value Object */
|
||||||
private GridFieldVO m_vo;
|
private GridFieldVO m_vo;
|
||||||
|
@ -106,7 +106,7 @@ public class GridField
|
||||||
*/
|
*/
|
||||||
protected void dispose()
|
protected void dispose()
|
||||||
{
|
{
|
||||||
// log.fine( "MField.dispose = " + m_vo.ColumnName);
|
// log.fine( "GridField.dispose = " + m_vo.ColumnName);
|
||||||
m_propertyChangeListeners = null;
|
m_propertyChangeListeners = null;
|
||||||
if (m_lookup != null)
|
if (m_lookup != null)
|
||||||
m_lookup.dispose();
|
m_lookup.dispose();
|
||||||
|
@ -1090,6 +1090,36 @@ public class GridField
|
||||||
* @return true if allow copy
|
* @return true if allow copy
|
||||||
*/
|
*/
|
||||||
public boolean isAllowCopy() {
|
public boolean isAllowCopy() {
|
||||||
|
/* IDEMPIERE-67
|
||||||
|
* Extending MColumn.isStandardColumn
|
||||||
|
* Force some additional columns to forbid copy from the UI
|
||||||
|
*/
|
||||||
|
String colname = getColumnName();
|
||||||
|
if ( colname.equals("C_CashLine_ID")
|
||||||
|
|| colname.equals("C_Location_ID")
|
||||||
|
|| colname.equals("C_Payment_ID")
|
||||||
|
|| colname.equals("DocAction")
|
||||||
|
|| colname.equals("DocStatus")
|
||||||
|
|| colname.equals("DocumentNo")
|
||||||
|
|| colname.equals("EntityType")
|
||||||
|
|| colname.equals("GrandTotal")
|
||||||
|
|| colname.equals("IsAllocated")
|
||||||
|
|| colname.equals("IsApproved")
|
||||||
|
|| colname.equals("IsDelivered")
|
||||||
|
|| colname.equals("IsGenerated")
|
||||||
|
|| colname.equals("IsInvoiced")
|
||||||
|
|| colname.equals("IsPaid")
|
||||||
|
|| colname.equals("IsReconciled")
|
||||||
|
|| colname.equals("IsSelfService")
|
||||||
|
|| colname.equals("Line")
|
||||||
|
|| colname.equals("Posted")
|
||||||
|
|| colname.equals("Processed")
|
||||||
|
|| colname.equals("ProcessedOn")
|
||||||
|
|| colname.equals("TotalCr")
|
||||||
|
|| colname.equals("TotalDr")
|
||||||
|
|| colname.equals("TotalLines")
|
||||||
|
|| colname.startsWith("Ref_"))
|
||||||
|
return false;
|
||||||
return m_vo.IsAllowCopy;
|
return m_vo.IsAllowCopy;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1693,7 +1723,7 @@ public class GridField
|
||||||
*/
|
*/
|
||||||
public String toStringX()
|
public String toStringX()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder("MField[");
|
StringBuilder sb = new StringBuilder("GridField[");
|
||||||
sb.append(m_vo.ColumnName).append("=").append(m_value)
|
sb.append(m_vo.ColumnName).append("=").append(m_value)
|
||||||
.append(",DisplayType=").append(getDisplayType())
|
.append(",DisplayType=").append(getDisplayType())
|
||||||
.append("]");
|
.append("]");
|
||||||
|
@ -2011,4 +2041,4 @@ public class GridField
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // MField
|
} // GridField
|
||||||
|
|
|
@ -533,7 +533,7 @@ public class GridTable extends AbstractTableModel
|
||||||
/**
|
/**
|
||||||
* Get Column at index
|
* Get Column at index
|
||||||
* @param index index
|
* @param index index
|
||||||
* @return MField
|
* @return GridField
|
||||||
*/
|
*/
|
||||||
protected GridField getField (int index)
|
protected GridField getField (int index)
|
||||||
{
|
{
|
||||||
|
@ -545,7 +545,7 @@ public class GridTable extends AbstractTableModel
|
||||||
/**
|
/**
|
||||||
* Return Columns with Identifier (ColumnName)
|
* Return Columns with Identifier (ColumnName)
|
||||||
* @param identifier column name
|
* @param identifier column name
|
||||||
* @return MField
|
* @return GridField
|
||||||
*/
|
*/
|
||||||
protected GridField getField (String identifier)
|
protected GridField getField (String identifier)
|
||||||
{
|
{
|
||||||
|
@ -564,7 +564,7 @@ public class GridTable extends AbstractTableModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Fields
|
* Get all Fields
|
||||||
* @return MFields
|
* @return GridFields
|
||||||
*/
|
*/
|
||||||
public GridField[] getFields ()
|
public GridField[] getFields ()
|
||||||
{
|
{
|
||||||
|
@ -791,7 +791,7 @@ public class GridTable extends AbstractTableModel
|
||||||
*/
|
*/
|
||||||
private void dispose()
|
private void dispose()
|
||||||
{
|
{
|
||||||
// MFields
|
// GridFields
|
||||||
for (int i = 0; i < m_fields.size(); i++)
|
for (int i = 0; i < m_fields.size(); i++)
|
||||||
((GridField)m_fields.get(i)).dispose();
|
((GridField)m_fields.get(i)).dispose();
|
||||||
m_fields.clear();
|
m_fields.clear();
|
||||||
|
@ -1183,7 +1183,7 @@ public class GridTable extends AbstractTableModel
|
||||||
} // setChanged
|
} // setChanged
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Value in data and update MField.
|
* Set Value in data and update GridField.
|
||||||
* (called directly or from JTable.editingStopped())
|
* (called directly or from JTable.editingStopped())
|
||||||
*
|
*
|
||||||
* @param value value to assign to cell
|
* @param value value to assign to cell
|
||||||
|
@ -1196,7 +1196,7 @@ public class GridTable extends AbstractTableModel
|
||||||
} // setValueAt
|
} // setValueAt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Value in data and update MField.
|
* Set Value in data and update GridField.
|
||||||
* (called directly or from JTable.editingStopped())
|
* (called directly or from JTable.editingStopped())
|
||||||
*
|
*
|
||||||
* @param value value to assign to cell
|
* @param value value to assign to cell
|
||||||
|
@ -1261,7 +1261,7 @@ public class GridTable extends AbstractTableModel
|
||||||
setDataAtRow(row, rowData);
|
setDataAtRow(row, rowData);
|
||||||
// update Table
|
// update Table
|
||||||
fireTableCellUpdated(row, col);
|
fireTableCellUpdated(row, col);
|
||||||
// update MField
|
// update GridField
|
||||||
GridField field = getField(col);
|
GridField field = getField(col);
|
||||||
field.setValue(value, m_inserting);
|
field.setValue(value, m_inserting);
|
||||||
// inform
|
// inform
|
||||||
|
@ -2530,18 +2530,28 @@ public class GridTable extends AbstractTableModel
|
||||||
// fill data
|
// fill data
|
||||||
if (copyCurrent)
|
if (copyCurrent)
|
||||||
{
|
{
|
||||||
|
boolean hasDocTypeTargetField = (getField("C_DocTypeTarget_ID") != null);
|
||||||
Object[] origData = getDataAtRow(currentRow);
|
Object[] origData = getDataAtRow(currentRow);
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
GridField field = (GridField)m_fields.get(i);
|
GridField field = (GridField)m_fields.get(i);
|
||||||
|
MColumn column = null;
|
||||||
|
if (field.getAD_Column_ID() > 0)
|
||||||
|
column = MColumn.get(m_ctx, field.getAD_Column_ID());
|
||||||
if (field.isVirtualColumn())
|
if (field.isVirtualColumn())
|
||||||
;
|
;
|
||||||
else if (field.isAllowCopy())
|
else if ( field.isKey() // KeyColumn
|
||||||
rowData[i] = origData[i];
|
|| (column != null && column.isUUIDColumn()) // IDEMPIERE-67
|
||||||
else {
|
|| (column != null && column.isStandardColumn() && !column.getColumnName().equals("AD_Org_ID")) // AD_Org_ID can be copied
|
||||||
|
// Bug [ 1807947 ]
|
||||||
|
|| (hasDocTypeTargetField && field.getColumnName().equals("C_DocType_ID"))
|
||||||
|
|| ! field.isAllowCopy())
|
||||||
|
{
|
||||||
rowData[i] = field.getDefault();
|
rowData[i] = field.getDefault();
|
||||||
field.setValue(rowData[i], m_inserting);
|
field.setValue(rowData[i], m_inserting);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
rowData[i] = origData[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // new
|
else // new
|
||||||
|
@ -3124,7 +3134,7 @@ public class GridTable extends AbstractTableModel
|
||||||
String columnName = null;
|
String columnName = null;
|
||||||
int displayType = 0;
|
int displayType = 0;
|
||||||
|
|
||||||
// Types see also MField.createDefault
|
// Types see also GridField.createDefault
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// get row data
|
// get row data
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class MColumn extends X_AD_Column
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -3366954463322356334L;
|
private static final long serialVersionUID = 2344447703630569514L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MColumn from Cache
|
* Get MColumn from Cache
|
||||||
|
@ -150,6 +150,7 @@ public class MColumn extends X_AD_Column
|
||||||
if (columnName.equals("AD_Client_ID")
|
if (columnName.equals("AD_Client_ID")
|
||||||
|| columnName.equals("AD_Org_ID")
|
|| columnName.equals("AD_Org_ID")
|
||||||
|| columnName.equals("IsActive")
|
|| columnName.equals("IsActive")
|
||||||
|
|| columnName.equals("Processing")
|
||||||
|| columnName.equals("Created")
|
|| columnName.equals("Created")
|
||||||
|| columnName.equals("CreatedBy")
|
|| columnName.equals("CreatedBy")
|
||||||
|| columnName.equals("Updated")
|
|| columnName.equals("Updated")
|
||||||
|
@ -159,6 +160,14 @@ public class MColumn extends X_AD_Column
|
||||||
return false;
|
return false;
|
||||||
} // isStandardColumn
|
} // isStandardColumn
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is UUID Column
|
||||||
|
* @return true for UUID column
|
||||||
|
*/
|
||||||
|
public boolean isUUIDColumn() {
|
||||||
|
return getColumnName().equals(PO.getUUIDColumnName(getAD_Table().getTableName()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Virtual Column
|
* Is Virtual Column
|
||||||
* @return true if virtual column
|
* @return true if virtual column
|
||||||
|
@ -273,17 +282,18 @@ public class MColumn extends X_AD_Column
|
||||||
if (isAlwaysUpdateable() && !isUpdateable())
|
if (isAlwaysUpdateable() && !isUpdateable())
|
||||||
setIsAlwaysUpdateable(false);
|
setIsAlwaysUpdateable(false);
|
||||||
// Encrypted
|
// Encrypted
|
||||||
|
String colname = getColumnName();
|
||||||
if (isEncrypted())
|
if (isEncrypted())
|
||||||
{
|
{
|
||||||
int dt = getAD_Reference_ID();
|
int dt = getAD_Reference_ID();
|
||||||
if (isKey() || isParent() || isStandardColumn()
|
if (isKey() || isParent() || isStandardColumn()
|
||||||
|| isVirtualColumn() || isIdentifier() || isTranslated()
|
|| isVirtualColumn() || isIdentifier() || isTranslated() || isUUIDColumn()
|
||||||
|| DisplayType.isLookup(dt) || DisplayType.isLOB(dt)
|
|| DisplayType.isLookup(dt) || DisplayType.isLOB(dt)
|
||||||
|| "DocumentNo".equalsIgnoreCase(getColumnName())
|
|| "DocumentNo".equalsIgnoreCase(colname)
|
||||||
|| "Value".equalsIgnoreCase(getColumnName())
|
|| "Value".equalsIgnoreCase(colname)
|
||||||
|| "Name".equalsIgnoreCase(getColumnName()))
|
|| "Name".equalsIgnoreCase(colname))
|
||||||
{
|
{
|
||||||
log.warning("Encryption not sensible - " + getColumnName());
|
log.warning("Encryption not sensible - " + colname);
|
||||||
setIsEncrypted(false);
|
setIsEncrypted(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,11 +310,10 @@ public class MColumn extends X_AD_Column
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validations for IsAllowCopy - some columns must never be set as allowed copying
|
// Validations for IsAllowCopy - some columns must never be set as allowed copying
|
||||||
String colname = getColumnName();
|
|
||||||
if (isAllowCopy()) {
|
if (isAllowCopy()) {
|
||||||
if ( isKey()
|
if ( isKey()
|
||||||
|| getColumnSQL() != null
|
|| isVirtualColumn()
|
||||||
|| colname.equals(PO.getUUIDColumnName(getAD_Table().getTableName()))
|
|| isUUIDColumn()
|
||||||
|| isStandardColumn()
|
|| isStandardColumn()
|
||||||
)
|
)
|
||||||
setIsAllowCopy(false);
|
setIsAllowCopy(false);
|
||||||
|
|
|
@ -132,12 +132,17 @@ public class MField extends X_AD_Field
|
||||||
if (getIsAllowCopy() != null) {
|
if (getIsAllowCopy() != null) {
|
||||||
MColumn column = (MColumn) getAD_Column();
|
MColumn column = (MColumn) getAD_Column();
|
||||||
if ( column.isKey()
|
if ( column.isKey()
|
||||||
|| column.getColumnSQL() != null
|
|| column.isVirtualColumn()
|
||||||
|| column.isStandardColumn()
|
|| column.isUUIDColumn()
|
||||||
|
|| (column.isStandardColumn() && !column.getColumnName().equals("AD_Org_ID")) // AD_Org_ID can be copied
|
||||||
)
|
)
|
||||||
setIsAllowCopy(null);
|
setIsAllowCopy(null);
|
||||||
}
|
}
|
||||||
|
if (getIsAllowCopy() == null) { // IDEMPIERE-67
|
||||||
|
// By default allow copy of AD_Org_ID overwriting value
|
||||||
|
if (getAD_Column().getColumnName().equals("AD_Org_ID")) // AD_Org_ID can be copied
|
||||||
|
setIsAllowCopy("Y");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class MRequestUpdate extends X_R_RequestUpdate
|
||||||
//
|
//
|
||||||
for (final MColumn col : MTable.get(getCtx(), Table_ID).getColumns(false))
|
for (final MColumn col : MTable.get(getCtx(), Table_ID).getColumns(false))
|
||||||
{
|
{
|
||||||
if (col.isStandardColumn() || col.isKey() || col.isParent())
|
if (col.isStandardColumn() || col.isKey() || col.isParent() || col.isUUIDColumn() || col.isVirtualColumn())
|
||||||
continue;
|
continue;
|
||||||
final String columnName = col.getColumnName();
|
final String columnName = col.getColumnName();
|
||||||
final int i = parent.get_ColumnIndex(columnName);
|
final int i = parent.get_ColumnIndex(columnName);
|
||||||
|
|
|
@ -1232,9 +1232,14 @@ public abstract class PO
|
||||||
{
|
{
|
||||||
for (int i1 = 0; i1 < from.m_oldValues.length; i1++)
|
for (int i1 = 0; i1 < from.m_oldValues.length; i1++)
|
||||||
{
|
{
|
||||||
if (! from.p_info.isAllowCopy(i1))
|
|
||||||
continue;
|
|
||||||
String colName = from.p_info.getColumnName(i1);
|
String colName = from.p_info.getColumnName(i1);
|
||||||
|
MColumn column = MColumn.get(from.getCtx(), from.p_info.getAD_Column_ID(colName));
|
||||||
|
if ( column.isVirtualColumn()
|
||||||
|
|| column.isKey() // KeyColumn
|
||||||
|
|| column.isUUIDColumn() // IDEMPIERE-67
|
||||||
|
|| column.isStandardColumn()
|
||||||
|
|| ! column.isAllowCopy())
|
||||||
|
continue;
|
||||||
for (int i2 = 0; i2 < to.m_oldValues.length; i2++)
|
for (int i2 = 0; i2 < to.m_oldValues.length; i2++)
|
||||||
{
|
{
|
||||||
if (to.p_info.getColumnName(i2).equals(colName))
|
if (to.p_info.getColumnName(i2).equals(colName))
|
||||||
|
@ -1249,7 +1254,13 @@ public abstract class PO
|
||||||
{
|
{
|
||||||
for (int i = 0; i < from.m_oldValues.length; i++)
|
for (int i = 0; i < from.m_oldValues.length; i++)
|
||||||
{
|
{
|
||||||
if (! from.p_info.isAllowCopy(i))
|
String colName = from.p_info.getColumnName(i);
|
||||||
|
MColumn column = MColumn.get(from.getCtx(), from.p_info.getAD_Column_ID(colName));
|
||||||
|
if ( column.isVirtualColumn()
|
||||||
|
|| column.isKey() // KeyColumn
|
||||||
|
|| column.isUUIDColumn()
|
||||||
|
|| column.isStandardColumn()
|
||||||
|
|| ! column.isAllowCopy())
|
||||||
continue;
|
continue;
|
||||||
to.m_newValues[i] = from.m_oldValues[i];
|
to.m_newValues[i] = from.m_oldValues[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue