[minor] check create permission separately
This commit is contained in:
parent
f808bf4b42
commit
f8f39958d8
2 changed files with 9 additions and 4 deletions
|
|
@ -278,7 +278,7 @@ def has_permission(doctype, ptype="read", refdoc=None):
|
|||
and ifnull(p.permlevel,0) = 0
|
||||
and (p.role="All" or p.role in (select `role` from tabUserRole where `parent`=%s))
|
||||
""" % ("%s", ptype, "%s"), (doctype, session.user), as_dict=1)
|
||||
|
||||
|
||||
if refdoc:
|
||||
match_failed = {}
|
||||
for p in perms:
|
||||
|
|
|
|||
|
|
@ -313,8 +313,13 @@ class Bean:
|
|||
return webnotes.has_permission(self.doc.doctype, "read", self.doc)
|
||||
|
||||
def save(self, check_links=1):
|
||||
perm = "create" if self.doc.fields.get("__islocal") else "write"
|
||||
if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, perm, self.doc):
|
||||
perm_to_check = "write"
|
||||
if self.doc.fields.get("__islocal"):
|
||||
perm_to_check = "create"
|
||||
if not self.doc.owner:
|
||||
self.doc.owner = webnotes.session.user
|
||||
|
||||
if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, perm_to_check, self.doc):
|
||||
self.to_docstatus = 0
|
||||
self.prepare_for_save("save")
|
||||
if not self.ignore_validate:
|
||||
|
|
@ -325,7 +330,7 @@ class Bean:
|
|||
self.save_children()
|
||||
self.run_method('on_update')
|
||||
else:
|
||||
self.no_permission_to(_(perm.title()))
|
||||
self.no_permission_to(_(perm_to_check.title()))
|
||||
|
||||
return self
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue