Wednesday, 12 August 2015

fetch address using frappe.call

frappe.ui.form.on("Documents Required", "buyer", function(frm, cdt, cdn) {
    var d = frappe.get_doc(cdt, cdn);
    msgprint("hi from ui");
        if(d.buyer) {
        return frm.call({
            method: "erpnext.utilities.doctype.address.address.get_address_display",
            child: d,
            args: {
                "address_dict":  d.buyer
            },
                        callback: function(r) {
            if(r.message)
                                    msgprint("hi from callback"+r.message);
                                frappe.model.set_value(cdt, cdn, "buyer_address", r.message);
        }
        });
     }
})

3 comments:


  1. cur_frm.set_query("buyer", "documents_required_master", function(doc) {
    if(doc.customer) return {filters: { 'address_type': 'Buyer', customer: doc.customer } };
    });
    frappe.ui.form.on("Documents Required Master", "buyer", function(frm, cdt, cdn) {
    var d = frappe.get_doc(cdt, cdn);
    if(d.buyer) {
    return frm.call({
    method: "erpnext.utilities.doctype.address.address.get_address_display",
    child: d,
    args: {
    "address_dict": d.buyer
    },
    callback: function(r) {
    if(r.message)
    frappe.model.set_value(cdt, cdn, "buyer_address", r.message);
    }
    });
    }
    })
    cur_frm.set_query("consignee", "documents_required_master", function(doc) {
    if(doc.customer) return {filters: { 'address_type': 'Consignee', customer: doc.customer } };
    });
    frappe.ui.form.on("Documents Required Master", "consignee", function(frm, cdt, cdn) {
    var d = frappe.get_doc(cdt, cdn);
    if(d.consignee) {
    return frm.call({
    method: "erpnext.utilities.doctype.address.address.get_address_display",
    child: d,
    args: {
    "address_dict": d.consignee
    },
    callback: function(r) {
    if(r.message)
    frappe.model.set_value(cdt, cdn, "consignee_address", r.message);
    }
    });
    }
    })
    cur_frm.set_query("notify_party_i", "documents_required_master", function(doc) {
    if(doc.customer) return {filters: { 'address_type': 'Notify Party', customer: doc.customer } };
    });
    cur_frm.set_query("notify_party_ii", "documents_required_master", function(doc) {
    if(doc.customer) return {filters: { 'address_type': 'Notify Party', customer: doc.customer } };
    });
    cur_frm.set_query("notify_party_iii", "documents_required_master", function(doc) {
    if(doc.customer) return {filters: { 'address_type': 'Notify Party', customer: doc.customer } };
    });
    frappe.ui.form.on("Documents Required Master", "notify_party_i", function(frm, cdt, cdn) {
    var d = frappe.get_doc(cdt, cdn);
    if(d.notify_party_i) {
    return frm.call({
    method: "erpnext.utilities.doctype.address.address.get_address_display",
    child: d,
    args: {
    "address_dict": d.notify_party_i
    },
    callback: function(r) {
    if(r.message)
    frappe.model.set_value(cdt, cdn, "notify_party_address_i", r.message);
    }
    });
    }
    })
    frappe.ui.form.on("Documents Required Master", "notify_party_ii", function(frm, cdt, cdn) {
    var d = frappe.get_doc(cdt, cdn);
    if(d.notify_party_ii) {
    return frm.call({
    method: "erpnext.utilities.doctype.address.address.get_address_display",
    child: d,
    args: {
    "address_dict": d.notify_party_ii
    },
    callback: function(r) {
    if(r.message)
    frappe.model.set_value(cdt, cdn, "notify_party_address_ii", r.message);
    }
    });
    }
    })
    frappe.ui.form.on("Documents Required Master", "notify_party_iii", function(frm, cdt, cdn) {
    var d = frappe.get_doc(cdt, cdn);
    if(d.notify_party_iii) {
    return frm.call({
    method: "erpnext.utilities.doctype.address.address.get_address_display",
    child: d,
    args: {
    "address_dict": d.notify_party_iii
    },
    callback: function(r) {
    if(r.message)
    frappe.model.set_value(cdt, cdn, "notify_party_address_iii", r.message);
    }
    });
    }
    })

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Dear Kolate,
    in address display, given above mentioned code but occurring error is " No module named address.address" pl suggest

    ReplyDelete