From 77d8b29fdffa4f76f2ed7083fd7588e677cc420a Mon Sep 17 00:00:00 2001 From: Ashish Vijaywargiya Date: Sat, 19 Dec 2015 11:32:08 +0000 Subject: [PATCH] Applied patch from OFBIZ-6777 - Product weight field enhancements ================================ There are three sets of dimensions in the Product entity. (productHeight, shippingHeight), (productWidth, shippingWidth), (productDepth, shippingDepth) but in case of weight, there is another set of dimension field weight and productWeight which are inconsistent in nature. Fix this thing and correct all instances of this in the framework. ================================= Thanks Suraj for reporting the issue and providing the patch for the same. Thanks Jacopo and Pierre for discussing the issue with Suraj. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1720900 13f79535-47bb-0310-9956-ffa450edef68 --- .../entitydef/product-entitymodel.xml | 2 +- .../jobshopmgt/WorkWithShipmentPlans.groovy | 4 +- .../ofbiz/order/order/OrderReadHelper.java | 4 +- .../order/shoppingcart/ShoppingCartItem.java | 4 +- .../ordermgr/entry/catalog/productdetail.ftl | 4 +- .../product/product/ProductUomFormulas.xml | 4 +- .../ofbiz/product/product/ProductEvents.java | 4 +- .../ofbiz/product/product/ProductWorker.java | 4 +- .../shipment/shipment/ShipmentWorker.java | 2 +- .../catalog/product/EditProductQuickAdmin.ftl | 4 +- .../actions/shipment/EditShipmentPlan.groovy | 8 ++-- .../product/widget/catalog/ProductForms.xml | 4 +- specialpurpose/ecommerce/data/DemoProduct.xml | 40 +++++++++---------- .../ecommerce/catalog/productdetail.ftl | 4 +- .../webapp/ecommerce/order/orderitems.ftl | 4 +- .../googlebase/ProductsExportToGoogle.java | 4 +- .../solr/src/org/ofbiz/solr/ProductUtil.java | 2 +- 17 files changed, 51 insertions(+), 51 deletions(-) diff --git a/applications/datamodel/entitydef/product-entitymodel.xml b/applications/datamodel/entitydef/product-entitymodel.xml index 3dd0a0cbce..4e2607c860 100644 --- a/applications/datamodel/entitydef/product-entitymodel.xml +++ b/applications/datamodel/entitydef/product-entitymodel.xml @@ -2724,7 +2724,7 @@ under the License. Use this for products which are sold in fixed denominations, such as gift certificates or calling cards. - The shipping weight of the product. + The shipping weight of the product. diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy index 376c5dd8bf..c2be87fe71 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy @@ -115,8 +115,8 @@ if (shipmentPlans) { if (shipmentPlan.quantity) { quantity = shipmentPlan.quantity; } - if (product.weight) { - weight = product.weight * quantity; + if (product.productWeight) { + weight = product.productWeight * quantity; } oneRow.weight = weight; if (product.weightUomId) { diff --git a/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java b/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java index 2f157a1b83..ed5365bef1 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java +++ b/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java @@ -991,7 +991,7 @@ public class OrderReadHelper { } if (product != null) { if (ProductWorker.shippingApplies(product)) { - BigDecimal weight = product.getBigDecimal("weight"); + BigDecimal weight = product.getBigDecimal("shippingWeight"); String isVariant = product.getString("isVariant"); if (weight == null && "Y".equals(isVariant)) { // get the virtual product and check its weight @@ -1000,7 +1000,7 @@ public class OrderReadHelper { if (UtilValidate.isNotEmpty(virtualId)) { GenericValue virtual = EntityQuery.use(delegator).from("Product").where("productId", virtualId).cache().queryOne(); if (virtual != null) { - weight = virtual.getBigDecimal("weight"); + weight = virtual.getBigDecimal("shippingWeight"); } } } catch (GenericEntityException e) { diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java index 636aaaa35e..d35f7045fe 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java @@ -1805,12 +1805,12 @@ public class ShoppingCartItem implements java.io.Serializable { public BigDecimal getWeight() { GenericValue product = getProduct(); if (product != null) { - BigDecimal weight = product.getBigDecimal("weight"); + BigDecimal weight = product.getBigDecimal("productWeight"); // if the weight is null, see if there is an associated virtual product and get the weight of that product if (weight == null) { GenericValue parentProduct = this.getParentProduct(); - if (parentProduct != null) weight = parentProduct.getBigDecimal("weight"); + if (parentProduct != null) weight = parentProduct.getBigDecimal("productWeight"); } if (weight == null) { diff --git a/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl b/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl index 1c97437558..741ed3811c 100644 --- a/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl +++ b/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl @@ -392,10 +392,10 @@ ${virtualJavaScript!} - <#if (product.weight?? && product.weight?double != 0) || product.weightUomId?has_content> + <#if (product.productWeight?? && product.productWeight?double != 0) || product.weightUomId?has_content> <#assign weightUom = product.getRelatedOne("WeightUom", true)!/>
- ${uiLabelMap.CommonWeight}: ${product.weight!} ${((weightUom.abbreviation)?default(product.weightUomId))!} + ${uiLabelMap.CommonWeight}: ${product.productWeight!} ${((weightUom.abbreviation)?default(product.weightUomId))!}
<#if (product.productHeight?? && product.productHeight?double != 0) || product.heightUomId?has_content> diff --git a/applications/product/script/org/ofbiz/product/product/ProductUomFormulas.xml b/applications/product/script/org/ofbiz/product/product/ProductUomFormulas.xml index edbb99b7f4..d20f3a3b5a 100644 --- a/applications/product/script/org/ofbiz/product/product/ProductUomFormulas.xml +++ b/applications/product/script/org/ofbiz/product/product/ProductUomFormulas.xml @@ -92,7 +92,7 @@ under the License. - + @@ -121,7 +121,7 @@ under the License. - + diff --git a/applications/product/src/org/ofbiz/product/product/ProductEvents.java b/applications/product/src/org/ofbiz/product/product/ProductEvents.java index b9946311e4..2d7ceabbf5 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductEvents.java +++ b/applications/product/src/org/ofbiz/product/product/ProductEvents.java @@ -441,7 +441,7 @@ public class ProductEvents { product.set("productHeight", parseBigDecimalForEntity(request.getParameter("productHeight"))); product.set("productWidth", parseBigDecimalForEntity(request.getParameter("productWidth"))); product.set("productDepth", parseBigDecimalForEntity(request.getParameter("productDepth"))); - product.set("weight", parseBigDecimalForEntity(request.getParameter("weight"))); + product.set("productWeight", parseBigDecimalForEntity(request.getParameter("weight"))); // default unit settings for shipping parameters product.set("heightUomId", "LEN_in"); @@ -478,7 +478,7 @@ public class ProductEvents { product.set("productHeight", parseBigDecimalForEntity(request.getParameter("productHeight" + attribIdx))); product.set("productWidth", parseBigDecimalForEntity(request.getParameter("productWidth" + attribIdx))); product.set("productDepth", parseBigDecimalForEntity(request.getParameter("productDepth" + attribIdx))); - product.set("weight", parseBigDecimalForEntity(request.getParameter("weight" + attribIdx))); + product.set("productWeight", parseBigDecimalForEntity(request.getParameter("weight" + attribIdx))); BigDecimal floz = parseBigDecimalForEntity(request.getParameter("~floz" + attribIdx)); BigDecimal ml = parseBigDecimalForEntity(request.getParameter("~ml" + attribIdx)); BigDecimal ntwt = parseBigDecimalForEntity(request.getParameter("~ntwt" + attribIdx)); diff --git a/applications/product/src/org/ofbiz/product/product/ProductWorker.java b/applications/product/src/org/ofbiz/product/product/ProductWorker.java index 0714bfb053..b55c58db53 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductWorker.java +++ b/applications/product/src/org/ofbiz/product/product/ProductWorker.java @@ -815,13 +815,13 @@ public class ProductWorker { * convert the value otherwise the weight is returned as is. */ public static BigDecimal getProductWeight(GenericValue product, String desiredUomId, Delegator delegator, LocalDispatcher dispatcher) { - BigDecimal weight = product.getBigDecimal("weight"); + BigDecimal weight = product.getBigDecimal("productWeight"); String weightUomId = product.getString("weightUomId"); if (weight == null) { GenericValue parentProduct = getParentProduct(product.getString("productId"), delegator); if (parentProduct != null) { - weight = parentProduct.getBigDecimal("weight"); + weight = parentProduct.getBigDecimal("productWeight"); weightUomId = parentProduct.getString("weightUomId"); } } diff --git a/applications/product/src/org/ofbiz/shipment/shipment/ShipmentWorker.java b/applications/product/src/org/ofbiz/shipment/shipment/ShipmentWorker.java index 268f2ff33d..f22f88c4b9 100644 --- a/applications/product/src/org/ofbiz/shipment/shipment/ShipmentWorker.java +++ b/applications/product/src/org/ofbiz/shipment/shipment/ShipmentWorker.java @@ -168,7 +168,7 @@ public class ShipmentWorker { for (Map.Entry entry: packageMap.entrySet()) { String productId = entry.getKey(); Map productInfo = getProductItemInfo(shippableItemInfo, productId); - BigDecimal productWeight = (BigDecimal) productInfo.get("weight"); + BigDecimal productWeight = (BigDecimal) productInfo.get("productWeight"); BigDecimal quantity = packageMap.get(productId); String weightUomId = (String) productInfo.get("weightUomId"); diff --git a/applications/product/webapp/catalog/product/EditProductQuickAdmin.ftl b/applications/product/webapp/catalog/product/EditProductQuickAdmin.ftl index cd6e63a3c3..39ab8f8b7e 100644 --- a/applications/product/webapp/catalog/product/EditProductQuickAdmin.ftl +++ b/applications/product/webapp/catalog/product/EditProductQuickAdmin.ftl @@ -235,7 +235,7 @@ function doPublish() { - + @@ -261,7 +261,7 @@ function doPublish() { - + diff --git a/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy b/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy index aa1733525c..155d27fd1a 100644 --- a/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy +++ b/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy @@ -153,8 +153,8 @@ if (shipmentPlans) { if (shipmentPlan.getDouble("quantity")) { quantity = shipmentPlan.getDouble("quantity"); } - if (product.getDouble("weight")) { - weight = product.getDouble("weight") * quantity; + if (product.getDouble("productWeight")) { + weight = product.getDouble("productWeight") * quantity; } oneRow.weight = weight; if (product.weightUomId) { @@ -251,8 +251,8 @@ if (orderItemShipGroupAssocs) { // Planned (unitary) Weight and Volume weight = new Double(0); product = orderItem.getRelatedOne("Product", false); - if (product.getDouble("weight")) { - weight = product.getDouble("weight"); + if (product.getDouble("productWeight")) { + weight = product.getDouble("productWeight"); } oneRow.weight = weight; diff --git a/applications/product/widget/catalog/ProductForms.xml b/applications/product/widget/catalog/ProductForms.xml index bdc2ea1865..24d157542a 100644 --- a/applications/product/widget/catalog/ProductForms.xml +++ b/applications/product/widget/catalog/ProductForms.xml @@ -203,7 +203,7 @@ under the License. - + @@ -322,7 +322,7 @@ under the License. - + diff --git a/specialpurpose/ecommerce/data/DemoProduct.xml b/specialpurpose/ecommerce/data/DemoProduct.xml index a5d82c1de8..22d8157e4d 100644 --- a/specialpurpose/ecommerce/data/DemoProduct.xml +++ b/specialpurpose/ecommerce/data/DemoProduct.xml @@ -396,21 +396,21 @@ under the License. - + - + - - - - - - - + + + + + + + - + @@ -1523,14 +1523,14 @@ under the License. - - - - - - - - + + + + + + + + @@ -1621,8 +1621,8 @@ under the License. - - + + diff --git a/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl b/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl index ba5545f075..8fae559591 100644 --- a/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl +++ b/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl @@ -500,10 +500,10 @@ $(function(){ - <#if (product.weight?? && product.weight != 0) || product.weightUomId?has_content> + <#if (product.productWeight?? && product.productWeight != 0) || product.weightUomId?has_content> <#assign weightUom = product.getRelatedOne("WeightUom", true)! />
- ${uiLabelMap.CommonWeight}: ${product.weight!} ${((weightUom.abbreviation)?default(product.weightUomId))!} + ${uiLabelMap.CommonWeight}: ${product.productWeight!} ${((weightUom.abbreviation)?default(product.weightUomId))!}
<#if (product.productHeight?? && product.productHeight != 0) || product.heightUomId?has_content> diff --git a/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl b/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl index 03490cb025..4bff3c73c7 100644 --- a/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl +++ b/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl @@ -141,9 +141,9 @@ under the License. <#assign quantityUom = product.getRelatedOne("QuantityUom", true)!/> [${uiLabelMap.CommonQuantity}: ${product.quantityIncluded!} ${((quantityUom.abbreviation)?default(product.quantityUomId))!}] - <#if (product.weight?? && product.weight != 0) || product.weightUomId?has_content> + <#if (product.productWeight?? && product.productWeight != 0) || product.weightUomId?has_content> <#assign weightUom = product.getRelatedOne("WeightUom", true)!/> - [${uiLabelMap.CommonWeight}: ${product.weight!} ${((weightUom.abbreviation)?default(product.weightUomId))!}] + [${uiLabelMap.CommonWeight}: ${product.productWeight!} ${((weightUom.abbreviation)?default(product.weightUomId))!}] <#if (product.productHeight?? && product.productHeight != 0) || product.heightUomId?has_content> <#assign heightUom = product.getRelatedOne("HeightUom", true)!/> diff --git a/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java b/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java index 52bf82494a..6288fed65a 100644 --- a/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java +++ b/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java @@ -774,9 +774,9 @@ public class ProductsExportToGoogle { //Add Online Only UtilXml.addChildElementNSValue(entryElem, "g:online_only", "y", feedDocument, googleBaseNSUrl); //Add shipping weight - if (UtilValidate.isNotEmpty(product.getString("weight")) && UtilValidate.isNotEmpty(product.getString("weightUomId"))) { + if (UtilValidate.isNotEmpty(product.getBigDecimal("shippingWeight")) && UtilValidate.isNotEmpty(product.getString("weightUomId"))) { GenericValue uom = EntityQuery.use(delegator).from("Uom").where("uomId", product.getString("weightUomId")).queryOne(); - String shippingWeight = product.getString("weight") + " " + uom.getString("description"); + String shippingWeight = product.getBigDecimal("shippingWeight") + " " + uom.getString("description"); UtilXml.addChildElementNSValue(entryElem, "g:shipping_weight", shippingWeight, feedDocument, googleBaseNSUrl); } List productFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", product.getString("productId")).queryList(); diff --git a/specialpurpose/solr/src/org/ofbiz/solr/ProductUtil.java b/specialpurpose/solr/src/org/ofbiz/solr/ProductUtil.java index eeb220abd2..55014ba8fc 100644 --- a/specialpurpose/solr/src/org/ofbiz/solr/ProductUtil.java +++ b/specialpurpose/solr/src/org/ofbiz/solr/ProductUtil.java @@ -79,7 +79,7 @@ public abstract class ProductUtil { if (largeImage != null) dispatchContext.put("largeImage", largeImage); - // if(product.get("weight") != null) dispatchContext.put("weight", ""); + // if(product.get("productWeight") != null) dispatchContext.put("weight", ""); // Trying to set a correctand trail List category = delegator.findList("ProductCategoryMember", EntityCondition.makeCondition(UtilMisc.toMap("productId", productId)), null, null, null, false);