Tuesday, 24 March 2015

In ERPNExt fetch table field from master

In ERPNext:
fetch table field from master using following code.
But, I need this with custom script.
My code is.

  python code:

    def apply_documents_required(self):
            if self.documents_required_master:
                shipping_rule = frappe.get_doc("Documents Required Master", self.documents_required_master)
                frappe.msgprint("from python function")
                for condition in shipping_rule.get("documents_required_master"):
                    doc_req = {
                        "doctype": "Documents Required",
                        "name_of_document": condition.name_of_document,
                        "dispatch_address": condition.dispatch_address
                    }
                    if (5==5):
                        self.append("documents_required", doc_req)

js code:

    documents_required_master: function() {
            var me = this;
            msgprint("from js function")
            if(5==5) {
                return this.frm.call({
                    doc: this.frm.doc,
                    method: "apply_documents_required",
                    callback: function(r) {
                        if(!r.exc) {
                        }
                    }
                })
            }
        }

3 comments:

  1. Hi ,
    Can you please explain this code to me.I require to do something same.
    I have to fetch table field type from one doc to other , and add_fetch is not working.

    ReplyDelete
  2. Hi,

    Its same as tax table in ERPNext.
    We can define sales tax master template, according to sales tax master, all taxes gets filled in sales order.

    frappe.get_doc() is used to get doc tax template in sales order.
    shipping_rule.get("documents_required_master") is table field name

    So I am making list and appending it on Sales Order Tax Table, here it is self.append("documents_required", doc_req)

    You can email me your code/question
    My email is kolate.sambhaji@gmail.com

    Thanks,

    ReplyDelete
    Replies
    1. Thanks for the reply .
      I have Qc Master doc with a table field qc_cild (Doc Qc Child) and i want to fetch this in item with link field qc_name(contains link field to Qc Master) and table field in item is qc_value .
      Please help me understand how to do this .

      Delete