blob: 5686a8ebc555c4df6d9e2e381d8d2de3d47fc553 [file] [log] [blame]
Nabin Haitf7b26b32012-10-02 12:08:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from __future__ import unicode_literals
18def execute():
19 import webnotes
20 webnotes.conn.sql("""
21 delete from `tabDocPerm`
22 where
23 role in ('Sales User', 'Sales Manager', 'Sales Master Manager',
24 'Purchase User', 'Purchase Manager', 'Purchase Master Manager')
25 and parent = 'Sales and Purchase Return Tool'
26 """)
27
28 webnotes.conn.sql("""delete from `tabDocPerm` where ifnull(role, '') = ''""")
29
30 if not webnotes.conn.sql("""select name from `tabDocPerm` where parent = 'Leave Application'
31 and role = 'Employee' and permlevel = 1"""):
32 from webnotes.model.code import get_obj
33 from webnotes.model.doc import addchild
34 leave_app = get_obj('DocType', 'Leave Application', with_children=1)
35 ch = addchild(leave_app.doc, 'permissions', 'DocPerm')
36 ch.role = 'Employee'
37 ch.permlevel = 1
38 ch.read = 1
39 ch.save()