Map_current_doc

frm.add_custom_button(
__(“Sales Order”),

        function () {
            erpnext.utils.map_current_doc({
                method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
                source_doctype: "Sales Order",
                target: frm,
                setters: {
                    po_no: frm.doc.po_no || undefined,
                    customer: frm.doc.customer || undefined,
                },
                get_query_filters: {
                    docstatus: 1,
                    status: ["not in", ["Closed", "On Hold"]],
                    per_billed: ["<", 99.99],
                    company: frm.doc.company,
                },
            });
        },
        __("Get Items From")
    );

po_no if data fieldtype

  1. I want ‘Customer PO’ as header not ‘Po No’
  2. When apply filter in customer Purchase Order then Po No column show blank.

Hi @RK_1214

Can you please share you dialog code

Please update the code.

frappe.ui.form.on('Sales Invoice', {
    refresh: function (frm) {
        frm.add_custom_button(
            __("Sales Order"),
            function () {

                setTimeout(function () {
                    $('span[title="Po No"]').text("Customer PO");
                }, 500);

                erpnext.utils.map_current_doc({
                    method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
                    source_doctype: "Sales Order",
                    target: frm,
                    setters: {
                        po_no: frm.doc.po_no || undefined,
                        customer: frm.doc.customer || undefined,
                    },
                    get_query_filters: {
                        docstatus: 1,
                        status: ["not in", ["Closed", "On Hold"]],
                        per_billed: ["<", 99.99],
                        company: frm.doc.company,
                    },
                });
            },
            __("Get Items From")
        );
    }
});

If label does not changed then please increase the setTimeout 500 to 700 or 100

Output:

3 Likes

Thank You .


After inserting a value into the Customer Purchase Order field, then customer PO column become blank

It’s coming but it’s gone when open the dialog or filter the value. data does not load properly for that.

any solution for that

No … !

can we hide Customer’s Purchase Order search bar

Not directly, you have to make a makeshift script :wink:

Please add this line in setTimeout

$('div[data-fieldname="po_no"]').hide();

Then reload Ctrl+Shift+R and check it.

1 Like