contact.js: set customer, supplier

This commit is contained in:
Rushabh Mehta 2012-11-28 16:01:58 +05:30
parent af45422668
commit 57774c032c
4 changed files with 23 additions and 18 deletions

View File

@ -75,6 +75,13 @@ cur_frm.cscript.make_contact = function() {
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
new_doctype: "Contact",
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
contact = locals['Contact'][contact];
contact.supplier = cur_frm.doc.name;
contact.supplier_name = cur_frm.doc.supplier_name;
wn.set_route("Form", "Contact", contact.name);
},
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},

View File

@ -93,6 +93,16 @@ cur_frm.cscript.make_contact = function() {
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
contact = locals['Contact'][contact];
contact.customer = cur_frm.doc.name;
contact.customer_name = cur_frm.doc.customer_name;
if(cur_frm.doc.customer_type == 'Individual') {
contact.first_name = cur_frm.doc.customer_name;
}
wn.set_route("Form", "Contact", contact.name);
},
new_doctype: "Contact",
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"

View File

@ -76,6 +76,12 @@ cur_frm.cscript.make_contact = function() {
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
new_doctype: "Contact",
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
contact = locals['Contact'][contact];
contact.sales_partner = cur_frm.doc.name;
wn.set_route("Form", "Contact", contact.name);
},
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},
@ -92,7 +98,6 @@ cur_frm.cscript.make_contact = function() {
});
}
cur_frm.contact_list.run();
}
cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {

View File

@ -23,23 +23,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query;
var route = wn.get_route();
if(route[1]=='Supplier') {
var supplier = wn.container.page.frm.doc;
doc.supplier = supplier.name;
doc.supplier_name = supplier.supplier_name;
} else if(route[1]=='Customer') {
var customer = wn.container.page.frm.doc;
doc.customer = customer.name;
doc.customer_name = customer.customer_name;
if(customer.customer_type == 'Individual') {
doc.first_name = customer.customer_name;
}
} else if(route[1]=='Sales Partner') {
var sp = wn.container.page.frm.doc;
doc.sales_partner = sp.name;
}
}
cur_frm.cscript.refresh = function() {