[ofbiz-framework] branch trunk updated: Improved: Improvement on Find BOM screen (OFBIZ-12179)

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

[ofbiz-framework] branch trunk updated: Improved: Improvement on Find BOM screen (OFBIZ-12179)

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e259170  Improved: Improvement on Find BOM screen (OFBIZ-12179)
e259170 is described below

commit e259170b77f73e8320b8ab7e23b158dab48a2dc9
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Thu Feb 18 11:56:43 2021 +0100

    Improved: Improvement on Find BOM screen (OFBIZ-12179)
   
    While exploring the manufacturing code I observed on the find screen BOM type is
    set hardcoded. We can improve it by using the entity-option tag to allow all
    ProductAssocType with parentTypeId equals "PRODUCT_COMPONENT".
   
    Thanks: Nameet Jain
---
 applications/manufacturing/groovyScripts/bom/FindProductBom.groovy | 6 +++---
 applications/manufacturing/widget/manufacturing/BomForms.xml       | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy b/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy
index 9d5f5a4..9cfd85d 100644
--- a/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy
+++ b/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+import org.apache.ofbiz.entity.util.EntityUtil
 import org.apache.ofbiz.entity.condition.EntityCondition
 import org.apache.ofbiz.entity.condition.EntityOperator
 
@@ -33,9 +34,8 @@ if (parameters.productAssocTypeId) {
     cond = EntityCondition.makeCondition("productAssocTypeId", EntityOperator.EQUALS, parameters.productAssocTypeId)
     condList.add(cond)
 } else {
-    cond = EntityCondition.makeCondition([EntityCondition.makeCondition("productAssocTypeId", EntityOperator.EQUALS, "ENGINEER_COMPONENT"),
-                                          EntityCondition.makeCondition("productAssocTypeId", EntityOperator.EQUALS, "MANUF_COMPONENT")
-                                          ], EntityOperator.OR)
+    bomAssocTypeIds = EntityUtil.getFieldListFromEntityList(select("productAssocTypeId").from("ProductAssocType").where("parentTypeId", "PRODUCT_COMPONENT").queryList(), "productAssocTypeId", true)
+    cond = EntityCondition.makeCondition("productAssocTypeId", EntityOperator.IN, bomAssocTypeIds)
     condList.add(cond)
 }
 bomListIterator = select("productId", "internalName", "productAssocTypeId")
diff --git a/applications/manufacturing/widget/manufacturing/BomForms.xml b/applications/manufacturing/widget/manufacturing/BomForms.xml
index 7dbe74e..777a87e 100644
--- a/applications/manufacturing/widget/manufacturing/BomForms.xml
+++ b/applications/manufacturing/widget/manufacturing/BomForms.xml
@@ -136,8 +136,9 @@ under the License.
         <field name="productIdTo" title="${uiLabelMap.ProductProductIdTo}"><lookup target-form-name="LookupProduct"/></field>
         <field name="productAssocTypeId"  title="${uiLabelMap.ManufacturingBomType}">
             <drop-down allow-empty="true">
-                <option key="MANUF_COMPONENT" description="${uiLabelMap.ManufacturingBillOfMaterials}"/>
-                <option key="ENGINEER_COMPONENT" description="${uiLabelMap.ManufacturingEngineeringBillOfMaterials}"/>
+                <entity-options entity-name="ProductAssocType" description="${description}">
+                    <entity-constraint name="parentTypeId" operator="equals" value="PRODUCT_COMPONENT"/>
+                </entity-options>
             </drop-down>
         </field>
         <field name="noConditionFind"><hidden value="Y"/><!-- if this isn't there then with all fields empty no query will be done --></field>