Fix: keep Client Scripts as DB fixtures for custom DocTypes
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
frappe.ui.form.on('Load', {
|
||||
refresh: function(frm) {
|
||||
frm.add_custom_button(__('View Pallets'), function() {
|
||||
frappe.set_route('List', 'Pallet', {'load': frm.doc.name});
|
||||
}, __('Actions'));
|
||||
}
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
frappe.ui.form.on('Pallet', {
|
||||
refresh: function(frm) {
|
||||
frm.add_custom_button(__('View Serials'), function() {
|
||||
frappe.set_route('List', 'Serial No', {
|
||||
'pallet': frm.doc.pallet_number || frm.doc.name
|
||||
});
|
||||
}, __('View'));
|
||||
|
||||
frm.add_custom_button(__('Serials Spreadsheet'), function() {
|
||||
frappe.set_route('query-report', 'Serial Nos by Pallet', {
|
||||
'pallet': frm.doc.pallet_number || frm.doc.name
|
||||
});
|
||||
}, __('View'));
|
||||
}
|
||||
});
|
||||
@@ -1,67 +0,0 @@
|
||||
frappe.ui.form.on('Scheduled Pickup', {
|
||||
customer_number: function(frm) {
|
||||
var customer = frm.doc.customer_number;
|
||||
if (!customer) {
|
||||
clear_supplier_fields(frm);
|
||||
return;
|
||||
}
|
||||
frappe.call({
|
||||
method: 'frappe.client.get',
|
||||
args: {doctype: 'Supplier', name: customer},
|
||||
callback: function(r) {
|
||||
if (!r.message) return;
|
||||
var s = r.message;
|
||||
if (!frm.doc.company_name && s.supplier_name) {
|
||||
frm.set_value('company_name', s.supplier_name);
|
||||
}
|
||||
if (s.supplier_primary_contact) {
|
||||
frappe.call({
|
||||
method: 'frappe.client.get',
|
||||
args: {doctype: 'Contact', name: s.supplier_primary_contact},
|
||||
callback: function(cr) {
|
||||
if (!cr.message) return;
|
||||
var ct = cr.message;
|
||||
var full_name = [ct.first_name, ct.last_name].filter(Boolean).join(' ');
|
||||
if (!frm.doc.contact_name) frm.set_value('contact_name', full_name);
|
||||
if (!frm.doc.contact_phone) frm.set_value('contact_phone', ct.phone || '');
|
||||
if (!frm.doc.contact_email) frm.set_value('contact_email', ct.email_id || '');
|
||||
}
|
||||
});
|
||||
}
|
||||
if (s.supplier_primary_address) {
|
||||
frappe.call({
|
||||
method: 'frappe.client.get',
|
||||
args: {doctype: 'Address', name: s.supplier_primary_address},
|
||||
callback: function(ar) {
|
||||
if (!ar.message) return;
|
||||
var a = ar.message;
|
||||
if (!frm.doc.address_line) frm.set_value('address_line', a.address_line1 || '');
|
||||
if (!frm.doc.city) frm.set_value('city', a.city || '');
|
||||
if (!frm.doc.state) frm.set_value('state', a.state || '');
|
||||
if (!frm.doc.zip_code) frm.set_value('zip_code', a.pincode || '');
|
||||
}
|
||||
});
|
||||
}
|
||||
if (s.geocoded && s.latitude && s.longitude) {
|
||||
frm.set_value('latitude', s.latitude);
|
||||
frm.set_value('longitude', s.longitude);
|
||||
frm.set_value('geocoded', 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function clear_supplier_fields(frm) {
|
||||
frm.set_value('company_name', '');
|
||||
frm.set_value('contact_name', '');
|
||||
frm.set_value('contact_phone', '');
|
||||
frm.set_value('contact_email', '');
|
||||
frm.set_value('address_line', '');
|
||||
frm.set_value('city', '');
|
||||
frm.set_value('state', '');
|
||||
frm.set_value('zip_code', '');
|
||||
frm.set_value('latitude', '');
|
||||
frm.set_value('longitude', '');
|
||||
frm.set_value('geocoded', 0);
|
||||
}
|
||||
Reference in New Issue
Block a user