Class 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:
    • Constructor Details

      • MProduct

        public MProduct(Properties ctx, String M_Product_UU, String trxName)
        UUID based Constructor
        Parameters:
        ctx - Context
        M_Product_UU - UUID key
        trxName - Transaction
      • MProduct

        public MProduct(Properties ctx, int M_Product_ID, String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        M_Product_ID - id
        trxName - transaction
      • MProduct

        public MProduct(Properties ctx, int M_Product_ID, String trxName, String... virtualColumns)
        Parameters:
        ctx -
        M_Product_ID -
        trxName -
        virtualColumns -
      • MProduct

        public MProduct(Properties ctx, ResultSet rs, String trxName)
        Load constructor
        Parameters:
        ctx - context
        rs - result set
        trxName - transaction
      • MProduct

        public MProduct(MExpenseType et)
        Parent Constructor
        Parameters:
        et - parent
      • MProduct

        public MProduct(MResource resource, MResourceType resourceType)
        Parent Constructor
        Parameters:
        resource - parent
        resourceType - resource type
      • MProduct

        public MProduct(X_I_Product impP)
        Import Constructor
        Parameters:
        impP - import
      • MProduct

        public MProduct(MProduct copy)
        Copy constructor
        Parameters:
        copy -
      • MProduct

        public MProduct(Properties ctx, MProduct copy)
        Copy constructor
        Parameters:
        ctx -
        copy -
      • MProduct

        public MProduct(Properties ctx, MProduct copy, String trxName)
        Copy constructor
        Parameters:
        ctx -
        copy -
        trxName -
    • Method Details

      • 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 - context
        M_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 - context
        M_Product_ID - id
        trxName - 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 - context
        whereClause - sql where clause
        trxName - trx
        Returns:
        array of MProduct
      • getByUPC

        public static List<MProduct> getByUPC(Properties ctx, String upc, String trxName)
        Get MProduct using UPC/EAN (case sensitive)
        Parameters:
        ctx - Context
        upc - The upc to look for
        Returns:
        List of MProduct
      • forS_Resource_ID

        @Deprecated public static MProduct forS_Resource_ID(Properties ctx, int S_Resource_ID)
        Deprecated.
        Get Product from Cache
        Parameters:
        ctx - context
        S_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 - context
        S_Resource_ID - resource ID
        trxName -
        Returns:
        MProduct or null if not found
      • isProductStocked

        public static boolean isProductStocked(Properties ctx, int M_Product_ID)
        Is Product Stocked
        Parameters:
        ctx - context
        M_Product_ID - id
        Returns:
        true if found and stocked - false otherwise
      • setExpenseType

        public boolean setExpenseType(MExpenseType parent)
        Set Expense Type.
        Copy over value, name, description, UOM, product category and tax category.
        Parameters:
        parent - expense type
        Returns:
        true if changed
      • setResource

        public boolean setResource(MResource parent)
        Set Resource.
        Copy over IsActive, Value, Name and Description.
        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()
        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

        public MAttributeSet 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 interface I_M_Product
        Overrides:
        isStocked in class X_M_Product
        Returns:
        true if stocked and is 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 - 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

        public String toString()
        Description copied from class: PO
        String representation
        Overrides:
        toString in class X_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 class PO
        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.
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - true if it is a new record
        success - true if save operation was success
        Returns:
        if save was a success
      • 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 class PO
        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 class PO
        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:
        MAttributeInstance or null
      • getMMPolicy

        public String 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 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 - X_M_AttributeSet.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 (X_C_AcctSchema.COSTINGLEVEL_*)
      • getCostingMethod

        public String getCostingMethod(MAcctSchema as)
        Get Product Costing Method
        Parameters:
        as - accounting schema
        Returns:
        product costing method (X_C_AcctSchema.COSTINGMETHOD_*)
      • getCostingRecord

        public MCost getCostingRecord(MAcctSchema as, int AD_Org_ID, int M_ASI_ID)
        Parameters:
        as -
        AD_Org_ID -
        M_ASI_ID -
        Returns:
        MCost or null
      • getCostingRecord

        public MCost getCostingRecord(MAcctSchema as, int AD_Org_ID, int M_ASI_ID, String costingMethod)
        Parameters:
        as -
        AD_Org_ID -
        M_ASI_ID -
        costingMethod -
        Returns:
        MCost or null
      • markImmutable

        public MProduct markImmutable()
        Description copied from interface: ImmutablePOSupport
        mark PO as immutable
        Specified by:
        markImmutable in interface ImmutablePOSupport
        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