Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
Nabin Hait | f7b26b3 | 2012-10-02 12:08:32 +0530 | [diff] [blame] | 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | def execute(): |
| 6 | import webnotes |
| 7 | webnotes.conn.sql(""" |
| 8 | delete from `tabDocPerm` |
| 9 | where |
| 10 | role in ('Sales User', 'Sales Manager', 'Sales Master Manager', |
| 11 | 'Purchase User', 'Purchase Manager', 'Purchase Master Manager') |
| 12 | and parent = 'Sales and Purchase Return Tool' |
| 13 | """) |
| 14 | |
| 15 | webnotes.conn.sql("""delete from `tabDocPerm` where ifnull(role, '') = ''""") |
| 16 | |
| 17 | if not webnotes.conn.sql("""select name from `tabDocPerm` where parent = 'Leave Application' |
| 18 | and role = 'Employee' and permlevel = 1"""): |
| 19 | from webnotes.model.code import get_obj |
| 20 | from webnotes.model.doc import addchild |
| 21 | leave_app = get_obj('DocType', 'Leave Application', with_children=1) |
| 22 | ch = addchild(leave_app.doc, 'permissions', 'DocPerm') |
| 23 | ch.role = 'Employee' |
| 24 | ch.permlevel = 1 |
| 25 | ch.read = 1 |
| 26 | ch.save() |