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:
    Serialized Form
    • Constructor Detail

      • 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,
                        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)
        Parameters:
        copy -
    • 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 - 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:
        MProducts
      • 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

        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
        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:
        isStocked in interface I_M_Product
        Overrides:
        isStocked in class X_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: 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
        Overrides:
        beforeSave in class PO
        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: PO
        Called after Save for Post-Save Operation
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - new record
        success - true if save operation was success
        Returns:
        if save was a success
      • beforeDelete

        protected boolean beforeDelete()
        Description copied from class: PO
        Executed before Delete operation.
        Overrides:
        beforeDelete in class PO
        Returns:
        true if record can be deleted
      • afterDelete

        protected boolean afterDelete​(boolean success)
        Description copied from class: PO
        Executed after Delete operation.
        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:
      • 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)