feat: Convenience APIs for tags (#11088)
Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
This commit is contained in:
parent
cc22350b04
commit
5d4feb5dbb
1 changed files with 10 additions and 0 deletions
|
|
@ -1307,6 +1307,16 @@ class Document(BaseDocument):
|
|||
users = set([assignment.owner for assignment in assignments])
|
||||
return users
|
||||
|
||||
def add_tag(self, tag):
|
||||
"""Add a Tag to this document"""
|
||||
from frappe.desk.doctype.tag.tag import DocTags
|
||||
DocTags(self.doctype).add(self.name, tag)
|
||||
|
||||
def get_tags(self):
|
||||
"""Return a list of Tags attached to this document"""
|
||||
from frappe.desk.doctype.tag.tag import DocTags
|
||||
return DocTags(self.doctype).get_tags(self.name).split(",")[1:]
|
||||
|
||||
def execute_action(doctype, name, action, **kwargs):
|
||||
"""Execute an action on a document (called by background worker)"""
|
||||
doc = frappe.get_doc(doctype, name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue