diff --git a/frappe/__init__.py b/frappe/__init__.py index d416ee7b3e..b2f8a1b614 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -426,11 +426,19 @@ def has_website_permission(doctype, ptype="read", doc=None, user=None, verbose=F if not user: user = session.user - for method in (get_hooks("has_website_permission") or {}).get(doctype, []): - if not call(get_attr(method), doc=doc, ptype=ptype, user=user, verbose=verbose): - return False + hooks = (get_hooks("has_website_permission") or {}).get(doctype, []) + if hooks: + for method in hooks: + result = call(get_attr(method), doc=doc, ptype=ptype, user=user, verbose=verbose) + # if even a single permission check is Falsy + if not result: + return False - return True + # else it is Truthy + return True + + else: + return False def is_table(doctype): """Returns True if `istable` property (indicating child Table) is set for given DocType.""" diff --git a/frappe/templates/pages/print.py b/frappe/templates/pages/print.py index 57d06ef1d9..a2ef5b6f44 100644 --- a/frappe/templates/pages/print.py +++ b/frappe/templates/pages/print.py @@ -121,7 +121,8 @@ def validate_print_permission(doc): return for ptype in ("read", "print"): - if not frappe.has_permission(doc.doctype, ptype, doc): + if (not frappe.has_permission(doc.doctype, ptype, doc) + and not frappe.has_website_permission(doc.doctype, ptype, doc)): raise frappe.PermissionError(_("No {0} permission").format(ptype)) def get_letter_head(doc, no_letterhead):