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 |
| 3 | |
Anand Doshi | 3245a15 | 2012-10-01 11:35:49 +0530 | [diff] [blame] | 4 | from __future__ import unicode_literals |
Anand Doshi | 5f76ceb | 2012-09-24 15:41:41 +0530 | [diff] [blame] | 5 | import webnotes |
| 6 | from webnotes.model.code import get_obj |
| 7 | from webnotes.model.doc import addchild |
| 8 | |
| 9 | def execute(): |
| 10 | existing = webnotes.conn.sql("""select name from `tabDocPerm` |
| 11 | where permlevel=0 and parent='Event' and role='System Manager' |
| 12 | and cancel=1""") |
| 13 | if not existing: |
| 14 | ev_obj = get_obj("DocType", "Event", with_children=1) |
| 15 | ch = addchild(ev_obj.doc, "permissions", "DocPerm") |
| 16 | ch.permlevel = 0 |
| 17 | ch.role = 'System Manager' |
| 18 | ch.read = ch.write = ch.create = ch.cancel = 1 |
| 19 | ch.save() |