i added new tab break on sales invoice doctype ,all fields has allow on submit property
i have field (custom_invoice_count) bring to me count invoices for the current customer
my issue is the update status appearing to me (Update) when i choose new tab break after submitting the invoice status
frappe.ui.form.on('Sales Invoice', {
customer: function(frm) {
// fetch the total count of invoices for the customer
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Sales Invoice',
fields: ['name'],
filters: {
'customer': frm.doc.customer,
'status': ['not in', ['Cancelled', 'Draft']]
},
limit_page_length: 9999 // Set a high limit to fetch all invoices
},
callback: function(r) {
if (r.message) {
// Update the custom_invoice_count field in the Sales Invoice form
frm.set_value('custom_invoice_count', r.message.length);
}
}
});
// fetch the count of custom_call_made where type is checked for the customer
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Sales Invoice',
fields: ['name'],
filters: {
'customer': frm.doc.customer,
'custom_contact_made': 1, // Assuming custom_call_made is a checkbox field
'status': ['not in', ['Cancelled', 'Draft']]
},
limit_page_length: 9999 // Set a high limit to fetch all invoices
},
callback: function(r) {
if (r.message) {
// Update the custom_call_made_no field in the Sales Invoice form
frm.set_value('custom_contact_made_no', r.message.length);
}
}
});
},
onload: function(frm) {
// fetch all sales invoices for the current customer on form load
if (frm.doc.customer) {
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Sales Invoice',
fields: ['name'],
filters: {
'customer': frm.doc.customer,
'status': ['not in', ['Cancelled', 'Draft']]
},
limit_page_length: 9999 // Set a high limit to fetch all invoices
},
callback: function(r) {
if (r.message) {
// Update the custom_invoice_count field in the Sales Invoice form
frm.set_value('custom_invoice_count', r.message.length);
}
}
});
// fetch the count of custom_call_made where type is checked for the customer
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Sales Invoice',
fields: ['name'],
filters: {
'customer': frm.doc.customer,
'custom_contact_made': 1, // Assuming custom_call_made is a checkbox field
'status': ['not in', ['Cancelled', 'Draft']]
},
limit_page_length: 9999 // Set a high limit to fetch all invoices
},
callback: function(r) {
if (r.message) {
// Update the custom_call_made_no field in the Sales Invoice form
frm.set_value('custom_contact_made_no', r.message.length);
}
}
});
}
}
});