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 5f11ebad2d Fixed: Accounting Invoice Overview - PDF failed 
(OFBIZ-12735)
5f11ebad2d is described below

commit 5f11ebad2d097d49d972b4a02bfa33380e6fb951
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Thu Jan 12 11:52:52 2023 +0100

    Fixed: Accounting Invoice Overview - PDF failed (OFBIZ-12735)
    
    >hen clicking “PDF” button in the invoice view, it failed with a 
StackOverflow
    
    A quick fix in DocTypeTemplate.groovy:
    in def getCustomScreenTemplate()
    Change:
    parentTypeValue = 
from(entityTypeName).where().cache().queryFirst().parentTypeId
    To:
    String parentTypeValue =
    from(entityTypeName)
    .where("invoiceTypeId", fieldTypeValue)
    .cache()
    .queryFirst()
    .parentTypeId
    
    jleroux: I noticed this Ingo's not applied patch at OFBIZ-10215:
    
https://issues.apache.org/jira/secure/attachment/13045313/DocTypeTemplate-1.patch
    It's very similar to Yannong's but a bit more general. We don't need to 
worry
    about the 3 types (invoice, order, quote). It's already handled.
    
    I also formatted getCustomScreenTemplate()
    
    Thanks: Yannong Huang for report a proposition fic
---
 .../groovyScripts/template/DocTypeTemplate.groovy  | 33 +++++++++++++---------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git 
a/applications/commonext/groovyScripts/template/DocTypeTemplate.groovy 
b/applications/commonext/groovyScripts/template/DocTypeTemplate.groovy
index 1c5986392d..a2234dfc56 100644
--- a/applications/commonext/groovyScripts/template/DocTypeTemplate.groovy
+++ b/applications/commonext/groovyScripts/template/DocTypeTemplate.groovy
@@ -30,19 +30,26 @@ def getFieldTypeName(String entityName) {
  * If no value found, do a recursive search on parentType
  */
 def getCustomScreenTemplate(String entityTypeName, String fieldTypeValue) {
-    if (! fieldTypeValue) {
-        return null
-    }
-    GenericValue tplCustScreen = from("PartyPrefDocTypeTplAndCustomScreen")
-            .where(getFieldTypeName(entityTypeName), fieldTypeValue)
-            .cache()
-            .queryFirst()
-    if (tplCustScreen) {
-        return tplCustScreen
-    }
-    // No template found for this type, try if the parent had
-    String parentTypeValue = 
from(entityTypeName).where().cache().queryFirst().parentTypeId
-    return getCustomScreenTemplate(entityTypeName, parentTypeValue)
+  if (!fieldTypeValue) {
+    return null
+  }
+
+  GenericValue tplCustScreen = from("PartyPrefDocTypeTplAndCustomScreen")
+      .where(getFieldTypeName(entityTypeName), fieldTypeValue)
+      .cache()
+      .queryFirst()
+
+  if (tplCustScreen) {
+    return tplCustScreen
+  }
+
+  // No template found for this type, try if the parent had
+  String parentTypeValue = from(entityTypeName)
+      .where(getFieldTypeName(entityTypeName), fieldTypeValue)
+      .cache()
+      .queryFirst()
+      .parentTypeId
+  return getCustomScreenTemplate(entityTypeName, parentTypeValue)
 }
 
 // first resolve the document reference passed on the context

Reply via email to