From 83190804977506088e165a438c790cd5037f9af9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 31 Jul 2013 16:08:50 +0530 Subject: [PATCH] [fix] [minor] [bug] int docstatus before to_docstatus check --- webnotes/model/bean.py | 5 +++-- webnotes/model/create_new.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/webnotes/model/bean.py b/webnotes/model/bean.py index dcfbf3a6ff..29c0629eab 100644 --- a/webnotes/model/bean.py +++ b/webnotes/model/bean.py @@ -35,6 +35,7 @@ from webnotes.model.doc import Document class DocstatusTransitionError(webnotes.ValidationError): pass class BeanPermissionError(webnotes.ValidationError): pass +class TimestampMismatchError(webnotes.ValidationError): pass class Bean: """ @@ -148,7 +149,7 @@ class Bean: if conflict: webnotes.msgprint(_("Error: Document has been modified after you have opened it") \ + (" (%s, %s). " % (modified, self.doc.modified)) \ - + _("Please refresh to get the latest document."), raise_exception=True) + + _("Please refresh to get the latest document."), raise_exception=TimestampMismatchError) def check_docstatus_transition(self, db_docstatus, method): valid = { @@ -199,7 +200,7 @@ class Bean: d.modified_by = user d.modified = ts - if d.docstatus != 2 and self.to_docstatus >= d.docstatus: # don't update deleted + if d.docstatus != 2 and self.to_docstatus >= int(d.docstatus): # don't update deleted d.docstatus = self.to_docstatus def prepare_for_save(self, method): diff --git a/webnotes/model/create_new.py b/webnotes/model/create_new.py index 0d4a431f3e..d1857f451a 100644 --- a/webnotes/model/create_new.py +++ b/webnotes/model/create_new.py @@ -11,7 +11,8 @@ def get_new_doc(doctype, parent_doc = None, parentfield = None): doc = webnotes.doc({ "doctype": doctype, "__islocal": 1, - "owner": webnotes.session.user + "owner": webnotes.session.user, + "docstatus": 0 }) meta = webnotes.get_doctype(doctype)