This is an automated email from the ASF dual-hosted git repository.
arunpati 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 afe3b95b6d Fixed: PDF print and create file actions failing from Find
Orders (OF… (#2024)
afe3b95b6d is described below
commit afe3b95b6d517594ac07ed021aa3782129f123db
Author: Arun Patidar <[email protected]>
AuthorDate: Wed Sep 16 14:52:59 2026 +0530
Fixed: PDF print and create file actions failing from Find Orders (OF…
(#2024)
Fixed: PDF print and create file actions failing from Find Orders
(OFBIZ-13505)
Thanks for the report, Carsten Heinrigs
The OrderPDF screen is rendered by the async services
sendPrintFromScreen and createFileFromScreen, which have no web context.
Fixes:
- OrderViewWebSecure.groovy: use the userLogin based Security overload
instead of the session one, and build the OrderContentWrapper with the
dispatcher based constructor when no request is available. This removes
the MissingPropertyException reported in the issue.
- OutputServices.java: pass userLogin into the screen render context so
permission checks work, fixing the FOP "Document is empty" error, and
default the print DocFlavor to AUTOSENSE since the FO transformation
always produces PDF, not PostScript.
- FindOrders.ftl: use an empty value for the placeholder printer option
so the default printer is used instead of a printer named
"javascript:void(0);".
---
.../java/org/apache/ofbiz/content/output/OutputServices.java | 5 ++++-
.../org/apache/ofbiz/order/order/OrderViewWebSecure.groovy | 9 +++++----
applications/order/template/order/FindOrders.ftl | 2 +-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git
a/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java
b/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java
index 202ec736e1..62ce72e555 100644
---
a/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java
+++
b/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java
@@ -102,11 +102,13 @@ public class OutputServices {
screenContext = new HashMap<>();
}
screenContext.put("locale", locale);
+ screenContext.putIfAbsent("userLogin",
serviceContext.get("userLogin"));
if (UtilValidate.isEmpty(contentType)) {
contentType = "application/postscript";
}
if (UtilValidate.isEmpty(printerContentType)) {
- printerContentType = contentType;
+ // the FO transformation below always produces PDF, so let the
print service autosense the format
+ printerContentType =
DocFlavor.INPUT_STREAM.AUTOSENSE.getMimeType();
}
try {
@@ -224,6 +226,7 @@ public class OutputServices {
screenContext = new HashMap<>();
}
screenContext.put("locale", locale);
+ screenContext.putIfAbsent("userLogin",
serviceContext.get("userLogin"));
if (UtilValidate.isEmpty(contentType)) {
contentType = "application/pdf";
}
diff --git
a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderViewWebSecure.groovy
b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderViewWebSecure.groovy
index bce8b3bc0e..181664112a 100644
---
a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderViewWebSecure.groovy
+++
b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderViewWebSecure.groovy
@@ -29,11 +29,11 @@ if (orderHeader) {
// hasPermission if: has ORDERMGR_VIEW, ORDERMGR_ROLE_VIEW & associated
with order, or is associated in the SUPPLIER_AGENT role
hasPermission = false
canViewInternalDetails = false
- if ((orderHeader.orderTypeId == 'SALES_ORDER' &&
security.hasEntityPermission('ORDERMGR', '_VIEW', session))
- || (orderHeader.orderTypeId == 'PURCHASE_ORDER' &&
security.hasEntityPermission('ORDERMGR', '_PURCHASE_VIEW', session))) {
+ if ((orderHeader.orderTypeId == 'SALES_ORDER' &&
security.hasEntityPermission('ORDERMGR', '_VIEW', userLogin))
+ || (orderHeader.orderTypeId == 'PURCHASE_ORDER' &&
security.hasEntityPermission('ORDERMGR', '_PURCHASE_VIEW', userLogin))) {
hasPermission = true
canViewInternalDetails = true
- } else if (security.hasEntityPermission('ORDERMGR_ROLE', '_VIEW',
session)) {
+ } else if (security.hasEntityPermission('ORDERMGR_ROLE', '_VIEW',
userLogin)) {
currentUserOrderRoles = orderHeader.getRelated('OrderRole', [partyId:
userLogin.partyId], null, false)
if (currentUserOrderRoles) {
hasPermission = true
@@ -66,6 +66,7 @@ if (orderHeader) {
context.hasPermission = hasPermission
context.canViewInternalDetails = canViewInternalDetails
- orderContentWrapper =
OrderContentWrapper.makeOrderContentWrapper(orderHeader, request)
+ orderContentWrapper = context.request ?
OrderContentWrapper.makeOrderContentWrapper(orderHeader, request)
+ : new OrderContentWrapper(dispatcher, orderHeader, locale,
'text/html')
context.orderContentWrapper = orderContentWrapper
}
diff --git a/applications/order/template/order/FindOrders.ftl
b/applications/order/template/order/FindOrders.ftl
index a19673223f..7380d190eb 100644
--- a/applications/order/template/order/FindOrders.ftl
+++ b/applications/order/template/order/FindOrders.ftl
@@ -473,7 +473,7 @@ document.lookuporder.orderId.focus();
</select>
<#if printers?has_content>
<select name="printerName">
- <option
value="javascript:void(0);">${uiLabelMap.CommonPleaseSelectPrinter}</option>
+ <option value="">${uiLabelMap.CommonPleaseSelectPrinter}</option>
<#list printers as printer>
<option value="${printer}">${printer}</option>
</#list>