I want to create a class that extends the idempiere product model to create a code from other fields but I don't know which class I should import or what method I should override.
org.compiere.model.MProduct:
public MProduct (X_I_Product impP)
{
this (impP.getCtx(), 0, impP.get_TrxName());
setClientOrg(impP);
setUpdatedBy(impP.getUpdatedBy());
// Value field:
setValue(impP.getValue());
setName(impP.getName());
setDescription(impP.getDescription());
setDocumentNote(impP.getDocumentNote());
setHelp(impP.getHelp());
setUPC(impP.getUPC());
setSKU(impP.getSKU());
setC_UOM_ID(impP.getC_UOM_ID());
setM_Product_Category_ID(impP.getM_Product_Category_ID());
setProductType(impP.getProductType());
setImageURL(impP.getImageURL());
setDescriptionURL(impP.getDescriptionURL());
setVolume(impP.getVolume());
setWeight(impP.getWeight());
} // MProduct
In one of the comments, you clarified that your intent is to "extend the MProduct class and override the method that saves the "VALUE" column".
To answer that, first let's define a simple version of
MProductclass, with a few edits:setValue()method, since that's the only part relevant to your question (the other methods onMProductare not relevant)setValue()was changed tointvs. the original type is in your example (whatever the return type is fromimpP.getValue())Here's a simple version of
MProduct:Here's a simple class which extends
MProductby overriding thesetValue()method:Finally, here's a simple example showing usage of both of the above classes (both
MProductandCustomProduct):And here's the output from running that example: