IDEMPIERE-3979 Record Access Exclude problem / peer review

This commit is contained in:
Carlos Ruiz 2019-06-10 19:22:13 +02:00
parent 05da94ddf1
commit 6bdfc00408
2 changed files with 36 additions and 28 deletions

View File

@ -83,7 +83,7 @@ public class GridField
/**
*
*/
private static final long serialVersionUID = -1871840570764036802L;
private static final long serialVersionUID = -5923967271000455417L;
/**
* Field Constructor.
@ -110,10 +110,8 @@ public class GridField
* GridTab.processDependentFields will check this flag to avoid clearing of lookup field value that just have been set.
**/
private boolean m_lookupEditorSettingValue = false;
private boolean m_lockedrecord=false;
private boolean m_lockedRecord = false;
/**
* Dispose
*/
@ -447,7 +445,7 @@ public class GridField
{
if (isVirtualColumn())
return false;
if (m_lockedrecord)
if (m_lockedRecord)
return false;
// Fields always enabled (are usually not updateable)
if (m_vo.ColumnName.equals("Posted")
@ -2512,13 +2510,14 @@ public class GridField
return m_vo.displayType == DisplayType.Button && MColumn.ISTOOLBARBUTTON_Toolbar.equals(m_vo.IsToolbarButton);
}
public boolean islockedrecord() {
return m_lockedrecord;
public boolean isLockedRecord() {
return m_lockedRecord;
}
public void setlockedrecord(boolean m_lockedrecord) {
this.m_lockedrecord = m_lockedrecord;
public void setLockedRecord(boolean lockedRecord) {
this.m_lockedRecord = lockedRecord;
}
public int getPA_DashboardContent_ID()
{
return m_vo.PA_DashboardContent_ID;

View File

@ -42,6 +42,7 @@ import org.compiere.model.GridField;
import org.compiere.model.GridTable;
import org.compiere.model.Lookup;
import org.compiere.model.MBPartnerLocation;
import org.compiere.model.MColumn;
import org.compiere.model.MLocation;
import org.compiere.model.MLookup;
import org.compiere.model.MRole;
@ -314,30 +315,38 @@ ContextMenuListener, IZoomableEditor
refreshList();
}
//still not in list, reset to zero
//still not in list, reset to zero
if (!getComponent().isSelected(value))
{
if (value instanceof Integer && gridField != null && gridField.getDisplayType() != DisplayType.ID &&
(gridTab==null || !gridTab.getTableModel().isImporting())) // for IDs is ok to be out of the list
{
//if it is problem with record lock, just keep value (no trigger change) and set field readonly
//if it is problem with record lock, just keep value (no trigger change) and set field readonly
MRole role = MRole.getDefault(Env.getCtx(), false);
if (role.isRecordAccess(gridTab.getAD_Table_ID() ,(int)value,false)){
oldValue = value;
setReadWrite(false);
gridField.setlockedrecord(true);
}
else
{
getComponent().setValue(null);
if (curValue == null)
curValue = value;
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null);
super.fireValueChange(changeEvent);
oldValue = null;
if (gridField!=null)
gridField.setlockedrecord(false);
}
MColumn col = MColumn.get(Env.getCtx(), gridField.getAD_Column_ID());
int refTableID = -1;
if (col.get_ID() > 0) {
String refTable = col.getReferenceTableName();
MTable table = MTable.get(Env.getCtx(), refTable);
refTableID = table.getAD_Table_ID();
}
if (refTableID > 0 && ! role.isRecordAccess(refTableID, (int)value, false))
{
oldValue = value;
setReadWrite(false);
gridField.setLockedRecord(true);
}
else
{
getComponent().setValue(null);
if (curValue == null)
curValue = value;
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null);
super.fireValueChange(changeEvent);
oldValue = null;
if (gridField!=null)
gridField.setLockedRecord(false);
}
}
}
}
@ -345,7 +354,7 @@ ContextMenuListener, IZoomableEditor
{
oldValue = value;
if (gridField!=null)
gridField.setlockedrecord(false);
gridField.setLockedRecord(false);
}
}
else