teo_sarca 2009-09-15 09:23:25 +00:00
parent 4849879b62
commit ced56da0d1
2 changed files with 38 additions and 2 deletions

View File

@ -76,6 +76,8 @@ import org.w3c.dom.Element;
* https://sourceforge.net/tracker/?func=detail&aid=2818369&group_id=176962&atid=879335
* <li>BF [ 2849122 ] PO.AfterSave is not rollback on error
* https://sourceforge.net/tracker/?func=detail&aid=2849122&group_id=176962&atid=879332
* <li>BF [ 2859125 ] Can't set AD_OrgBP_ID
* https://sourceforge.net/tracker/index.php?func=detail&aid=2859125&group_id=176962&atid=879332
* @author Victor Perez, e-Evolution SC
* <li>[ 2195894 ] Improve performance in PO engine
* <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195894&group_id=176962&atid=879335
@ -667,8 +669,13 @@ public abstract class PO
}
if (ColumnName.endsWith("_ID") && value instanceof String )
{
log.severe("Invalid Data Type for " + ColumnName + "=" + value);
value = Integer.parseInt((String)value);
// Convert to Integer only if info class is Integer - teo_sarca [ 2859125 ]
Class<?> clazz = p_info.getColumnClass(p_info.getColumnIndex(ColumnName));
if (Integer.class == clazz)
{
log.severe("Invalid Data Type for " + ColumnName + "=" + value);
value = Integer.parseInt((String)value);
}
}
return set_Value (index, value);

View File

@ -2,6 +2,7 @@ package test.functional;
import java.util.Properties;
import org.compiere.model.MBPartner;
import org.compiere.model.MTest;
import org.compiere.model.POInfo;
import org.compiere.util.DB;
@ -173,4 +174,32 @@ public class POTest extends AdempiereTestCase
assertEquals("Object should not be modified(2) -- id="+test2, test.getName(), name);
}
}
/**
* BF [ 2859125 ] Can't set AD_OrgBP_ID
* https://sourceforge.net/tracker/index.php?func=detail&aid=2859125&group_id=176962&atid=879332#
*/
public void testAD_OrgBP_ID_Issue() throws Exception
{
MBPartner bp = new MBPartner(getCtx(), 50004, getTrxName()); // Store Central
//
// Try to change AD_OrgBP_ID field value to a new value
final int old_org_id = bp.getAD_OrgBP_ID_Int();
int new_org_id = 50005; // Store East Org
if (old_org_id == new_org_id)
{
new_org_id = 12; // Store Central
}
bp.setAD_OrgBP_ID(new_org_id);
//
// Following line throws:
// java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
// at org.compiere.model.X_C_BPartner.getAD_OrgBP_ID(X_C_BPartner.java:165)
// at org.compiere.model.MBPartner.getAD_OrgBP_ID_Int(MBPartner.java:602)
// at test.functional.POTest.testAD_OrgBP_ID_Issue(POTest.java:192)
bp.getAD_OrgBP_ID_Int();
//
// Test save:
bp.saveEx();
}
}