Browse Source

webnotes/client.py: added cancel method

version-14
Rushabh Mehta 12 years ago
parent
commit
98b7bd43a7
2 changed files with 22 additions and 7 deletions
  1. +7
    -6
      webnotes/client.py
  2. +15
    -1
      webnotes/utils/webclient.py

+ 7
- 6
webnotes/client.py View File

@@ -44,9 +44,6 @@ def insert(doclist):
def save(doclist):
if isinstance(doclist, basestring):
doclist = json.loads(doclist)
if not webnotes.has_permission(doclist[0]["doctype"], "write"):
webnotes.msgprint("No Write Permission", raise_exception=True)

doclistobj = webnotes.model_wrapper(doclist)
doclistobj.save()
@@ -57,15 +54,19 @@ def save(doclist):
def submit(doclist):
if isinstance(doclist, basestring):
doclist = json.loads(doclist)
if not webnotes.has_permission(doclist[0]["doctype"], "submit"):
webnotes.msgprint("No Submit Permission", raise_exception=True)

doclistobj = webnotes.model_wrapper(doclist)
doclistobj.submit()
return [d.fields for d in doclist]

@webnotes.whitelist()
def cancel(doctype, name):
wrapper = webnotes.model_wrapper(doctype, name)
wrapper.cancel()
return [d.fields for d in wrapper.doclist]

@webnotes.whitelist()
def set_default(key, value, parent=None):
"""set a user default value"""


+ 15
- 1
webnotes/utils/webclient.py View File

@@ -50,7 +50,7 @@ def update(doclist):
"cmd": "webnotes.client.save",
"doclist": json.dumps(doclist)
})
def delete(doctype, name):
return post_request({
"cmd": "webnotes.model.delete_doc",
@@ -58,6 +58,20 @@ def delete(doctype, name):
"name": name
})
def submit(doclist):
return post_request({
"cmd": "webnotes.client.submit",
"doclist": json.dumps(doclist)
})


def cancel(doctype, name):
return post_request({
"cmd": "webnotes.client.cancel",
"doctype": doctype,
"name": name
})
def get_doc(doctype, name=None, filters=None):
params = {
"cmd": "webnotes.client.get",


Loading…
Cancel
Save