From d254933a7cd202790d26b2271c79962136cfc0d6 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 24 Oct 2020 14:12:59 +0530 Subject: [PATCH] fix: Build cookie jar only if request object is present --- frappe/utils/pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/pdf.py b/frappe/utils/pdf.py index 49a8a0d37a..aabe033e26 100644 --- a/frappe/utils/pdf.py +++ b/frappe/utils/pdf.py @@ -124,7 +124,7 @@ def prepare_options(html, options): def get_cookie_options(): options = {} - if frappe.session and frappe.session.sid: + if frappe.session and frappe.session.sid and hasattr(frappe.local, "request"): # Use wkhtmltopdf's cookie-jar feature to set cookies and restrict them to host domain cookiejar = "/tmp/{}.jar".format(frappe.generate_hash())