Example #1
0
    def check_if_latest(self, method="save"):
        from webnotes.model.meta import is_single

        conflict = False
        if not cint(self.doc.fields.get('__islocal')):
            if is_single(self.doc.doctype):
                modified = webnotes.conn.get_value(self.doc.doctype,
                                                   self.doc.name, "modified")
                if isinstance(modified, list):
                    modified = modified[0]
                if cstr(modified) and cstr(modified) != cstr(
                        self.doc.modified):
                    conflict = True
            else:
                tmp = webnotes.conn.sql(
                    """select modified, docstatus from `tab%s` 
					where name="%s" for update""" % (self.doc.doctype, self.doc.name),
                    as_dict=True)

                if not tmp:
                    webnotes.msgprint(
                        """This record does not exist. Please refresh.""",
                        raise_exception=1)

                modified = cstr(tmp[0].modified)
                if modified and modified != cstr(self.doc.modified):
                    conflict = True

                self.check_docstatus_transition(tmp[0].docstatus, method)

            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)
Example #2
0
	def check_if_latest(self, method="save"):
		from webnotes.model.meta import is_single

		conflict = False
		if not cint(self.doc.fields.get('__islocal')):
			if is_single(self.doc.doctype):
				modified = webnotes.conn.get_value(self.doc.doctype, self.doc.name, "modified")
				if isinstance(modified, list):
					modified = modified[0]
				if cstr(modified) and cstr(modified) != cstr(self.doc.modified):
					conflict = True
			else:
				tmp = webnotes.conn.sql("""select modified, docstatus from `tab%s` 
					where name="%s" for update"""
					% (self.doc.doctype, self.doc.name), as_dict=True)

				if not tmp:
					webnotes.msgprint("""This record does not exist. Please refresh.""", raise_exception=1)

				modified = cstr(tmp[0].modified)
				if modified and modified != cstr(self.doc.modified):
					conflict = True
			
				self.check_docstatus_transition(tmp[0].docstatus, method)
				
			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=TimestampMismatchError)
Example #3
0
	def check_if_latest(self):
		"""
			Raises exception if the modified time is not the same as in the database
		"""
		from webnotes.model.meta import is_single

		if (not is_single(self.doc.doctype)) and (not self.doc.fields.get('__islocal')):
			tmp = webnotes.conn.sql("""
				SELECT modified FROM `tab%s` WHERE name="%s" for update""" 
				% (self.doc.doctype, self.doc.name))

			if tmp and str(tmp[0][0]) != str(self.doc.modified):
				webnotes.msgprint("""
				Document has been modified after you have opened it. 
				To maintain the integrity of the data, you will not be able to save your changes. 
				Please refresh this document. [%s/%s]""" % (tmp[0][0], self.doc.modified), raise_exception=1)
Example #4
0
    def check_if_latest(self):
        """
			Raises exception if the modified time is not the same as in the database
		"""
        from webnotes.model.meta import is_single

        if (not is_single(self.doc.doctype)) and (not cint(
                self.doc.fields.get('__islocal'))):
            tmp = webnotes.conn.sql("""
				SELECT modified FROM `tab%s` WHERE name="%s" for update""" %
                                    (self.doc.doctype, self.doc.name))

            if tmp and str(tmp[0][0]) != str(self.doc.modified):
                webnotes.msgprint("""
				Document has been modified after you have opened it.
				To maintain the integrity of the data, you will not be able to save your changes.
				Please refresh this document. [%s/%s]""" % (tmp[0][0], self.doc.modified),
                                  raise_exception=1)