Fix: keep Client Scripts as DB fixtures for custom DocTypes
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
[
|
||||
{
|
||||
"name": "Pallet - View Serials",
|
||||
"dt": "Pallet",
|
||||
"script": "frappe.ui.form.on('Pallet', {\n refresh: function(frm) {\n frm.add_custom_button(__('View Serials'), function() {\n frappe.set_route('List', 'Serial No', {\n 'pallet': frm.doc.pallet_number || frm.doc.name\n });\n }, __('View'));\n \n frm.add_custom_button(__('Serials Spreadsheet'), function() {\n frappe.set_route('query-report', 'Serial Nos by Pallet', {\n 'pallet': frm.doc.pallet_number || frm.doc.name\n });\n }, __('View'));\n }\n});\n",
|
||||
"view": "Form",
|
||||
"enabled": 1
|
||||
},
|
||||
{
|
||||
"name": "Load - View Pallets Button",
|
||||
"dt": "Load",
|
||||
"script": "frappe.ui.form.on('Load', {\n refresh: function(frm) {\n frm.add_custom_button(__('View Pallets'), function() {\n frappe.set_route('List', 'Pallet', {'load': frm.doc.name});\n }, __('Actions'));\n }\n});\n",
|
||||
"view": "Form",
|
||||
"enabled": 1
|
||||
},
|
||||
{
|
||||
"name": "Scheduled Pickup - Auto Fill",
|
||||
"dt": "Scheduled Pickup",
|
||||
"script": "frappe.ui.form.on('Scheduled Pickup', {\n customer_number: function(frm) {\n var customer = frm.doc.customer_number;\n if (!customer) {\n clear_supplier_fields(frm);\n return;\n }\n frappe.call({\n method: 'frappe.client.get',\n args: {doctype: 'Supplier', name: customer},\n callback: function(r) {\n if (!r.message) return;\n var s = r.message;\n if (!frm.doc.company_name && s.supplier_name) {\n frm.set_value('company_name', s.supplier_name);\n }\n if (s.supplier_primary_contact) {\n frappe.call({\n method: 'frappe.client.get',\n args: {doctype: 'Contact', name: s.supplier_primary_contact},\n callback: function(cr) {\n if (!cr.message) return;\n var ct = cr.message;\n var full_name = [ct.first_name, ct.last_name].filter(Boolean).join(' ');\n if (!frm.doc.contact_name) frm.set_value('contact_name', full_name);\n if (!frm.doc.contact_phone) frm.set_value('contact_phone', ct.phone || '');\n if (!frm.doc.contact_email) frm.set_value('contact_email', ct.email_id || '');\n }\n });\n }\n if (s.supplier_primary_address) {\n frappe.call({\n method: 'frappe.client.get',\n args: {doctype: 'Address', name: s.supplier_primary_address},\n callback: function(ar) {\n if (!ar.message) return;\n var a = ar.message;\n if (!frm.doc.address_line) frm.set_value('address_line', a.address_line1 || '');\n if (!frm.doc.city) frm.set_value('city', a.city || '');\n if (!frm.doc.state) frm.set_value('state', a.state || '');\n if (!frm.doc.zip_code) frm.set_value('zip_code', a.pincode || '');\n }\n });\n }\n if (s.geocoded && s.latitude && s.longitude) {\n frm.set_value('latitude', s.latitude);\n frm.set_value('longitude', s.longitude);\n frm.set_value('geocoded', 1);\n }\n }\n });\n }\n});\n\nfunction clear_supplier_fields(frm) {\n frm.set_value('company_name', '');\n frm.set_value('contact_name', '');\n frm.set_value('contact_phone', '');\n frm.set_value('contact_email', '');\n frm.set_value('address_line', '');\n frm.set_value('city', '');\n frm.set_value('state', '');\n frm.set_value('zip_code', '');\n frm.set_value('latitude', '');\n frm.set_value('longitude', '');\n frm.set_value('geocoded', 0);\n}\n",
|
||||
"view": "Form",
|
||||
"enabled": 1
|
||||
}
|
||||
]
|
||||
+1
-7
@@ -10,6 +10,7 @@ fixtures = [
|
||||
"Custom Field",
|
||||
"DocType",
|
||||
"Workspace",
|
||||
"Client Script",
|
||||
]
|
||||
|
||||
# Required apps
|
||||
@@ -27,10 +28,3 @@ doc_events = {
|
||||
"before_save": "westech_r2.doctype.load.load.calculate_totals",
|
||||
},
|
||||
}
|
||||
|
||||
# Include JS in forms
|
||||
app_include_js = [
|
||||
"/assets/westech_r2/js/scheduled_pickup.js",
|
||||
"/assets/westech_r2/js/load.js",
|
||||
"/assets/westech_r2/js/pallet.js",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user