svn commit: r813413 - in /ofbiz/trunk: applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ applications/order/script/org/ofbiz/order/order/ applications/order/src/org/ofbiz/order/order/ applications/order/webapp/ordermgr/WEB-INF/actions/...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r813413 - in /ofbiz/trunk: applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ applications/order/script/org/ofbiz/order/order/ applications/order/src/org/ofbiz/order/order/ applications/order/webapp/ordermgr/WEB-INF/actions/...

jacopoc
Author: jacopoc
Date: Thu Sep 10 13:02:33 2009
New Revision: 813413

URL: http://svn.apache.org/viewvc?rev=813413&view=rev
Log:
New util method to find out if a "type" record has a given ancestor.
The method is also used to clean the code related to the two existing marketing package types (that have now in common the same parent).
This will make the framework more flexible because you will be able to create a new product subtype and the system will treat them as its parent type; then you can add custom code to treat it in the special way (if needed). This pattern can be extended in other areas of the system, starting from product types (right now it is also applied to marketing packages).
Thanks to Mridul Pathak for the patch - OFBIZ-2902

Modified:
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
    ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/ShipGroups.groovy
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl
    ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl
    ofbiz/trunk/applications/product/config/ProductEntityLabels.xml
    ofbiz/trunk/applications/product/data/ProductTypeData.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.groovy
    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Thu Sep 10 13:02:33 2009
@@ -40,6 +40,7 @@
 import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.common.CommonWorkers;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericPK;
@@ -2811,7 +2812,7 @@
             if (product == null) {
                 return ServiceUtil.returnError("Error: product with id [" + inventoryItem.get("productId") + "] not found.");
             }
-            if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId"))) {
+            if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_AUTO")) {
                 Map serviceContext = UtilMisc.toMap("inventoryItemId", inventoryItemId,
                                                     "userLogin", userLogin);
                 /*

Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Thu Sep 10 13:02:33 2009
@@ -182,11 +182,11 @@
         <entity-one entity-name="Product" auto-field-map="true" value-field="product"/>
         <set from-field="product.requirementMethodEnumId" field="requirementMethodId"/>
         <if-empty field="requirementMethodId">
+            <set field="isMarketingPkg" value="${groovy: org.ofbiz.common.CommonWorkers.hasParentType(delegator, 'ProductType', 'productTypeId', product.productTypeId, 'parentTypeId', 'MARKETING_PKG')}" type="Boolean"/>
             <if>
                 <condition>
                     <and>
-                        <if-compare field="product.productTypeId" operator="not-equals" value="MARKETING_PKG_AUTO"/>
-                        <if-compare field="product.productTypeId" operator="not-equals" value="MARKETING_PKG_PICK"/>
+                        <if-compare field="isMarketingPkg" operator="equals" value="false" type="Boolean"/>
                         <if-compare field="product.productTypeId" operator="not-equals" value="DIGITAL_GOOD"/>
                         <not><if-empty field="order"/></not>
                     </and>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Thu Sep 10 13:02:33 2009
@@ -48,6 +48,7 @@
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.collections.ResourceBundleMapWrapper;
+import org.ofbiz.common.CommonWorkers;
 import org.ofbiz.common.DataModelConstants;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntity;
@@ -1166,7 +1167,7 @@
                             }
                             if (reserveInventory) {
                                 // for MARKETING_PKG_PICK reserve the components
-                                if ("MARKETING_PKG_PICK".equals(product.get("productTypeId"))) {
+                                if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_PICK")) {
                                     Map componentsRes = dispatcher.runSync("getAssociatedProducts", UtilMisc.toMap("productId", orderItem.getString("productId"), "type", "PRODUCT_COMPONENT"));
                                     if (ServiceUtil.isError(componentsRes)) {
                                         resErrorMessages.add(componentsRes.get(ModelService.ERROR_MESSAGE));
@@ -1226,7 +1227,7 @@
                             }
                             // Reserving inventory or not we still need to create a marketing package
                             // If the product is a marketing package auto, attempt to create enough packages to bring ATP back to 0, won't necessarily create enough to cover this order.
-                            if ("MARKETING_PKG_AUTO".equals(product.get("productTypeId"))) {
+                            if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_AUTO")) {
                                 // do something tricky here: run as the "system" user
                                 // that can actually create and run a production run
                                 GenericValue permUserLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "system"));

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/ShipGroups.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/ShipGroups.groovy?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/ShipGroups.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/ShipGroups.groovy Thu Sep 10 13:02:33 2009
@@ -21,6 +21,7 @@
 import javolution.util.FastList;
 
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.common.CommonWorkers;
 import org.ofbiz.entity.util.EntityUtil;
 
 orderId = parameters.orderId;
@@ -107,9 +108,8 @@
         line.quantityShipped = quantityShipped;
         line.quantityOpen = quantityOpen;
 
-        if ("MARKETING_PKG_AUTO".equals(product.productTypeId) ||
-                "MARKETING_PKG_PICK".equals(product.productTypeId)) {
-            assocType = "MARKETING_PKG_AUTO".equals(product.productTypeId) ? "MANUF_COMPONENT" : "PRODUCT_COMPONENT";
+        if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG")) {
+            assocType = CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG_AUTO") ? "MANUF_COMPONENT" : "PRODUCT_COMPONENT";
             sublines = expandProductGroup(product, quantityInGroup, quantityShipped, quantityOpen, assocType);
             line.expandedList = sublines;
         }

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl Thu Sep 10 13:02:33 2009
@@ -142,7 +142,7 @@
                   <div>
                     <a href="/catalog/control/EditProductInventoryItems?productId=${productId}" class="buttontext"><b>${uiLabelMap.ProductInventory}</b></a>:
                     ${uiLabelMap.ProductAtp} = ${availableToPromiseMap.get(productId)}, ${uiLabelMap.ProductQoh} = ${quantityOnHandMap.get(productId)}
-                    <#if product.productTypeId == "MARKETING_PKG_AUTO" || product.productTypeId == "MARKETING_PKG_PICK">
+                    <#if Static["org.ofbiz.common.CommonWorkers"].hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG")>
                     ${uiLabelMap.ProductMarketingPackageATP} = ${mktgPkgATPMap.get(productId)}, ${uiLabelMap.ProductMarketingPackageQOH} = ${mktgPkgQOHMap.get(productId)}
                     </#if>
                     <#if (availableToPromiseMap.get(cartLine.getProductId()) <= 0) && (shoppingCart.getOrderType() == "SALES_ORDER")>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl Thu Sep 10 13:02:33 2009
@@ -101,7 +101,7 @@
                               </#if>
                               <tr><td>${uiLabelMap.ProductInInventory} [${uiLabelMap.CommonAll} ${uiLabelMap.ProductFacilities}] ${uiLabelMap.ProductQoh}</td>
                                 <td style="padding-left: 15px; text-align: left;">${qohQuantity} (${uiLabelMap.ProductAtp}: ${atpQuantity})</td></tr>
-                              <#if (product != null) && (product.productTypeId != null) && (product.productTypeId == "MARKETING_PKG_AUTO" || product.productTypeId == "MARKETING_PKG_PICK")>
+                              <#if (product != null) && (product.productTypeId != null) && Static["org.ofbiz.common.CommonWorkers"].hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG")>
                                 <tr><td>${uiLabelMap.ProductMarketingPackageQOH}</td>
                                   <td style="padding-left: 15px; text-align: left;">${mktgPkgQOH} (${uiLabelMap.ProductAtp}: ${mktgPkgATP})</td></tr>
                               </#if>

Modified: ofbiz/trunk/applications/product/config/ProductEntityLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductEntityLabels.xml?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductEntityLabels.xml (original)
+++ ofbiz/trunk/applications/product/config/ProductEntityLabels.xml Thu Sep 10 13:02:33 2009
@@ -2204,9 +2204,12 @@
         <value xml:lang="th">สินค้า</value>
         <value xml:lang="zh">商品</value>
     </property>
+    <property key="ProductType.description.MARKETING_PKG">
+        <value xml:lang="en">Marketing Package</value>
+    </property>
     <property key="ProductType.description.MARKETING_PKG_AUTO">
         <value xml:lang="de">Marketingpaket</value>
-        <value xml:lang="en">Marketing Package</value>
+        <value xml:lang="en">Marketing Package: Auto Manufactured</value>
         <value xml:lang="es">Paquete de marketing</value>
         <value xml:lang="fr">Conditionnement marketing</value>
         <value xml:lang="it">Pacco di vendita</value>

Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original)
+++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Thu Sep 10 13:02:33 2009
@@ -462,8 +462,9 @@
     <ProductType description="Digital Good" isPhysical="N" isDigital="Y" hasTable="N" parentTypeId="GOOD" productTypeId="DIGITAL_GOOD"/>
     <ProductType description="Finished/Digital Good" isPhysical="Y" isDigital="Y" hasTable="N" parentTypeId="GOOD" productTypeId="FINDIG_GOOD"/>
     <ProductType description="Configurable Good" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="AGGREGATED"/>
-    <ProductType description="Marketing Package: Auto Manufactured" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="MARKETING_PKG_AUTO"/>
-    <ProductType description="Marketing Package: Pick Assembly" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="MARKETING_PKG_PICK"/>
+    <ProductType description="Marketing Package" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="MARKETING_PKG"/>
+    <ProductType description="Marketing Package: Auto Manufactured" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="MARKETING_PKG" productTypeId="MARKETING_PKG_AUTO"/>
+    <ProductType description="Marketing Package: Pick Assembly" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="MARKETING_PKG" productTypeId="MARKETING_PKG_PICK"/>
     <ProductType description="Work In Process" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="WIP"/>
     <ProductType description="Configurable Good Configuration" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="AGGREGATED" productTypeId="AGGREGATED_CONF"/>
 

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Thu Sep 10 13:02:33 2009
@@ -675,7 +675,8 @@
         <set field="quantityOnHandTotal" value="0" type="BigDecimal"/>
         <set from-field="parameters.productId" field="lookupMktgPkgParams.productId"/>
         <entity-one entity-name="Product" value-field="product"/>
-        <if-compare field="product.productTypeId" operator="equals" value="MARKETING_PKG_AUTO">
+        <set field="isMarketingPkgAuto" value="${groovy: org.ofbiz.common.CommonWorkers.hasParentType(delegator, 'ProductType', 'productTypeId', product.productTypeId, 'parentTypeId', 'MARKETING_PKG_AUTO')}" type="Boolean"/>
+        <if-compare field="isMarketingPkgAuto" operator="equals" value="true" type="Boolean">
             <set value="MANUF_COMPONENT" field="lookupMktgPkgParams.type"/>
         <else>
             <set value="PRODUCT_COMPONENT" field="lookupMktgPkgParams.type"/>

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml Thu Sep 10 13:02:33 2009
@@ -581,24 +581,17 @@
 
             <set from-field="parameters.productId" field="callServiceMap.productId"/>
             <set from-field="productStore.inventoryFacilityId" field="callServiceMap.facilityId"/>
-            <if>
-                <condition>
-                    <or>
-                        <if-compare field="product.productTypeId" value="MARKETING_PKG_AUTO" operator="equals"/>
-                        <if-compare field="product.productTypeId" value="MARKETING_PKG_PICK" operator="equals"/>
-                    </or>
-                </condition>
-                <then>
-                    <call-service service-name="getMktgPackagesAvailable" in-map-name="callServiceMap">
-                        <result-to-field result-name="availableToPromiseTotal"/>
-                    </call-service>
-                </then>
+            <set field="isMarketingPkg" value="${groovy: org.ofbiz.common.CommonWorkers.hasParentType(delegator, 'ProductType', 'productTypeId', product.productTypeId, 'parentTypeId', 'MARKETING_PKG')}" type="Boolean"/>
+            <if-compare field="isMarketingPkg" operator="equals" value="true" type="Boolean">
+                <call-service service-name="getMktgPackagesAvailable" in-map-name="callServiceMap">
+                    <result-to-field result-name="availableToPromiseTotal"/>
+                </call-service>
                 <else>
                     <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap">
                         <result-to-field result-name="availableToPromiseTotal"/>
                     </call-service>
                 </else>
-            </if>
+            </if-compare>
             <!-- check to see if we got enough back... -->
             <if-compare-field field="availableToPromiseTotal" to-field="parameters.quantity" operator="greater-equals" type="BigDecimal">
                 <set value="Y" field="available"/>
@@ -621,24 +614,17 @@
                     <!-- Right now the answer is yes, it only succeeds if one facility has sufficient inventory for the order. -->
                     <set from-field="parameters.productId" field="callServiceMap.productId"/>
                     <set from-field="productStoreFacility.facilityId" field="callServiceMap.facilityId"/>
-                    <if>
-                        <condition>
-                            <or>
-                                <if-compare field="product.productTypeId" value="MARKETING_PKG_AUTO" operator="equals"/>
-                                <if-compare field="product.productTypeId" value="MARKETING_PKG_PICK" operator="equals"/>
-                            </or>
-                        </condition>
-                        <then>
-                            <call-service service-name="getMktgPackagesAvailable" in-map-name="callServiceMap">
-                                <result-to-field result-name="availableToPromiseTotal"/>
-                            </call-service>
-                        </then>
+                    <set field="isMarketingPkg" value="${groovy: org.ofbiz.common.CommonWorkers.hasParentType(delegator, 'ProductType', 'productTypeId', product.productTypeId, 'parentTypeId', 'MARKETING_PKG')}" type="Boolean"/>
+                    <if-compare field="isMarketingPkg" operator="equals" value="true" type="Boolean">
+                        <call-service service-name="getMktgPackagesAvailable" in-map-name="callServiceMap">
+                            <result-to-field result-name="availableToPromiseTotal"/>
+                        </call-service>
                         <else>
                             <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap">
                                 <result-to-field result-name="availableToPromiseTotal"/>
                             </call-service>
                         </else>
-                    </if>
+                    </if-compare>
 
                     <clear-field field="callServiceMap"/>
 

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java Thu Sep 10 13:02:33 2009
@@ -34,6 +34,7 @@
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.common.CommonWorkers;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -749,8 +750,7 @@
 
                 // get both the real ATP/QOH available and the quantities available from marketing packages
                 try {
-                    if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId")) ||
-                            "MARKETING_PKG_PICK".equals(product.getString("productTypeId"))) {
+                    if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG")) {
                         mktgPkgInvResult = dispatcher.runSync("getMktgPackagesAvailable", UtilMisc.toMap("productId", productId, "facilityId", facility.getString("facilityId")));
                     }
                     invResult = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facility.getString("facilityId")));
@@ -767,7 +767,7 @@
                     if (fatp != null) atp = atp.add(fatp);
                     if (fqoh != null) qoh = qoh.add(fqoh);
                 }
-                if (("MARKETING_PKG_AUTO".equals(product.getString("productTypeId")) || "MARKETING_PKG_PICK".equals(product.getString("productTypeId"))) && (!ServiceUtil.isError(mktgPkgInvResult))) {
+                if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG") && !ServiceUtil.isError(mktgPkgInvResult)) {
                     BigDecimal fatp = (BigDecimal) mktgPkgInvResult.get("availableToPromiseTotal");
                     BigDecimal fqoh = (BigDecimal) mktgPkgInvResult.get("quantityOnHandTotal");
                     if (fatp != null) mktgPkgAtp = mktgPkgAtp.add(fatp);
@@ -809,8 +809,7 @@
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
-        if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId")) ||
-                "MARKETING_PKG_PICK".equals(product.getString("productTypeId"))) {
+        if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG")) {
             try {
                 resultOutput = dispatcher.runSync("getMktgPackagesAvailable", contextInput);
             } catch (GenericServiceException e) {

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy Thu Sep 10 13:02:33 2009
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+import org.ofbiz.common.CommonWorkers
 import org.ofbiz.entity.condition.*
 import org.ofbiz.product.inventory.InventoryWorker
 
@@ -85,8 +86,7 @@
             quantitySummary.totalAvailableToPromise = resultOutput.availableToPromiseTotal;
     
             // if the product is a MARKETING_PKG_AUTO/PICK, then also get the quantity which can be produced from components
-            if ("MARKETING_PKG_AUTO".equals(product.productTypeId) ||
-                "MARKETING_PKG_PICK".equals(product.productTypeId)) {
+            if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG")) {
                 resultOutput = dispatcher.runSync("getMktgPackagesAvailable", [productId : productId, facilityId : facility.facilityId]);
                 quantitySummary.mktgPkgQOH = resultOutput.quantityOnHandTotal;
                 quantitySummary.mktgPkgATP = resultOutput.availableToPromiseTotal;

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.groovy?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.groovy Thu Sep 10 13:02:33 2009
@@ -20,6 +20,7 @@
 // This script gets shipment items grouped by package for use in the packing slip PDF or any screens that require by-package layout
 
 import org.ofbiz.base.util.*;
+import org.ofbiz.common.CommonWorkers;
 import org.ofbiz.entity.condition.*;
 
 // Since this script is run after ViewShipment, we will re-use the shipment in the context
@@ -110,15 +111,15 @@
         line.product = product;
         line.quantityRequested = quantityRequestedByProduct.get(product.productId);
         line.quantityInPackage = content.quantity;
-        if (productTypeId.equals("MARKETING_PKG_PICK") && line.quantityInPackage > line.quantityRequested) {
+        if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", productTypeId, "parentTypeId", "MARKETING_PKG_PICK") && line.quantityInPackage > line.quantityRequested) {
             line.quantityInPackage = line.quantityRequested;
         }
         line.quantityInShipment = quantityInShipmentByProduct.get(product.productId);
-        if (productTypeId.equals("MARKETING_PKG_PICK") && line.quantityInShipment > line.quantityRequested) {
+        if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", productTypeId, "parentTypeId", "MARKETING_PKG_PICK") && line.quantityInShipment > line.quantityRequested) {
             line.quantityInShipment = line.quantityRequested;
         }
         line.quantityShipped = quantityShippedByProduct.get(product.productId);
-        if (productTypeId.equals("MARKETING_PKG_PICK") && line.quantityShipped > line.quantityRequested) {
+        if (CommonWorkers.hasParentType(delegator, "ProductType", "productTypeId", productTypeId, "parentTypeId", "MARKETING_PKG_PICK") && line.quantityShipped > line.quantityRequested) {
             line.quantityShipped = line.quantityRequested;
         }
         lines.add(line);

Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=813413&r1=813412&r2=813413&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Sep 10 13:02:33 2009
@@ -105,4 +105,38 @@
 
         return geoList;
     }
+    
+    /**
+     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
+     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
+     *
+     * @param delegator       The GenericDelegator object.
+     * @param entityName      Name of the Type entity on which check is performed.
+     * @param primaryKey      Primary Key field of the Type entity.
+     * @param childType       Type value for which the check is performed.
+     * @param parentTypeField Field in Type entity which stores the parent type.
+     * @param parentType      Value of the parent type against which check is performed.
+     * @return boolean value based on the check results.
+     */
+    public static boolean hasParentType(GenericDelegator delegator, String entityName, String primaryKey, String childType, String parentTypeField, String parentType) {
+        GenericValue childTypeValue = null;
+        try {
+            childTypeValue = delegator.findOne(entityName, UtilMisc.toMap(primaryKey, childType), true);
+        } catch (GenericEntityException e) {
+            Debug.logError("Error finding "+entityName+" record for type "+childType, module);
+        }
+        if (childTypeValue != null) {
+            if (parentType.equals(childTypeValue.getString(primaryKey))) return true;
+            
+            if (childTypeValue.getString(parentTypeField) != null) {
+                if (parentType.equals(childTypeValue.getString(parentTypeField))) {
+                    return true;
+                } else {
+                    hasParentType(delegator, entityName, primaryKey, childTypeValue.getString(parentTypeField), parentTypeField, parentType);
+                }
+            }
+        }
+        
+        return false;
+    }
 }