mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 13:49:13 +00:00
Patch to migrate allow_print and allow_email to print and email rights of DocPerm
This commit is contained in:
@@ -33,10 +33,9 @@ def update_user_match():
|
|||||||
doctype_matches.setdefault(doctype, []).append(match)
|
doctype_matches.setdefault(doctype, []).append(match)
|
||||||
|
|
||||||
for doctype, user_matches in doctype_matches.items():
|
for doctype, user_matches in doctype_matches.items():
|
||||||
|
|
||||||
# get permissions of this doctype
|
# get permissions of this doctype
|
||||||
perms = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
|
perms = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
|
||||||
where parent=%s and permlevel=0 and read=1""", doctype, as_dict=True)
|
where parent=%s and permlevel=0 and `read`=1""", doctype, as_dict=True)
|
||||||
|
|
||||||
# for each user with roles of this doctype, check if match condition applies
|
# for each user with roles of this doctype, check if match condition applies
|
||||||
for profile in webnotes.conn.sql_list("""select name from `tabProfile`
|
for profile in webnotes.conn.sql_list("""select name from `tabProfile`
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ def execute():
|
|||||||
# reset Page perms
|
# reset Page perms
|
||||||
from core.page.permission_manager.permission_manager import reset
|
from core.page.permission_manager.permission_manager import reset
|
||||||
reset("Page")
|
reset("Page")
|
||||||
|
reset("Report")
|
||||||
|
|
||||||
# patch to move print, email into DocPerm
|
# patch to move print, email into DocPerm
|
||||||
|
for doctype, hide_print, hide_email in webnotes.conn.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0)
|
||||||
|
from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and
|
||||||
|
(ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""):
|
||||||
|
|
||||||
|
if not hide_print:
|
||||||
|
webnotes.conn.sql("""update `tabDocPerm` set `print`=1
|
||||||
|
where permlevel=0 and `read`=1 and parent=%s""", doctype)
|
||||||
|
|
||||||
|
if not hide_email:
|
||||||
|
webnotes.conn.sql("""update `tabDocPerm` set `email`=1
|
||||||
|
where permlevel=0 and `read`=1 and parent=%s""", doctype)
|
||||||
|
|||||||
Reference in New Issue
Block a user