It is possible and relatively not hard to customize quick entry form.
- Add custom js to app using
hook.py
app_include_js = [
'assets/appname/js/customer_quick_entry.js',
]
doc_events = {
'Customer': {
'on_update': 'appname.appname.customer_quick_entry.custom_customer_info'
}
}
- Add custom js to
appname/appname/public/js/customer_quick_entry.jsto override quick entry function. Field with same name will get copied to customer data
frappe.provide('frappe.ui.form');
frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({
// copied from `erpnext/erpnext/public/js/utils/customer_quick_entry.js`
init: function(doctype, after_insert) {
this.skip_redirect_on_error = true;
this._super(doctype, after_insert);
},
render_dialog: function() {
this.mandatory = this.get_field();
this._super();
},
get_field: function() {
const variantFields = [
{
label: __('Full Name'),
fieldname: 'customer_name',
fieldtype: 'Data',
},
{
fieldtype: 'Section Break',
},
{
label: __('Email Id'),
fieldname: 'email',
fieldtype: 'Data',
options: 'Email',
},
{
label: __('Gender'),
fieldname: 'gender',
fieldtype: 'Link',
options: 'Gender',
},
{
fieldtype: 'Column Break',
},
{
label: __('Mobile Number'),
fieldname: 'mobile',
fieldtype: 'Data',
},
{
label: __('Birthdate'),
fieldname: 'birthdate',
fieldtype: 'Date',
},
{
fieldtype: 'Section Break',
label: __('Tax Details'),
},
{
label: __('Tax ID'),
fieldname: 'tax_id',
fieldtype: 'Data',
},
{
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: __('Branch'),
fieldname: 'branch',
fieldtype: 'Data',
},
{
label: __('City'),
fieldname: 'city',
fieldtype: 'Data',
},
{
label: __('State'),
fieldname: 'state',
fieldtype: 'Data',
},
{
label: __('Country'),
fieldname: 'country',
fieldtype: 'Link',
options: 'Country',
default: 'Thailand',
},
{
label: __('Customer POS Id'),
fieldname: 'customer_pos_id',
fieldtype: 'Data',
hidden: 1,
},
];
return variantFields;
},
});
- Write address data
import frappe
from frappe.utils import cstr
from frappe import _
def custom_customer_info(doc, method):
# this function will get call `on_update` as we define in hook.py
add_address_info(doc)
def add_address_info(doc):
if doc.flags.is_new_doc and doc.get('address_line1'):
# this name construct should work
# because we just create this customer
# Billing is default type
# there shouldn't be any more address of this customer
address_name = (
cstr(doc.name).strip() + '-' + cstr(_('Billing')).strip()
)
address_doc = frappe.get_doc('Address', address_name)
# adding custom data to address
address_doc.branch = doc.get('branch')
address_doc.save()