From 98b7bd43a7f7612303f37e7935dba825352f0c79 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 6 Feb 2013 08:58:29 +0530 Subject: [PATCH] webnotes/client.py: added cancel method --- webnotes/client.py | 13 +++++++------ webnotes/utils/webclient.py | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/webnotes/client.py b/webnotes/client.py index 112a792244..c5306bc1fc 100644 --- a/webnotes/client.py +++ b/webnotes/client.py @@ -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""" diff --git a/webnotes/utils/webclient.py b/webnotes/utils/webclient.py index 235cbb7f14..3ed809e46c 100644 --- a/webnotes/utils/webclient.py +++ b/webnotes/utils/webclient.py @@ -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",