diff --git a/msp/hooks.py b/msp/hooks.py index c5f86e4..f0057f1 100644 --- a/msp/hooks.py +++ b/msp/hooks.py @@ -16,7 +16,7 @@ app_license = "GPLv3" # include js, css files in header of desk.html # app_include_css = "/assets/msp/css/msp.css" -# app_include_js = "/assets/msp/js/msp.js" +app_include_js = "/assets/msp/js/customer_quick_entry.js" # include js, css files in header of web template # web_include_css = "/assets/msp/css/msp.css" @@ -79,13 +79,11 @@ app_license = "GPLv3" # --------------- # Hook on document methods and events -# doc_events = { -# "*": { -# "on_update": "method", -# "on_cancel": "method", -# "on_trash": "method" -# } -# } +doc_events = { + "Customer": { + "on_update": "msp.msp.customer_quick_entry.custom_customer_info" + } +} # Scheduled Tasks # --------------- diff --git a/msp/public/js/customer_quick_entry.js b/msp/public/js/customer_quick_entry.js new file mode 100644 index 0000000..fc84bf2 --- /dev/null +++ b/msp/public/js/customer_quick_entry.js @@ -0,0 +1,118 @@ +frappe.provide('frappe.ui.form'); + +frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ + init: function(doctype, after_insert, init_callback, doc, force) { + this._super(doctype, after_insert, init_callback, doc, force); + this.skip_redirect_on_error = true; + }, + + render_dialog: function() { + this.mandatory = this.mandatory.concat(this.get_variant_fields()); + this._super(); + console.log("hi") + let me = this + console.log(me) + me.dialog.fields_dict.customer_name.$input[0].onchange = function() { + me.inputHandler(this) + } + + }, + + inputHandler: function(obj) { + console.log("test") + console.log(obj.value) + }, + + + + get_variant_fields: function() { + var variant_fields = [{ + fieldtype: "Section Break", + label: __("Primary Contact Details"), + collapsible: 1 + }, + { + label: __("Salutation"), + fieldname: "contact_salutation", + fieldtype: "Link", + options: "Salutation" + }, + { + label: __("First Name"), + fieldname: "first_name", + fieldtype: "Data" + }, + { + label: __("Last Name"), + fieldname: "last_name", + fieldtype: "Data" + }, + { + fieldtype: "Column Break" + }, + { + label: __("Mobile Number"), + fieldname: "mobile_no", + fieldtype: "Data" + }, + { + label: __("Phone Number"), + fieldname: "phone", + fieldtype: "Data" + }, + { + label: __("Email Id"), + fieldname: "email_id", + fieldtype: "Data" + }, + { + fieldtype: "Section Break", + label: __("Primary Address Details"), + collapsible: 1 + }, + { + label: __("Address Line 1"), + fieldname: "address_line1", + fieldtype: "Data" + }, + { + label: __("Address Line 2"), + fieldname: "address_line2", + fieldtype: "Data" + }, + { + label: __("ZIP Code"), + fieldname: "pincode", + fieldtype: "Data" + }, + { + fieldtype: "Column Break" + }, + { + label: __("City"), + fieldname: "city", + fieldtype: "Data" + }, + { + label: __("State"), + fieldname: "state", + fieldtype: "Data", + hidden: 1 + }, + { + label: __("Country"), + fieldname: "country", + fieldtype: "Link", + options: "Country", + default: "Germany" + }, + { + label: __("Customer POS Id"), + fieldname: "customer_pos_id", + fieldtype: "Data", + hidden: 1 + }]; + + return variant_fields; + }, +}) diff --git a/msp/public/v b/msp/public/v new file mode 100644 index 0000000..e69de29