Skip to content

Commit

Permalink
Merge pull request #1947 from mckayERP/Fix_for_#1944_FirstSaveOfYN
Browse files Browse the repository at this point in the history
#1944 Deal with special case where a Y/N field has been added to a populated table.

Pull request: #1947
Issue: #1944
  • Loading branch information
marcalwestf committed Oct 5, 2018
2 parents 4768c5b + 328daef commit f5705d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion base/src/org/compiere/model/GridTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@
* <li> FR [ 392 ] Translation method does not use PO class
* @see https://github.com/adempiere/adempiere/issues/392
* @author Nicolas Sarlabos, nicolas.sarlabos@openupsolutions.com, http://www.openupsolutions.com
** <li> FR [ 1350 ] Return customized message in model validator
* <li> FR [ 1350 ] Return customized message in model validator
* @see https://github.com/adempiere/adempiere/issues/1350
* @author Michael McKay, michael.mckay@mckayerp.com
* <li> BF [ <a href="https://github.com/adempiere/adempiere/issues/1944">1944</a> ] First save of a record with new Yes-No field causes error.
*
*/
public class GridTable extends AbstractTableModel
Expand Down Expand Up @@ -2132,12 +2134,20 @@ else if (m_inserting || isValueChanged(oldValue, value) )
Object dbValue = po.get_Value(poIndex);
if (m_inserting
|| !m_compareDB

// Original == DB
|| (oldValue == null && dbValue == null)
|| (oldValue != null && oldValue.equals (dbValue))
// #1944 Special case when the field is boolean and not initialized
// false equivalent to null allowed
|| (oldValue instanceof Boolean && !((Boolean) oldValue) && dbValue == null)

// Target == DB (changed by trigger to new value already)
|| (value == null && dbValue == null)
|| (value != null && value.equals (dbValue))
// #1944 Special case when the field is boolean and not initialized
// false equivalent to null allowed
|| (value instanceof Boolean && !((Boolean) value) && dbValue == null)

// GridTable.dataSave(boolean manualCmd) has a Bug when comparing new, old and db value
// - https://adempiere.atlassian.net/browse/ADEMPIERE-157
Expand Down

0 comments on commit f5705d2

Please sign in to comment.