How to add Issue doctype in get items from in sales invoice
Please check the core code:
We achieve that by adding code on the backend right
For server-side operations, this is possible. However, you can write the client-side script code in the Client Script doctype.
i think adding server script is more good but the field name in sales invoice is items and in issue is custom item so how can i get rid of the custom
Please check the whole code and apply it according to the scenario.
Can you show me a an exAMPLE OF CLIENT SIDE SCRIPT TO ADD A new button inside get items from
Please check the syntax:
frappe.ui.form.on('Sales Invoice', {
refresh: function(frm) {
frm.add_custom_button(__('Custom Button'), function(){
// your logic
}, __("Get Items From"));
}
});
ThanK you bro i have successfully added the Button ,Next how can i list the issues in issue doctype which is Closed
frappe.ui.form.on('Sales Invoice', {
refresh: function(frm) {
frm.add_custom_button(__('Issue'), function(){
// your logic
}, __("Get Items From"));
}
function () {
frm.set_query("Issue", function() {
return {
"filters": {
"status": 'Closed'
}
};
}
});
Successfully done Next how can i fetch the selected data to the sales invoice
action(selections) {
console.log(selections);
// logic
}
Please again check the code that I provided in the doc.
No bro that works i want to fetch datas from issue to sales invoice which is selected in multi selected
after selecting by clicking get items i need to populate the items from issue to the sales invoice
Please check the reference:
Okay bro how can i auto populate if the doc have same field names
frappe.ui.form.on('Sales Invoice', {
refresh: function(frm) {
frm.add_custom_button(__('Issue'), function(){
new frappe.ui.form.MultiSelectDialog({
doctype: "Issue",
target: this.cur_frm,
setters: {
},
get_query() {
return {
filters: { status: 'Closed' }
}
},
action(selections) {
if (selections && selections.length > 0) {
$.each(selections, function (i,Issue) {
frm.add_child("items", {
items : custom_itemss,
});
customer : customer;
});
frm.refresh_field("items");
$(".modal").modal("hide");
}
}
});
}, __("Get Items From"));
}
});
Issue is the doctype name