Merge branch 'show_address_in_online_pos' of https://github.com/mntechnique/erpnext into mntechnique-show_address_in_online_pos

This commit is contained in:
Nabin Hait 2018-02-12 19:14:38 +05:30
commit 4adcced9ae
3 changed files with 128 additions and 13 deletions

View File

@ -33,7 +33,39 @@ frappe.ui.form.on("Customer", {
} }
} }
}) })
frm.set_query('customer_primary_address', function(doc) {
return {
query: "erpnext.selling.doctype.customer.customer.get_customer_primary_address",
filters: {
'customer': doc.name
}
}
})
}, },
customer_primary_address: function(frm){
if(frm.doc.customer_primary_address){
frappe.call({
doc: frm.doc,
args: {
"address_title":frm.doc.customer_primary_address
},
method: 'get_display',
callback: function(r) {
frm.set_value("primary_address",r.message);
}
});
}
if(!frm.doc.customer_primary_address){
frm.set_value("primary_address", "");
}
},
customer_primary_contact: function(frm){
if(!frm.doc.customer_primary_contact){
frm.set_value("mobile_no", "");
frm.set_value("email_id", "");
}
},
refresh: function(frm) { refresh: function(frm) {
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") { if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
frm.toggle_display("naming_series", false); frm.toggle_display("naming_series", false);
@ -43,7 +75,7 @@ frappe.ui.form.on("Customer", {
frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Customer'} frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Customer'}
frm.toggle_display(['address_html','contact_html','primary_contact_detail'], !frm.doc.__islocal); frm.toggle_display(['address_html','contact_html','primary_address_and_contact_detail'], !frm.doc.__islocal);
if(!frm.doc.__islocal) { if(!frm.doc.__islocal) {
frappe.contacts.render_address_and_contact(frm); frappe.contacts.render_address_and_contact(frm);
@ -72,4 +104,4 @@ frappe.ui.form.on("Customer", {
validate: function(frm) { validate: function(frm) {
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
}, },
}); });

View File

@ -725,7 +725,8 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "primary_contact_detail", "description": "Select, to make the customer searchable with these fields",
"fieldname": "primary_address_and_contact_detail",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
@ -734,7 +735,7 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Primary Contact Detail", "label": "Primary Address and Contact Detail",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -755,6 +756,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Reselect, if the chosen contact is edited after save",
"fieldname": "customer_primary_contact", "fieldname": "customer_primary_contact",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -780,6 +782,68 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "mobile_no",
"fieldtype": "Read Only",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Mobile No",
"length": 0,
"no_copy": 0,
"options": "customer_primary_contact.mobile_no",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "email_id",
"fieldtype": "Read Only",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Id",
"length": 0,
"no_copy": 0,
"options": "customer_primary_contact.email_id",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
@ -815,8 +879,9 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "mobile_no", "description": "Reselect, if the chosen address is edited after save",
"fieldtype": "Read Only", "fieldname": "customer_primary_address",
"fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@ -824,10 +889,10 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Mobile Number", "label": "Customer Primary Address",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "customer_primary_contact.mobile_no", "options": "Address",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -846,7 +911,8 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "email_id", "default": "",
"fieldname": "primary_address",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
@ -855,10 +921,10 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Email Id", "label": "Primary Address",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "customer_primary_contact.email_id", "options": "",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -1383,7 +1449,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-01-30 11:52:05.497363", "modified": "2018-02-09 10:44:35.801716",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Customer", "name": "Customer",
@ -1574,7 +1640,7 @@
"quick_entry": 1, "quick_entry": 1,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"search_fields": "customer_name,customer_group,territory, mobile_no", "search_fields": "customer_name,customer_group,territory, mobile_no,primary_address",
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_order": "ASC", "sort_order": "ASC",
"title_field": "customer_name", "title_field": "customer_name",

View File

@ -77,6 +77,11 @@ class Customer(TransactionBase):
if self.flags.is_new_doc and self.get('address_line1'): if self.flags.is_new_doc and self.get('address_line1'):
make_address(self) make_address(self)
@classmethod
def get_display(self,address_title):
from frappe.contacts.doctype.address.address import get_address_display
return get_address_display(address_title)
def update_lead_status(self): def update_lead_status(self):
'''If Customer created from Lead, update lead status to "Converted" '''If Customer created from Lead, update lead status to "Converted"
update Customer link in Quotation, Opportunity''' update Customer link in Quotation, Opportunity'''
@ -309,3 +314,15 @@ def get_customer_primary_contact(doctype, txt, searchfield, start, page_len, fil
'customer': customer, 'customer': customer,
'txt': '%%%s%%' % txt 'txt': '%%%s%%' % txt
}) })
def get_customer_primary_address(doctype, txt, searchfield, start, page_len, filters):
customer = frappe.db.escape(filters.get('customer'))
return frappe.db.sql("""
select `tabAddress`.name from `tabAddress`, `tabDynamic Link`
where `tabAddress`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
and `tabDynamic Link`.link_doctype = 'Customer' and `tabAddress`.is_primary_address = 1
and `tabAddress`.name like %(txt)s
""", {
'customer': customer,
'txt': '%%%s%%' % txt
})