Package org.compiere.model
Class MProduct
- java.lang.Object
-
- org.compiere.model.PO
-
- org.compiere.model.X_M_Product
-
- org.compiere.model.MProduct
-
- All Implemented Interfaces:
Serializable,Cloneable,Comparator<Object>,I_M_Product,I_Persistent,Evaluatee,ImmutablePOSupport
public class MProduct extends X_M_Product implements ImmutablePOSupport
Product Model- Version:
- $Id: MProduct.java,v 1.5 2006/07/30 00:51:05 jjanke Exp $
- Author:
- Jorg Janke, Teo Sarca, SC ARHIPAC SERVICE SRL
- FR [ 1885153 ] Refactor: getMMPolicy code
- BF [ 1885414 ] ASI should be always mandatory if CostingLevel is Batch/Lot
- FR [ 2093551 ] Refactor/Add org.compiere.model.MProduct.getCostingLevel
- FR [ 2093569 ] Refactor/Add org.compiere.model.MProduct.getCostingMethod
- BF [ 2824795 ] Deleting Resource product should be forbidden https://sourceforge.net/p/adempiere/bugs/1988/, Mark Ostermann (mark_o), metas consult GmbH
- BF [ 2814628 ] Wrong evaluation of Product inactive in beforeSave()
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.compiere.model.X_M_Product
PRODUCTTYPE_AD_Reference_ID, PRODUCTTYPE_Asset, PRODUCTTYPE_ExpenseType, PRODUCTTYPE_Item, PRODUCTTYPE_Online, PRODUCTTYPE_Resource, PRODUCTTYPE_Service
-
Fields inherited from class org.compiere.model.PO
ACCESSLEVEL_ALL, ACCESSLEVEL_CLIENT, ACCESSLEVEL_CLIENTORG, ACCESSLEVEL_ORG, ACCESSLEVEL_SYSTEM, ACCESSLEVEL_SYSTEMCLIENT, ENTITYTYPE_Dictionary, ENTITYTYPE_UserMaintained, I_ZERO, LOCAL_TRX_PREFIX, log, p_ctx, p_info, XML_ATTRIBUTE_AD_Table_ID, XML_ATTRIBUTE_Record_ID
-
Fields inherited from interface org.compiere.model.I_M_Product
accessLevel, COLUMNNAME_AD_Client_ID, COLUMNNAME_AD_Org_ID, COLUMNNAME_C_RevenueRecognition_ID, COLUMNNAME_C_SubscriptionType_ID, COLUMNNAME_C_TaxCategory_ID, COLUMNNAME_C_UOM_ID, COLUMNNAME_Classification, COLUMNNAME_CopyFrom, COLUMNNAME_Created, COLUMNNAME_CreatedBy, COLUMNNAME_CustomsTariffNumber, COLUMNNAME_Description, COLUMNNAME_DescriptionURL, COLUMNNAME_Discontinued, COLUMNNAME_DiscontinuedAt, COLUMNNAME_DocumentNote, COLUMNNAME_Group1, COLUMNNAME_Group2, COLUMNNAME_GuaranteeDays, COLUMNNAME_GuaranteeDaysMin, COLUMNNAME_Help, COLUMNNAME_ImageURL, COLUMNNAME_IsActive, COLUMNNAME_IsAutoProduce, COLUMNNAME_IsBOM, COLUMNNAME_IsDropShip, COLUMNNAME_IsExcludeAutoDelivery, COLUMNNAME_IsInvoicePrintDetails, COLUMNNAME_IsKanban, COLUMNNAME_IsManufactured, COLUMNNAME_IsOwnBox, COLUMNNAME_IsPhantom, COLUMNNAME_IsPickListPrintDetails, COLUMNNAME_IsPurchased, COLUMNNAME_IsSelfService, COLUMNNAME_IsSold, COLUMNNAME_IsStocked, COLUMNNAME_IsSummary, COLUMNNAME_IsVerified, COLUMNNAME_IsWebStoreFeatured, COLUMNNAME_LowLevel, COLUMNNAME_M_AttributeSet_ID, COLUMNNAME_M_AttributeSetInstance_ID, COLUMNNAME_M_FreightCategory_ID, COLUMNNAME_M_Locator_ID, COLUMNNAME_M_PartType_ID, COLUMNNAME_M_Product_Category_ID, COLUMNNAME_M_Product_ID, COLUMNNAME_M_Product_UU, COLUMNNAME_Name, COLUMNNAME_Processing, COLUMNNAME_ProductType, COLUMNNAME_R_MailText_ID, COLUMNNAME_S_ExpenseType_ID, COLUMNNAME_S_Resource_ID, COLUMNNAME_SalesRep_ID, COLUMNNAME_ShelfDepth, COLUMNNAME_ShelfHeight, COLUMNNAME_ShelfWidth, COLUMNNAME_SKU, COLUMNNAME_UnitsPerPack, COLUMNNAME_UnitsPerPallet, COLUMNNAME_UPC, COLUMNNAME_Updated, COLUMNNAME_UpdatedBy, COLUMNNAME_Value, COLUMNNAME_VersionNo, COLUMNNAME_Volume, COLUMNNAME_Weight, Model, Table_ID, Table_Name
-
-
Constructor Summary
Constructors Constructor Description MProduct(Properties ctx, int M_Product_ID, String trxName)Standard ConstructorMProduct(Properties ctx, ResultSet rs, String trxName)Load constructorMProduct(Properties ctx, MProduct copy)MProduct(Properties ctx, MProduct copy, String trxName)MProduct(MExpenseType et)Parent ConstructorMProduct(MProduct copy)MProduct(MResource resource, MResourceType resourceType)Parent ConstructorMProduct(X_I_Product impP)Import Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleanafterDelete(boolean success)Executed after Delete operation.protected booleanafterSave(boolean newRecord, boolean success)Called after Save for Post-Save Operationprotected booleanbeforeDelete()Executed before Delete operation.protected booleanbeforeSave(boolean newRecord)Called before Save for Pre-Save Operationstatic MProductforS_Resource_ID(Properties ctx, int S_Resource_ID)Deprecated.Since 3.5.3a.static MProductforS_Resource_ID(Properties ctx, int S_Resource_ID, String trxName)Get Product from Cache (immutable)static MProductget(int M_Product_ID)Get MProduct from Cache (immutable)static MProductget(Properties ctx, int M_Product_ID)Get MProduct from Cache (immutable)static MProductget(Properties ctx, int M_Product_ID, String trxName)Get MProduct from Cache (immutable)static MProduct[]get(Properties ctx, String whereClause, String trxName)Get MProducts from dbintgetA_Asset_Group_ID()Create Asset Group for this productMAttributeInstancegetAttributeInstance(String name, String trxName)Get attribute instance for this product by attribute nameMAttributeSetgetAttributeSet()Get Attribute Setstatic List<MProduct>getByUPC(Properties ctx, String upc, String trxName)Get MProduct using UPC/EAN (case sensitive)static MProductgetCopy(Properties ctx, int M_Product_ID, String trxName)Get updateable copy of MProduct from cacheStringgetCostingLevel(MAcctSchema as)Get Product Costing LevelStringgetCostingMethod(MAcctSchema as)Get Product Costing MethodMCostgetCostingRecord(MAcctSchema as, int AD_Org_ID, int M_ASI_ID)MCostgetCostingRecord(MAcctSchema as, int AD_Org_ID, int M_ASI_ID, String costingMethod)StringgetMMPolicy()Gets Material Management Policy.MProductDownload[]getProductDownloads(boolean requery)Get Active(!)intgetUOMPrecision()Get UOM Standard PrecisionStringgetUOMSymbol()Get UOM SymbolbooleanhasDownloads()Does the product have downloadsprotected booleanhasInventoryOrCost()HasInventoryOrCostbooleanisASIMandatory(boolean isSOTrx)Deprecated.booleanisASIMandatoryFor(String mandatoryType, boolean isSOTrx)Check if ASI is mandatory according to mandatory typebooleanisCreateAsset()Create Asset for this productbooleanisInstanceAttribute()Has the Product Instance AttributebooleanisItem()Product is ItembooleanisOneAssetPerUOM()Create One Asset Per UOMstatic booleanisProductStocked(Properties ctx, int M_Product_ID)Is Product StockedbooleanisService()Is ServicebooleanisStocked()Product is an Item and StockedbooleanisUseGuaranteeDateForMPolicy()Check if use GuaranteeDate for Material PolicyMProductmarkImmutable()mark PO as immutablebooleansetExpenseType(MExpenseType parent)Set Expense TypebooleansetResource(MResource parent)Set ResourcebooleansetResource(MResourceType parent)Set Resource TypeStringtoString()String representation-
Methods inherited from class org.compiere.model.X_M_Product
get_AccessLevel, getC_RevenueRecognition, getC_RevenueRecognition_ID, getC_SubscriptionType, getC_SubscriptionType_ID, getC_TaxCategory, getC_TaxCategory_ID, getC_UOM, getC_UOM_ID, getClassification, getCopyFrom, getCustomsTariffNumber, getDescription, getDescriptionURL, getDiscontinuedAt, getDocumentNote, getGroup1, getGroup2, getGuaranteeDays, getGuaranteeDaysMin, getHelp, getImageURL, getKeyNamePair, getLowLevel, getM_AttributeSet, getM_AttributeSet_ID, getM_AttributeSetInstance, getM_AttributeSetInstance_ID, getM_FreightCategory, getM_FreightCategory_ID, getM_Locator, getM_Locator_ID, getM_PartType, getM_PartType_ID, getM_Product_Category, getM_Product_Category_ID, getM_Product_ID, getM_Product_UU, getName, getProductType, getR_MailText, getR_MailText_ID, getS_ExpenseType, getS_ExpenseType_ID, getS_Resource, getS_Resource_ID, getSalesRep, getSalesRep_ID, getShelfDepth, getShelfHeight, getShelfWidth, getSKU, getUnitsPerPack, getUnitsPerPallet, getUPC, getValue, getVersionNo, getVolume, getWeight, initPO, isAutoProduce, isBOM, isDiscontinued, isDropShip, isExcludeAutoDelivery, isInvoicePrintDetails, isKanban, isManufactured, isOwnBox, isPhantom, isPickListPrintDetails, isProcessing, isPurchased, isSelfService, isSold, isSummary, isVerified, isWebStoreFeatured, setC_RevenueRecognition_ID, setC_SubscriptionType_ID, setC_TaxCategory_ID, setC_UOM_ID, setClassification, setCopyFrom, setCustomsTariffNumber, setDescription, setDescriptionURL, setDiscontinued, setDiscontinuedAt, setDocumentNote, setGroup1, setGroup2, setGuaranteeDays, setGuaranteeDaysMin, setHelp, setImageURL, setIsAutoProduce, setIsBOM, setIsDropShip, setIsExcludeAutoDelivery, setIsInvoicePrintDetails, setIsKanban, setIsManufactured, setIsOwnBox, setIsPhantom, setIsPickListPrintDetails, setIsPurchased, setIsSelfService, setIsSold, setIsStocked, setIsSummary, setIsVerified, setIsWebStoreFeatured, setLowLevel, setM_AttributeSet_ID, setM_AttributeSetInstance_ID, setM_FreightCategory_ID, setM_Locator_ID, setM_PartType_ID, setM_Product_Category_ID, setM_Product_ID, setM_Product_UU, setName, setProcessing, setProductType, setR_MailText_ID, setS_ExpenseType_ID, setS_Resource_ID, setSalesRep_ID, setShelfDepth, setShelfHeight, setShelfWidth, setSKU, setUnitsPerPack, setUnitsPerPallet, setUPC, setValue, setVersionNo, setVolume, setWeight
-
Methods inherited from class org.compiere.model.PO
checkImmutable, clearCrossTenantSafe, clone, columnExists, columnExists, compare, copyPO, copyValues, copyValues, createAttachment, delete, delete, delete_Accounting, delete_Tree, deleteEx, deleteEx, dump, dump, equals, get_Attribute, get_Attributes, get_ColumnCount, get_ColumnDescription, get_ColumnDisplayType, get_ColumnIndex, get_ColumnLabel, get_ColumnLookup, get_ColumnName, get_DisplayValue, get_HashMap, get_ID, get_IDOld, get_KeyColumns, get_Logger, get_OptimisticLockingColumns, get_Table_ID, get_TableName, get_Translation, get_Translation, get_Translation, get_Translation, get_Translation, get_TrxName, get_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, get_ValueDifference, get_ValueDifference, get_ValueE, get_ValueOfColumn, get_ValueOld, get_ValueOld, get_ValueOldAsInt, get_WhereClause, get_WhereClause, get_xmlDocument, get_xmlString, getAD_Client_ID, getAD_Org_ID, getAllIDs, getAttachment, getAttachment, getAttachmentData, getCreated, getCreatedBy, getCtx, getDoc, getFindParameter, getPdfAttachment, getUpdated, getUpdatedBy, getUUIDColumnName, getUUIDColumnName, hashCode, insert_Accounting, insert_Tree, insert_Tree, is_Changed, is_Immutable, is_new, is_UseOptimisticLocking, is_ValueChanged, is_ValueChanged, isActive, isAttachment, isColumnMandatory, isColumnUpdateable, isMandatoryOK, isPdfAttachment, isReplication, load, load, load, load, load, loadByUU, loadComplete, loadDefaults, loadSpecial, lock, makeImmutable, postDelete, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, saveEx, saveEx, saveNew_afterSetID, saveNew_getID, saveNewSpecial, saveReplica, saveUpdate, set_Attribute, set_ColumnUpdateable, set_CustomColumn, set_CustomColumnReturningBoolean, set_OptimisticLockingColumns, set_TrxName, set_TrxName, set_UseOptimisticLocking, set_Value, set_Value, set_Value, set_Value, set_ValueE, set_ValueNoCheck, set_ValueNoCheckE, set_ValueOfColumn, set_ValueOfColumn, set_ValueOfColumnReturningBoolean, set_ValueOfColumnReturningBoolean, setAD_Client_ID, setAD_Org_ID, setClientOrg, setClientOrg, setCrossTenantSafe, setDoc, setDocWorkflowMgr, setIsActive, setProcessedOn, setReplication, setStandardDefaults, setUpdateable, setUpdatedBy, unlock, update_Tree, validForeignKeys
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface org.compiere.model.I_M_Product
getAD_Client_ID, getAD_Org_ID, getCreated, getCreatedBy, getUpdated, getUpdatedBy, isActive, setAD_Org_ID, setIsActive
-
Methods inherited from interface org.compiere.model.I_Persistent
save
-
-
-
-
Constructor Detail
-
MProduct
public MProduct(Properties ctx, int M_Product_ID, String trxName)
Standard Constructor- Parameters:
ctx- contextM_Product_ID- idtrxName- transaction
-
MProduct
public MProduct(Properties ctx, ResultSet rs, String trxName)
Load constructor- Parameters:
ctx- contextrs- result settrxName- transaction
-
MProduct
public MProduct(MExpenseType et)
Parent Constructor- Parameters:
et- parent
-
MProduct
public MProduct(MResource resource, MResourceType resourceType)
Parent Constructor- Parameters:
resource- parentresourceType- resource type
-
MProduct
public MProduct(X_I_Product impP)
Import Constructor- Parameters:
impP- import
-
MProduct
public MProduct(MProduct copy)
- Parameters:
copy-
-
MProduct
public MProduct(Properties ctx, MProduct copy)
- Parameters:
ctx-copy-
-
MProduct
public MProduct(Properties ctx, MProduct copy, String trxName)
- Parameters:
ctx-copy-trxName-
-
-
Method Detail
-
get
public static MProduct get(int M_Product_ID)
Get MProduct from Cache (immutable)- Parameters:
M_Product_ID- id- Returns:
- MProduct or null
-
get
public static MProduct get(Properties ctx, int M_Product_ID)
Get MProduct from Cache (immutable)- Parameters:
ctx- contextM_Product_ID- id- Returns:
- MProduct or null
-
get
public static MProduct get(Properties ctx, int M_Product_ID, String trxName)
Get MProduct from Cache (immutable)- Parameters:
ctx- contextM_Product_ID- idtrxName- trx- Returns:
- MProduct or null
-
getCopy
public static MProduct getCopy(Properties ctx, int M_Product_ID, String trxName)
Get updateable copy of MProduct from cache- Parameters:
ctx-M_Product_ID-trxName-- Returns:
- MProduct
-
get
public static MProduct[] get(Properties ctx, String whereClause, String trxName)
Get MProducts from db- Parameters:
ctx- contextwhereClause- sql where clausetrxName- trx- Returns:
- MProducts
-
getByUPC
public static List<MProduct> getByUPC(Properties ctx, String upc, String trxName)
Get MProduct using UPC/EAN (case sensitive)- Parameters:
ctx- Contextupc- The upc to look for- Returns:
- List of MProduct
-
forS_Resource_ID
public static MProduct forS_Resource_ID(Properties ctx, int S_Resource_ID)
Deprecated.Since 3.5.3a. Please useforS_Resource_ID(Properties, int, String)Get Product from Cache- Parameters:
ctx- contextS_Resource_ID- resource ID- Returns:
- MProduct or null if not found
-
forS_Resource_ID
public static MProduct forS_Resource_ID(Properties ctx, int S_Resource_ID, String trxName)
Get Product from Cache (immutable)- Parameters:
ctx- contextS_Resource_ID- resource IDtrxName-- Returns:
- MProduct or null if not found
-
isProductStocked
public static boolean isProductStocked(Properties ctx, int M_Product_ID)
Is Product Stocked- Parameters:
ctx- contextM_Product_ID- id- Returns:
- true if found and stocked - false otherwise
-
setExpenseType
public boolean setExpenseType(MExpenseType parent)
Set Expense Type- Parameters:
parent- expense type- Returns:
- true if changed
-
setResource
public boolean setResource(MResource parent)
Set Resource- Parameters:
parent- resource- Returns:
- true if changed
-
setResource
public boolean setResource(MResourceType parent)
Set Resource Type- Parameters:
parent- resource type- Returns:
- true if changed
-
getUOMPrecision
public int getUOMPrecision()
Get UOM Standard Precision- Returns:
- UOM Standard Precision
-
getA_Asset_Group_ID
public int getA_Asset_Group_ID()
Create Asset Group for this product- Returns:
- asset group id
-
isCreateAsset
public boolean isCreateAsset()
Create Asset for this product- Returns:
- true if asset is created
-
getAttributeSet
public MAttributeSet getAttributeSet()
Get Attribute Set- Returns:
- set or null
-
isInstanceAttribute
public boolean isInstanceAttribute()
Has the Product Instance Attribute- Returns:
- true if instance attributes
-
isOneAssetPerUOM
public boolean isOneAssetPerUOM()
Create One Asset Per UOM- Returns:
- individual asset
-
isItem
public boolean isItem()
Product is Item- Returns:
- true if item
-
isStocked
public boolean isStocked()
Product is an Item and Stocked- Specified by:
isStockedin interfaceI_M_Product- Overrides:
isStockedin classX_M_Product- Returns:
- true if stocked and item
-
isService
public boolean isService()
Is Service- Returns:
- true if service (resource, online)
-
getUOMSymbol
public String getUOMSymbol()
Get UOM Symbol- Returns:
- UOM Symbol
-
getProductDownloads
public MProductDownload[] getProductDownloads(boolean requery)
Get Active(!) Product Downloads- Parameters:
requery- requery- Returns:
- array of downloads
-
hasDownloads
public boolean hasDownloads()
Does the product have downloads- Returns:
- true if downloads exists
-
toString
public String toString()
Description copied from class:POString representation- Overrides:
toStringin classX_M_Product- Returns:
- String representation
-
beforeSave
protected boolean beforeSave(boolean newRecord)
Description copied from class:POCalled before Save for Pre-Save Operation- Overrides:
beforeSavein classPO- Parameters:
newRecord- new record- Returns:
- true if record can be saved
-
hasInventoryOrCost
protected boolean hasInventoryOrCost()
HasInventoryOrCost- Returns:
- true if it has Inventory or Cost
-
afterSave
protected boolean afterSave(boolean newRecord, boolean success)Description copied from class:POCalled after Save for Post-Save Operation
-
beforeDelete
protected boolean beforeDelete()
Description copied from class:POExecuted before Delete operation.- Overrides:
beforeDeletein classPO- Returns:
- true if record can be deleted
-
afterDelete
protected boolean afterDelete(boolean success)
Description copied from class:POExecuted after Delete operation.- Overrides:
afterDeletein classPO- Parameters:
success- true if record deleted- Returns:
- true if delete is a success
-
getAttributeInstance
public MAttributeInstance getAttributeInstance(String name, String trxName)
Get attribute instance for this product by attribute name- Parameters:
name-trxName-- Returns:
-
getMMPolicy
public String getMMPolicy()
Gets Material Management Policy. Tries: Product Category, Client (in this order)- Returns:
- Material Management Policy
-
isUseGuaranteeDateForMPolicy
public boolean isUseGuaranteeDateForMPolicy()
Check if use GuaranteeDate for Material Policy- Returns:
-
isASIMandatory
@Deprecated public boolean isASIMandatory(boolean isSOTrx)
Deprecated.Check if ASI is mandatory- Parameters:
isSOTrx- is outgoing trx?- Returns:
- true if ASI is mandatory, false otherwise
-
isASIMandatoryFor
public boolean isASIMandatoryFor(String mandatoryType, boolean isSOTrx)
Check if ASI is mandatory according to mandatory type- Parameters:
mandatoryType-isSOTrx-- Returns:
- true if ASI is mandatory, false otherwise
-
getCostingLevel
public String getCostingLevel(MAcctSchema as)
Get Product Costing Level- Parameters:
as- accounting schema- Returns:
- product costing level
-
getCostingMethod
public String getCostingMethod(MAcctSchema as)
Get Product Costing Method- Parameters:
as- accounting schema- Returns:
- product costing method
-
getCostingRecord
public MCost getCostingRecord(MAcctSchema as, int AD_Org_ID, int M_ASI_ID)
-
getCostingRecord
public MCost getCostingRecord(MAcctSchema as, int AD_Org_ID, int M_ASI_ID, String costingMethod)
-
markImmutable
public MProduct markImmutable()
Description copied from interface:ImmutablePOSupportmark PO as immutable- Specified by:
markImmutablein interfaceImmutablePOSupport- Returns:
- PO
-
-