Thursday, 14 May 2015

working with comment and prompt box



frappe.ui.form.on("Sales Order", "press_me", function(frm, doctype, name) {
var d = frappe.prompt([
    {'fieldname': 'birth', 'fieldtype': 'Date', 'label': 'Birth Date', 'reqd': 0},
    {'fieldname': 'text', 'fieldtype': 'Text', 'label': 'Comment', 'reqd': 1}
],
function(values){
    var c = d.get_values()
    msgprint(frm.doc.customer)
    msgprint(frm.doc.doctype)
    frappe.model.open_mapped_doc({
            "method": "ngse.ngse_doc.ef_doc.apply_prompt_comment",
                        "args:": {
                                 "source_name": cur_frm,
                                 "dtype": frm.doc.doctype,
                         },
        });
},
'Age verification',
'Subscribe me'
)
});



@frappe.whitelist(allow_guest=True)
def apply_comment(source_name, target_doc=None):
        comment = frappe.new_doc("Comment")
        comment.comment = "test two"
        comment.comment_doctype = "Sales Order"
        comment.comment_docname = "SO-00110"
        comment.save()
        msgprint("after save")
        cur_doc = frappe.get_doc("Sales Order", source_name)

@frappe.whitelist(allow_guest=True)
def apply_prompt_comment(source_name, dtype, target_doc=None):
        comment = frappe.new_doc("Comment")
        comment.comment = dtype
        comment.comment_doctype = "Sales Order"
        comment.comment_docname = "SO-00110"
        comment.save()
        msgprint("Interaction Submited")
        cur_doc = frappe.get_doc("Sales Order", source_name)

No comments:

Post a Comment