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
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:
-
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, UUID_NEW_RECORD, 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
ConstructorDescriptionMProduct
(Properties ctx, int M_Product_ID, String trxName) Standard ConstructorMProduct
(Properties ctx, int M_Product_ID, String trxName, String... virtualColumns) MProduct
(Properties ctx, String M_Product_UU, String trxName) UUID based ConstructorMProduct
(Properties ctx, ResultSet rs, String trxName) Load constructorMProduct
(Properties ctx, MProduct copy) Copy constructorMProduct
(Properties ctx, MProduct copy, String trxName) Copy constructorMProduct
(MExpenseType et) Parent ConstructorCopy constructorMProduct
(MResource resource, MResourceType resourceType) Parent ConstructorMProduct
(X_I_Product impP) Import Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
afterDelete
(boolean success) Execute after Delete operations.protected boolean
afterSave
(boolean newRecord, boolean success) Called after Save for Post-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.protected boolean
Execute before Delete operations.
Default implementation is nop, to be implemented in sub-classes that needed it.protected boolean
beforeSave
(boolean newRecord) Called before Save for Pre-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.static MProduct
forS_Resource_ID
(Properties ctx, int S_Resource_ID) Deprecated.Since 3.5.3a.static MProduct
forS_Resource_ID
(Properties ctx, int S_Resource_ID, String trxName) Get Product from Cache (immutable)static MProduct
get
(int M_Product_ID) Get MProduct from Cache (immutable)static MProduct
get
(Properties ctx, int M_Product_ID) Get MProduct from Cache (immutable)static MProduct
get
(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 DBint
Get asset group idgetAttributeInstance
(String name, String trxName) Get attribute instance for this product by attribute nameGet Attribute SetgetByUPC
(Properties ctx, String upc, String trxName) Get MProduct using UPC/EAN (case sensitive)static MProduct
getCopy
(Properties ctx, int M_Product_ID, String trxName) Get updateable copy of MProduct from cacheGet Product Costing LevelGet Product Costing MethodgetCostingRecord
(MAcctSchema as, int AD_Org_ID, int M_ASI_ID) getCostingRecord
(MAcctSchema as, int AD_Org_ID, int M_ASI_ID, String costingMethod) Gets Material Management Policy.getProductDownloads
(boolean requery) Get Active Product Downloadsint
Get UOM Standard PrecisionGet UOM Symbolboolean
Is product have downloadsprotected boolean
boolean
isASIMandatory
(boolean isSOTrx) Deprecated.boolean
isASIMandatoryFor
(String mandatoryType, boolean isSOTrx) Check if ASI is mandatory according to mandatory typeboolean
Create Asset for this productboolean
Is the Product has Instance Attributeboolean
isItem()
Is Product of Item typeboolean
isLot()
boolean
Is One Asset Per UOMstatic boolean
isProductStocked
(Properties ctx, int M_Product_ID) Is Product Stockedboolean
isSerial()
boolean
Is Serviceboolean
Product is an Item and is Stockedboolean
Check if product use GuaranteeDate for Material Policymark PO as immutableboolean
setExpenseType
(MExpenseType parent) Set Expense Type.
Copy over value, name, description, UOM, product category and tax category.boolean
setResource
(MResource parent) Set Resource.
Copy over IsActive, Value, Name and Description.boolean
setResource
(MResourceType parent) Set Resource TypetoString()
String representationMethods 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
buildInsertSQL, 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_UUID, get_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, 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, loadByUU, loadComplete, loadDefaults, loadPO, loadSpecial, lock, makeImmutable, postDelete, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, saveCrossTenantSafe, saveCrossTenantSafeEx, saveCrossTenantSafeEx, 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, toInsertSQL, 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 Details
-
MProduct
UUID based Constructor- Parameters:
ctx
- ContextM_Product_UU
- UUID keytrxName
- Transaction
-
MProduct
Standard Constructor- Parameters:
ctx
- contextM_Product_ID
- idtrxName
- transaction
-
MProduct
- Parameters:
ctx
-M_Product_ID
-trxName
-virtualColumns
-
-
MProduct
Load constructor- Parameters:
ctx
- contextrs
- result settrxName
- transaction
-
MProduct
Parent Constructor- Parameters:
et
- parent
-
MProduct
Parent Constructor- Parameters:
resource
- parentresourceType
- resource type
-
MProduct
Import Constructor- Parameters:
impP
- import
-
MProduct
Copy constructor- Parameters:
copy
-
-
MProduct
Copy constructor- Parameters:
ctx
-copy
-
-
MProduct
Copy constructor- Parameters:
ctx
-copy
-trxName
-
-
-
Method Details
-
get
Get MProduct from Cache (immutable)- Parameters:
M_Product_ID
- id- Returns:
- MProduct or null
-
get
Get MProduct from Cache (immutable)- Parameters:
ctx
- contextM_Product_ID
- id- Returns:
- MProduct or null
-
get
Get MProduct from Cache (immutable)- Parameters:
ctx
- contextM_Product_ID
- idtrxName
- trx- Returns:
- MProduct or null
-
getCopy
Get updateable copy of MProduct from cache- Parameters:
ctx
-M_Product_ID
-trxName
-- Returns:
- MProduct
-
get
Get MProducts from DB- Parameters:
ctx
- contextwhereClause
- sql where clausetrxName
- trx- Returns:
- array of MProduct
-
getByUPC
Get MProduct using UPC/EAN (case sensitive)- Parameters:
ctx
- Contextupc
- The upc to look for- Returns:
- List of MProduct
-
forS_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
Get Product from Cache (immutable)- Parameters:
ctx
- contextS_Resource_ID
- resource IDtrxName
-- Returns:
- MProduct or null if not found
-
isProductStocked
Is Product Stocked- Parameters:
ctx
- contextM_Product_ID
- id- Returns:
- true if found and stocked - false otherwise
-
setExpenseType
Set Expense Type.
Copy over value, name, description, UOM, product category and tax category.- Parameters:
parent
- expense type- Returns:
- true if changed
-
setResource
Set Resource.
Copy over IsActive, Value, Name and Description.- Parameters:
parent
- resource- Returns:
- true if changed
-
setResource
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()Get asset group id- Returns:
- A_Asset_Group_ID
-
isCreateAsset
public boolean isCreateAsset()Create Asset for this product- Returns:
- true if asset is created
-
getAttributeSet
Get Attribute Set- Returns:
- MAttributeSet or null
-
isInstanceAttribute
public boolean isInstanceAttribute()Is the Product has Instance Attribute- Returns:
- true if product has instance attributes
-
isOneAssetPerUOM
public boolean isOneAssetPerUOM()Is One Asset Per UOM- Returns:
- true if it is one asset per UOM
-
isItem
public boolean isItem()Is Product of Item type- Returns:
- true if product is of item type (PRODUCTTYPE_Item)
-
isStocked
public boolean isStocked()Product is an Item and is Stocked- Specified by:
isStocked
in interfaceI_M_Product
- Overrides:
isStocked
in classX_M_Product
- Returns:
- true if stocked and is item
-
isService
public boolean isService()Is Service- Returns:
- true if service (resource, online)
-
getUOMSymbol
Get UOM Symbol- Returns:
- UOM Symbol
-
getProductDownloads
Get Active Product Downloads- Parameters:
requery
- true to re-query from DB- Returns:
- array of product downloads
-
hasDownloads
public boolean hasDownloads()Is product have downloads- Returns:
- true if downloads exists
-
toString
Description copied from class:PO
String representation- Overrides:
toString
in classX_M_Product
- Returns:
- String representation
-
beforeSave
protected boolean beforeSave(boolean newRecord) Description copied from class:PO
Called before Save for Pre-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.- Overrides:
beforeSave
in classPO
- Parameters:
newRecord
- true if it is a new record- Returns:
- true if record can be saved
-
hasInventoryOrCost
protected boolean hasInventoryOrCost()- Returns:
- true if product has inventory transaction (MTransaction) or cost detail (MCostDetail) records.
-
afterSave
protected boolean afterSave(boolean newRecord, boolean success) Description copied from class:PO
Called after Save for Post-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it. -
beforeDelete
protected boolean beforeDelete()Description copied from class:PO
Execute before Delete operations.
Default implementation is nop, to be implemented in sub-classes that needed it.- Overrides:
beforeDelete
in classPO
- Returns:
- true if record can be deleted
-
afterDelete
protected boolean afterDelete(boolean success) Description copied from class:PO
Execute after Delete operations.
Default implementation is nop, to be implemented in sub-classes that needed it.- Overrides:
afterDelete
in classPO
- Parameters:
success
- true if record deleted- Returns:
- true if delete is a success
-
getAttributeInstance
Get attribute instance for this product by attribute name- Parameters:
name
-trxName
-- Returns:
- MAttributeInstance or null
-
getMMPolicy
Gets Material Management Policy. Tries: Product Category, Client (in this order).- Returns:
- Material Management Policy (Fifo, Lifo)
-
isUseGuaranteeDateForMPolicy
public boolean isUseGuaranteeDateForMPolicy()Check if product use GuaranteeDate for Material Policy- Returns:
- true if product uses GuaranteeDate for Material Policy
-
isASIMandatory
Deprecated.Check if ASI is mandatory- Parameters:
isSOTrx
- is outgoing trx?- Returns:
- true if ASI is mandatory, false otherwise
-
isASIMandatoryFor
Check if ASI is mandatory according to mandatory type- Parameters:
mandatoryType
- X_M_AttributeSet.MANDATORYTYPE_*isSOTrx
-- Returns:
- true if ASI is mandatory, false otherwise
-
getCostingLevel
Get Product Costing Level- Parameters:
as
- accounting schema- Returns:
- product costing level (X_C_AcctSchema.COSTINGLEVEL_*)
-
getCostingMethod
Get Product Costing Method- Parameters:
as
- accounting schema- Returns:
- product costing method (X_C_AcctSchema.COSTINGMETHOD_*)
-
getCostingRecord
- Parameters:
as
-AD_Org_ID
-M_ASI_ID
-- Returns:
- MCost or null
-
getCostingRecord
- Parameters:
as
-AD_Org_ID
-M_ASI_ID
-costingMethod
-- Returns:
- MCost or null
-
markImmutable
Description copied from interface:ImmutablePOSupport
mark PO as immutable- Specified by:
markImmutable
in interfaceImmutablePOSupport
- Returns:
- PO
-
isSerial
public boolean isSerial()- Returns:
- true if instance of product is managed with serial no
-
isLot
public boolean isLot()- Returns:
- true if instance of product is managed with lot
-