blob: 9dffdd4dfa109a6e7757a9611be7c94701ac6da6 [file] [log] [blame]
Anand Doshi620145c2013-12-16 19:28:11 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import webnotes
6
7def execute():
Anand Doshi620145c2013-12-16 19:28:11 +05308 # reset Page perms
Anand Doshi8e332ff2013-12-26 18:30:39 +05309 from webnotes.core.page.permission_manager.permission_manager import reset
Anand Doshi2298d592013-12-17 19:04:08 +053010 reset("Page")
Anand Doshi9b67f432013-12-20 19:33:11 +053011 reset("Report")
Anand Doshi2298d592013-12-17 19:04:08 +053012
13 # patch to move print, email into DocPerm
Anand Doshi9b67f432013-12-20 19:33:11 +053014 for doctype, hide_print, hide_email in webnotes.conn.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0)
15 from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and
16 (ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""):
17
18 if not hide_print:
19 webnotes.conn.sql("""update `tabDocPerm` set `print`=1
20 where permlevel=0 and `read`=1 and parent=%s""", doctype)
21
22 if not hide_email:
23 webnotes.conn.sql("""update `tabDocPerm` set `email`=1
24 where permlevel=0 and `read`=1 and parent=%s""", doctype)