ccfiel
December 3, 2015, 12:56pm
1
Example if I have inserted a new journal entry code below.
jv = frappe.get_doc({
"doctype": "Journal Entry",
"posting_date": "2015-01-01",
"accounts": [{
"account": ...
}],
...
})
jv.insert()
How can I add programmatically a tag to this?
rmehta
December 4, 2015, 10:41am
2
1 Like
ccfiel
December 4, 2015, 1:21pm
3
@rmehta I am a little lost how to use this one
jv = frappe.get_doc({
"doctype": "Journal Entry",
"posting_date": "2015-01-01",
"accounts": [{
"account": ...
}],
...
})
jv.insert()
frappe.desk.tags.add(jv, "test")
Adding frappe.desk.tags.add(jv, “test”) got an error 'module' object has no attribute 'tags'
. What is the right way to add tags in a document? Sorry for being so noobs for this one.
@ccfiel do you need import tags at the head!
from frappe.desk import tags
....
tags.add(jv, 'test')
ccfiel
December 4, 2015, 11:49pm
5
@max_morais_dmm @rmehta I got how to use it! DocTags("Journal Entry").add(journal.name, "test")
. Thanks!
from frappe.desk.tags import DocTags
jv = frappe.get_doc({
"doctype": "Journal Entry",
"posting_date": "2015-01-01",
"accounts": [{
"account": ...
}],
...
})
jv.insert()
DocTags("Journal Entry").add(journal.name, "test")
1 Like