def update_comment_in_doc(self): if self.doc.comment_doctype and self.doc.comment_docname and self.doc.comment: try: _comments = self.get_comments_from_parent() updated = False for c in _comments: if c.get("name") == self.doc.name: c["comment"] = self.doc.comment updated = True if not updated: _comments.append({ "comment": self.doc.comment, "by": self.doc.comment_by or self.doc.owner, "name": self.doc.name }) self.update_comments_in_parent(_comments) except Exception, e: if e.args[0] == 1054: from webnotes.model.db_schema import add_column add_column(self.doc.comment_doctype, "_comments", "Text") self.update_comment_in_doc() elif e.args[0] == 1146: # no table pass else: raise
def update_comment_in_doc(self): if self.doc.comment_doctype and self.doc.comment_docname and self.doc.comment: try: _comments = self.get_comments_from_parent() updated = False for c in _comments: if c.get("name")==self.doc.name: c["comment"] = self.doc.comment updated = True if not updated: _comments.append({ "comment": self.doc.comment, "by": self.doc.comment_by or self.doc.owner, "name":self.doc.name }) self.update_comments_in_parent(_comments) except Exception, e: if e.args[0]==1054: from webnotes.model.db_schema import add_column add_column(self.doc.comment_doctype, "_comments", "Text") self.update_comment_in_doc() elif e.args[0]==1146: # no table pass else: raise
def setup(self): """adds the _user_tags column if not exists""" from webnotes.model.db_schema import add_column add_column(self.dt, "_user_tags", "Data")