IDEMPIERE-4223 Model class generated with wrong datatype for Column with displaytype=button and columname ends with _ID

This commit is contained in:
hengsin 2020-03-27 11:34:27 +08:00
parent 92cd714221
commit 41aa4102cd
16 changed files with 63 additions and 90 deletions

View File

@ -64,9 +64,9 @@ public class BPartnerOrgUnLink extends SvrProcess
if (bp.get_ID() == 0)
throw new IllegalArgumentException ("Business Partner not found - C_BPartner_ID=" + p_C_BPartner_ID);
//
if (bp.getAD_OrgBP_ID_Int() == 0)
if (bp.getAD_OrgBP_ID() == 0)
throw new IllegalArgumentException ("Business Partner not linked to an Organization");
bp.setAD_OrgBP_ID(null);
bp.setAD_OrgBP_ID(0);
if (!bp.save())
throw new IllegalArgumentException ("Business Partner not changed");

View File

@ -516,12 +516,12 @@ public class DistributionRun extends SvrProcess
order.setC_DocType_ID(m_docType.getC_DocType_ID());
order.setIsSOTrx(m_docType.isSOTrx());
// Counter Doc
if (counter && bp.getAD_OrgBP_ID_Int() > 0)
if (counter && bp.getAD_OrgBP_ID() > 0)
{
if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID_Int()
if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID()
+ "-" + bp + ", To_BP=" + runBPartner);
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
MOrgInfo oi = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID_Int(), get_TrxName());
order.setAD_Org_ID(bp.getAD_OrgBP_ID());
MOrgInfo oi = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID(), get_TrxName());
if (oi.getM_Warehouse_ID() > 0)
order.setM_Warehouse_ID(oi.getM_Warehouse_ID());
order.setBPartner(runBPartner);
@ -557,7 +557,7 @@ public class DistributionRun extends SvrProcess
// Create Order Line
MOrderLine line = new MOrderLine(order);
if (counter && bp.getAD_OrgBP_ID_Int() > 0)
if (counter && bp.getAD_OrgBP_ID() > 0)
; // don't overwrite counter doc
else // normal - optionally overwrite
{
@ -929,7 +929,7 @@ public class DistributionRun extends SvrProcess
lastC_BPartner_Location_ID = detail.getC_BPartner_Location_ID();
bp = new MBPartner (getCtx(), detail.getC_BPartner_ID(), get_TrxName());
MOrgInfo oi_target = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID_Int(), get_TrxName());
MOrgInfo oi_target = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID(), get_TrxName());
m_target = MWarehouse.get(getCtx(), oi_target.getM_Warehouse_ID());
if(m_target==null)
throw new AdempiereException("Do not exist Default Warehouse Target");
@ -944,7 +944,7 @@ public class DistributionRun extends SvrProcess
if(p_ConsolidateDocument)
{
StringBuilder whereClause = new StringBuilder("DocStatus IN ('DR','IN') AND AD_Org_ID=").append(bp.getAD_OrgBP_ID_Int()).append(" AND ")
StringBuilder whereClause = new StringBuilder("DocStatus IN ('DR','IN') AND AD_Org_ID=").append(bp.getAD_OrgBP_ID()).append(" AND ")
.append(MDDOrder.COLUMNNAME_C_BPartner_ID).append("=? AND ")
.append(MDDOrder.COLUMNNAME_M_Warehouse_ID).append("=? AND ")
.append(MDDOrder.COLUMNNAME_DatePromised).append("<=? ");
@ -961,16 +961,16 @@ public class DistributionRun extends SvrProcess
if (!p_IsTest)
{
order = new MDDOrder (getCtx(), 0, get_TrxName());
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
order.setAD_Org_ID(bp.getAD_OrgBP_ID());
order.setC_DocType_ID(m_docType.getC_DocType_ID());
order.setIsSOTrx(m_docType.isSOTrx());
// Counter Doc
if (counter && bp.getAD_OrgBP_ID_Int() > 0)
if (counter && bp.getAD_OrgBP_ID() > 0)
{
if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID_Int()
if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID()
+ "-" + bp + ", To_BP=" + runBPartner);
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
order.setAD_Org_ID(bp.getAD_OrgBP_ID());
if (ws[0].getM_Warehouse_ID() > 0)
order.setM_Warehouse_ID(ws[0].getM_Warehouse_ID());
order.setBPartner(runBPartner);
@ -979,7 +979,7 @@ public class DistributionRun extends SvrProcess
{
if (log.isLoggable(Level.FINE)) log.fine("From_Org=" + runAD_Org_ID
+ ", To_BP=" + bp);
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
order.setAD_Org_ID(bp.getAD_OrgBP_ID());
order.setBPartner(bp);
if (detail.getC_BPartner_Location_ID() != 0)
order.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID());
@ -1015,7 +1015,7 @@ public class DistributionRun extends SvrProcess
if (DD_OrderLine_ID <= 0)
{
MDDOrderLine line = new MDDOrderLine(order);
line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
line.setAD_Org_ID(bp.getAD_OrgBP_ID());
line.setM_Locator_ID(m_locator.getM_Locator_ID());
line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID());
line.setIsInvoiced(false);
@ -1059,7 +1059,7 @@ public class DistributionRun extends SvrProcess
{
// Create Order Line
MDDOrderLine line = new MDDOrderLine(order);
if (counter && bp.getAD_OrgBP_ID_Int() > 0)
if (counter && bp.getAD_OrgBP_ID() > 0)
; // don't overwrite counter doc
/*else // normal - optionally overwrite
{
@ -1068,7 +1068,7 @@ public class DistributionRun extends SvrProcess
line.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID());
}*/
//
line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
line.setAD_Org_ID(bp.getAD_OrgBP_ID());
line.setM_Locator_ID(m_locator.getM_Locator_ID());
line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID());
line.setIsInvoiced(false);

View File

@ -66,7 +66,7 @@ public class ProjectSetType extends SvrProcess
MProject project = new MProject (getCtx(), m_C_Project_ID, get_TrxName());
if (project.getC_Project_ID() == 0 || project.getC_Project_ID() != m_C_Project_ID)
throw new IllegalArgumentException("Project not found C_Project_ID=" + m_C_Project_ID);
if (project.getC_ProjectType_ID_Int() > 0)
if (project.getC_ProjectType_ID() > 0)
throw new IllegalArgumentException("Project already has Type (Cannot overwrite) " + project.getC_ProjectType_ID());
//
MProjectType type = new MProjectType (getCtx(), m_C_ProjectType_ID, get_TrxName());

View File

@ -533,6 +533,10 @@ public class ModelInterfaceGenerator
//
return getClass(columnName, displayType, AD_Reference_ID); // recursive call with new parameters
}
else if (displayType == DisplayType.Button && columnName.endsWith("_ID"))
{
return Integer.class;
}
else
{
return DisplayType.getClass(displayType, true);

View File

@ -94,12 +94,12 @@ public interface I_C_BPartner
/** Set Linked Organization.
* The Business Partner is another Organization for explicit Inter-Org transactions
*/
public void setAD_OrgBP_ID (String AD_OrgBP_ID);
public void setAD_OrgBP_ID (int AD_OrgBP_ID);
/** Get Linked Organization.
* The Business Partner is another Organization for explicit Inter-Org transactions
*/
public String getAD_OrgBP_ID();
public int getAD_OrgBP_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";

View File

@ -268,12 +268,12 @@ public interface I_C_Project
/** Set Project Type.
* Type of the project
*/
public void setC_ProjectType_ID (String C_ProjectType_ID);
public void setC_ProjectType_ID (int C_ProjectType_ID);
/** Get Project Type.
* Type of the project
*/
public String getC_ProjectType_ID();
public int getC_ProjectType_ID();
/** Column name C_Project_UU */
public static final String COLUMNNAME_C_Project_UU = "C_Project_UU";

View File

@ -573,41 +573,17 @@ public class MBPartner extends X_C_BPartner
super.setClientOrg(AD_Client_ID, AD_Org_ID);
} // setClientOrg
/**
* Set Linked Organization.
* (is Button)
* @param AD_OrgBP_ID
*/
public void setAD_OrgBP_ID (int AD_OrgBP_ID)
{
if (AD_OrgBP_ID == 0)
super.setAD_OrgBP_ID (null);
else
super.set_Value("AD_OrgBP_ID", AD_OrgBP_ID);
} // setAD_OrgBP_ID
/**
* Get Linked Organization.
* (is Button)
* The Business Partner is another Organization
* for explicit Inter-Org transactions
* @return AD_Org_ID if BP
* @deprecated
*/
public int getAD_OrgBP_ID_Int()
{
String org = super.getAD_OrgBP_ID();
if (org == null)
return 0;
int AD_OrgBP_ID = 0;
try
{
AD_OrgBP_ID = Integer.parseInt (org);
}
catch (Exception ex)
{
log.log(Level.SEVERE, org, ex);
}
return AD_OrgBP_ID;
return getAD_OrgBP_ID();
} // getAD_OrgBP_ID_Int
/**

View File

@ -1973,7 +1973,7 @@ public class MInOut extends X_M_InOut implements DocAction
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
int counterAD_Org_ID = bp.getAD_OrgBP_ID();
if (counterAD_Org_ID == 0)
return null;

View File

@ -2205,7 +2205,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
int counterAD_Org_ID = bp.getAD_OrgBP_ID();
if (counterAD_Org_ID == 0)
return null;

View File

@ -2326,7 +2326,7 @@ public class MOrder extends X_C_Order implements DocAction
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
int counterAD_Org_ID = bp.getAD_OrgBP_ID();
if (counterAD_Org_ID == 0)
return null;

View File

@ -2171,7 +2171,7 @@ public class MPayment extends X_C_Payment
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
int counterAD_Org_ID = bp.getAD_OrgBP_ID();
if (counterAD_Org_ID == 0)
return null;

View File

@ -127,36 +127,13 @@ public class MProject extends X_C_Project
/**
* Get Project Type as Int (is Button).
* @return C_ProjectType_ID id
* @deprecated
*/
public int getC_ProjectType_ID_Int()
{
String pj = super.getC_ProjectType_ID();
if (pj == null)
return 0;
int C_ProjectType_ID = 0;
try
{
C_ProjectType_ID = Integer.parseInt (pj);
}
catch (Exception ex)
{
log.log(Level.SEVERE, pj, ex);
}
return C_ProjectType_ID;
return getC_ProjectType_ID();
} // getC_ProjectType_ID_Int
/**
* Set Project Type (overwrite r/o)
* @param C_ProjectType_ID id
*/
public void setC_ProjectType_ID (int C_ProjectType_ID)
{
if (C_ProjectType_ID == 0)
super.setC_ProjectType_ID (null);
else
super.set_Value("C_ProjectType_ID", C_ProjectType_ID);
} // setC_ProjectType_ID
/**
* String Representation
* @return info

View File

@ -505,7 +505,7 @@ public class MRMA extends X_M_RMA implements DocAction
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
int counterAD_Org_ID = bp.getAD_OrgBP_ID();
if (counterAD_Org_ID == 0)
return null;

View File

@ -87,6 +87,10 @@ public class POInfoColumn implements Serializable
DisplayType = org.compiere.util.DisplayType.ID;
ColumnClass = Integer.class;
}
else if (displayType == org.compiere.util.DisplayType.Button && columnName.endsWith("_ID"))
{
ColumnClass = Integer.class;
}
else
ColumnClass = org.compiere.util.DisplayType.getClass(displayType, true);
IsMandatory = isMandatory;

View File

@ -33,7 +33,7 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20191121L;
private static final long serialVersionUID = 20200327L;
/** Standard Constructor */
public X_C_BPartner (Properties ctx, int C_BPartner_ID, String trxName)
@ -86,8 +86,8 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
public String toString()
{
StringBuffer sb = new StringBuffer ("X_C_BPartner[")
.append(get_ID()).append("]");
StringBuilder sb = new StringBuilder ("X_C_BPartner[")
.append(get_ID()).append(",Name=").append(getName()).append("]");
return sb.toString();
}
@ -155,17 +155,23 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
@param AD_OrgBP_ID
The Business Partner is another Organization for explicit Inter-Org transactions
*/
public void setAD_OrgBP_ID (String AD_OrgBP_ID)
public void setAD_OrgBP_ID (int AD_OrgBP_ID)
{
set_Value (COLUMNNAME_AD_OrgBP_ID, AD_OrgBP_ID);
if (AD_OrgBP_ID < 1)
set_Value (COLUMNNAME_AD_OrgBP_ID, null);
else
set_Value (COLUMNNAME_AD_OrgBP_ID, Integer.valueOf(AD_OrgBP_ID));
}
/** Get Linked Organization.
@return The Business Partner is another Organization for explicit Inter-Org transactions
*/
public String getAD_OrgBP_ID ()
public int getAD_OrgBP_ID ()
{
return (String)get_Value(COLUMNNAME_AD_OrgBP_ID);
Integer ii = (Integer)get_Value(COLUMNNAME_AD_OrgBP_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Partner Parent.

View File

@ -33,7 +33,7 @@ public class X_C_Project extends PO implements I_C_Project, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20191121L;
private static final long serialVersionUID = 20200327L;
/** Standard Constructor */
public X_C_Project (Properties ctx, int C_Project_ID, String trxName)
@ -451,17 +451,23 @@ public class X_C_Project extends PO implements I_C_Project, I_Persistent
@param C_ProjectType_ID
Type of the project
*/
public void setC_ProjectType_ID (String C_ProjectType_ID)
public void setC_ProjectType_ID (int C_ProjectType_ID)
{
set_Value (COLUMNNAME_C_ProjectType_ID, C_ProjectType_ID);
if (C_ProjectType_ID < 1)
set_Value (COLUMNNAME_C_ProjectType_ID, null);
else
set_Value (COLUMNNAME_C_ProjectType_ID, Integer.valueOf(C_ProjectType_ID));
}
/** Get Project Type.
@return Type of the project
*/
public String getC_ProjectType_ID ()
public int getC_ProjectType_ID ()
{
return (String)get_Value(COLUMNNAME_C_ProjectType_ID);
Integer ii = (Integer)get_Value(COLUMNNAME_C_ProjectType_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set C_Project_UU.