chore: simplify setting email status as open or closed

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
Chinmay D. Pai 2020-04-19 13:46:52 +05:30
parent bfac02a1a9
commit c8558e2b98
No known key found for this signature in database
GPG key ID: 75507BE256F40CED
2 changed files with 5 additions and 8 deletions

View file

@ -204,13 +204,13 @@ frappe.ui.form.on("Communication", {
},
mark_as_closed_open: function(frm) {
var action = frm.doc.status == "Open" ? "Close" : "Open";
var status = frm.doc.status == "Open" ? "Closed" : "Open";
return frappe.call({
method: "frappe.email.inbox.mark_as_closed_open",
args: {
communication: frm.doc.name,
action: action
status: status
},
freeze: true,
callback: function(r) {

View file

@ -97,12 +97,9 @@ def create_email_flag_queue(names, action):
mark_as_seen_unseen(name, action)
@frappe.whitelist()
def mark_as_closed_open(communication, action):
def mark_as_closed_open(communication, status):
"""Set status to open or close"""
if action == "Close":
frappe.db.set_value("Communication", communication, "status", "Closed")
else:
frappe.db.set_value("Communication", communication, "status", "Open")
frappe.db.set_value("Communication", communication, "status", status)
@frappe.whitelist()
def move_email(communication, email_account):
@ -131,4 +128,4 @@ def link_communication_to_document(doc, reference_doctype, reference_name, ignor
doc.reference_doctype = reference_doctype
doc.reference_name = reference_name
doc.status = "Linked"
doc.save(ignore_permissions=True)
doc.save(ignore_permissions=True)