IDEMPIERE-5560 Cannot save more than one order line when an _ID field is not displayed (#1764)

This commit is contained in:
hengsin 2023-04-01 22:11:35 +08:00 committed by GitHub
parent 09df36a78f
commit ee1b6828f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -2752,6 +2752,11 @@ public class GridTable extends AbstractTableModel
for (int i = 0; i < size; i++)
{
GridField field = (GridField)m_fields.get(i);
if (field.getGridTab() != null) {
//avoid getting default from previous row
String key = field.getVO().WindowNo+"|"+field.getVO().TabNo+"|"+field.getVO().ColumnName;
field.getVO().ctx.remove(key);
}
Object value = field.getDefault();
field.setValue(value, m_inserting);
field.validateValueNoDirect();

View File

@ -193,9 +193,8 @@ public class GridTabTest extends AbstractTestCase {
boolean displayGridOri = field.isDisplayed();
try {
/* IDEMPIERE-5560 */
DB.executeUpdateEx("UPDATE AD_Field SET IsDisplayed='N', IsDisplayedGrid='N' WHERE AD_Field_ID=?", new Object[] {FIELD_ORDERLINE_SHIPPER}, getTrxName());
// we need to commit here for the test case below to get the update
commit();
// must not use trx here for the test case below to get the update
DB.executeUpdateEx("UPDATE AD_Field SET IsDisplayed='N', IsDisplayedGrid='N' WHERE AD_Field_ID=?", new Object[] {FIELD_ORDERLINE_SHIPPER}, null);
CacheMgt.get().reset();
// Sales Order
@ -253,6 +252,8 @@ public class GridTabTest extends AbstractTestCase {
assertTrue(gTab0.dataNew(false));
assertTrue(gTab0.isNew(), "Grid Tab dataNew call not working as expected");
gTab0.setValue(MOrder.COLUMNNAME_C_BPartner_ID, DictionaryIDs.C_BPartner.C_AND_W.id);
gTab0.setValue(MOrder.COLUMNNAME_C_DocTypeTarget_ID, DictionaryIDs.C_DocType.STANDARD_ORDER.id);
gTab0.setValue(MOrder.COLUMNNAME_SalesRep_ID, DictionaryIDs.AD_User.GARDEN_USER.id);
assertTrue(gTab0.dataSave(true), CLogger.retrieveWarningString("Could not save order"));
GridTab gTab1 = gridWindow.getTab(1);
@ -269,9 +270,7 @@ public class GridTabTest extends AbstractTestCase {
} finally {
// rollback the work from the test
rollback();
DB.executeUpdateEx("UPDATE AD_Field SET IsDisplayed=?, IsDisplayedGrid=? WHERE AD_Field_ID=?", new Object[] {displayOri, displayGridOri, FIELD_ORDERLINE_SHIPPER}, getTrxName());
// commit the cleanup
commit();
DB.executeUpdateEx("UPDATE AD_Field SET IsDisplayed=?, IsDisplayedGrid=? WHERE AD_Field_ID=?", new Object[] {displayOri, displayGridOri, FIELD_ORDERLINE_SHIPPER}, null);
CacheMgt.get().reset();
}