changed doctype name userrole to has role
This commit is contained in:
parent
d59f8b32cd
commit
312498060f
@ -17,7 +17,7 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
||||
def get_approver_list(name):
|
||||
return frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
tabUser user, tabUserRole user_role where
|
||||
tabUser user, `tabHas Role` user_role where
|
||||
user_role.role = "Leave Approver"
|
||||
and user_role.parent = user.name and
|
||||
user.name != %s
|
||||
|
@ -194,7 +194,7 @@ def update_reimbursed_amount(doc):
|
||||
def get_expense_approver(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.db.sql("""
|
||||
select u.name, concat(u.first_name, ' ', u.last_name)
|
||||
from tabUser u, tabUserRole r
|
||||
from tabUser u, `tabHas Role` r
|
||||
where u.name = r.parent and r.role = 'Expense Approver'
|
||||
and u.enabled = 1 and u.name like %s
|
||||
""", ("%" + txt + "%"))
|
||||
|
@ -215,7 +215,7 @@ class LeaveApplication(Document):
|
||||
frappe.throw(_("Leave approver must be one of {0}")
|
||||
.format(comma_or(leave_approvers)), InvalidLeaveApproverError)
|
||||
|
||||
elif self.leave_approver and not frappe.db.sql("""select name from `tabUserRole`
|
||||
elif self.leave_approver and not frappe.db.sql("""select name from `tabHas Role`
|
||||
where parent=%s and role='Leave Approver'""", self.leave_approver):
|
||||
frappe.throw(_("{0} ({1}) must have role 'Leave Approver'")\
|
||||
.format(get_fullname(self.leave_approver), self.leave_approver), InvalidLeaveApproverError)
|
||||
|
@ -53,7 +53,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
frappe.db.sql("""delete from `tabEmployee Leave Approver`""")
|
||||
|
||||
def _clear_roles(self):
|
||||
frappe.db.sql("""delete from `tabUserRole` where parent in
|
||||
frappe.db.sql("""delete from `tabHas Role` where parent in
|
||||
("test@example.com", "test1@example.com", "test2@example.com")""")
|
||||
|
||||
def _clear_applications(self):
|
||||
|
@ -176,7 +176,7 @@ class TestSalarySlip(unittest.TestCase):
|
||||
"email": user,
|
||||
"first_name": user,
|
||||
"new_password": "password",
|
||||
"roles": [{"doctype": "UserRole", "role": "Employee"}]
|
||||
"roles": [{"doctype": "Has Role", "role": "Employee"}]
|
||||
}).insert()
|
||||
|
||||
if not frappe.db.get_value("Employee", {"user_id": user}):
|
||||
|
@ -52,7 +52,7 @@ def make_employee(user):
|
||||
"email": user,
|
||||
"first_name": user,
|
||||
"new_password": "password",
|
||||
"roles": [{"doctype": "UserRole", "role": "Employee"}]
|
||||
"roles": [{"doctype": "Has Role", "role": "Employee"}]
|
||||
}).insert()
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ import frappe
|
||||
import frappe.permissions
|
||||
|
||||
def execute():
|
||||
for user in frappe.db.sql_list("select distinct parent from `tabUserRole` where role='Employee'"):
|
||||
for user in frappe.db.sql_list("select distinct parent from `tabHas Role` where role='Employee'"):
|
||||
# if employee record does not exists, remove employee role!
|
||||
if not frappe.db.get_value("Employee", {"user_id": user}):
|
||||
try:
|
||||
|
@ -19,11 +19,11 @@ def execute():
|
||||
if not frappe.db.exists("Role", "Newsletter Manager"):
|
||||
frappe.get_doc({"doctype": "Role", "role": "Newsletter Manager"}).insert()
|
||||
|
||||
for userrole in frappe.get_all("UserRole", "parent", {"role": "Sales Manager"}):
|
||||
for userrole in frappe.get_all("Has Role", "parent", {"role": "Sales Manager", "parenttype": "User"}):
|
||||
if frappe.db.exists("User", userrole.parent):
|
||||
user = frappe.get_doc("User", userrole.parent)
|
||||
user.append("roles", {
|
||||
"doctype": "UserRole",
|
||||
"doctype": "Has Role",
|
||||
"role": "Newsletter Manager"
|
||||
})
|
||||
user.flags.ignore_mandatory = True
|
||||
|
@ -8,10 +8,10 @@ def execute():
|
||||
frappe.reload_doc("projects", "doctype", "timesheet")
|
||||
|
||||
for role in ('Customer', 'Supplier'):
|
||||
frappe.db.sql('''delete from `tabUserRole`
|
||||
frappe.db.sql('''delete from `tabHas Role`
|
||||
where role=%s and parent in ("Administrator", "Guest")''', role)
|
||||
|
||||
if not frappe.db.sql('select name from `tabUserRole` where role=%s', role):
|
||||
if not frappe.db.sql('select name from `tabHas Role` where role=%s', role):
|
||||
|
||||
# delete DocPerm
|
||||
for doctype in frappe.db.sql('select parent from tabDocPerm where role=%s', role):
|
||||
|
@ -213,7 +213,7 @@ class AuthorizationControl(TransactionBase):
|
||||
app_specific_user.append(m['approving_user'])
|
||||
elif m['approving_role']:
|
||||
user_lst = [z[0] for z in frappe.db.sql("""select distinct t1.name
|
||||
from `tabUser` t1, `tabUserRole` t2 where t2.role=%s
|
||||
from `tabUser` t1, `tabHas Role` t2 where t2.role=%s
|
||||
and t2.parent=t1.name and t1.name !='Administrator'
|
||||
and t1.name != 'Guest' and t1.docstatus !=2""", m['approving_role'])]
|
||||
|
||||
|
@ -96,7 +96,7 @@ def setup_properties(data):
|
||||
def setup_roles(data):
|
||||
'''Add, remove roles from `data.allow_roles` or `data.remove_roles`'''
|
||||
def remove_role(role):
|
||||
frappe.db.sql('delete from tabUserRole where role=%s', role)
|
||||
frappe.db.sql('delete from `tabHas Role` where role=%s', role)
|
||||
frappe.set_value('Role', role, 'disabled', 1)
|
||||
|
||||
if data.remove_roles:
|
||||
|
@ -164,7 +164,7 @@ def send_email_notification(mr_list):
|
||||
""" Notify user about auto creation of indent"""
|
||||
|
||||
email_list = frappe.db.sql_list("""select distinct r.parent
|
||||
from tabUserRole r, tabUser p
|
||||
from `tabHas Role` r, tabUser p
|
||||
where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
|
||||
and r.role in ('Purchase Manager','Stock Manager')
|
||||
and p.name not in ('Administrator', 'All', 'Guest')""")
|
||||
|
@ -35,9 +35,6 @@ class TransactionBase(StatusUpdater):
|
||||
frappe.db.sql("delete from `tabEvent` where name in (%s)"
|
||||
.format(", ".join(['%s']*len(events))), tuple(events))
|
||||
|
||||
frappe.db.sql("delete from `tabEvent Role` where parent in (%s)"
|
||||
.format(", ".join(['%s']*len(events))), tuple(events))
|
||||
|
||||
def _add_calendar_event(self, opts):
|
||||
opts = frappe._dict(opts)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user