added customer get_query to allow search based on customer name. also don't show name again if id naming is based on customer name and not series
This commit is contained in:
parent
009d3e1952
commit
93a35cab19
@ -27,3 +27,5 @@ cur_frm.cscript.invoice_no = function(doc, cdt, cdn) {
|
|||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
get_server_fields('get_invoice_details', d.invoice_no, 'invoice_details', doc, cdt, cdn, 1);
|
get_server_fields('get_invoice_details', d.invoice_no, 'invoice_details', doc, cdt, cdn, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -48,3 +48,8 @@ cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(
|
|||||||
var d = locals[this.doctype][this.docname];
|
var d = locals[this.doctype][this.docname];
|
||||||
return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
|
return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
||||||
|
|
||||||
|
cur_frm.fields_dict.pp_so_details.grid.get_field("customer").get_query =
|
||||||
|
erpnext.utils.customer_query;
|
@ -28,3 +28,5 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
erpnext.show_task_gantt(cur_frm.gantt_area, cur_frm.docname);
|
erpnext.show_task_gantt(cur_frm.gantt_area, cur_frm.docname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -27,6 +27,8 @@ cur_frm.cscript.project = function(doc, cdt, cdn){
|
|||||||
if(doc.project) get_server_fields('get_project_details', '','', doc, cdt, cdn, 1);
|
if(doc.project) get_server_fields('get_project_details', '','', doc, cdt, cdn, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: remove these? field doesn't exist, but custom field could exist
|
||||||
cur_frm.fields_dict['customer'].get_query = function(doc,cdt,cdn){
|
cur_frm.fields_dict['customer'].get_query = function(doc,cdt,cdn){
|
||||||
var cond='';
|
var cond='';
|
||||||
if(doc.project) cond = 'ifnull(`tabProject`.customer, "") = `tabCustomer`.name AND ifnull(`tabProject`.name, "") = "'+doc.project+'" AND';
|
if(doc.project) cond = 'ifnull(`tabProject`.customer, "") = `tabCustomer`.name AND ifnull(`tabProject`.name, "") = "'+doc.project+'" AND';
|
||||||
|
@ -42,6 +42,7 @@ class DocType:
|
|||||||
ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
|
ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
# TODO: Remove these? as the field customer doesn't exists
|
||||||
def get_customer_details(self):
|
def get_customer_details(self):
|
||||||
cust = sql("select customer_name from `tabCustomer` where name=%s", self.doc.customer)
|
cust = sql("select customer_name from `tabCustomer` where name=%s", self.doc.customer)
|
||||||
if cust:
|
if cust:
|
||||||
|
@ -45,3 +45,6 @@ cur_frm.fields_dict['timesheet_details'].grid.get_field("task_name").get_query =
|
|||||||
|
|
||||||
return repl('SELECT distinct `tabTask`.`subject` FROM `tabTask` WHERE %(cond)s `tabTask`.`subject` LIKE "%s" ORDER BY `tabTask`.`subject` ASC LIMIT 50', {cond:cond});
|
return repl('SELECT distinct `tabTask`.`subject` FROM `tabTask` WHERE %(cond)s `tabTask`.`subject` LIKE "%s" ORDER BY `tabTask`.`subject` ASC LIMIT 50', {cond:cond});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.timesheet_details.grid.get_field("customer_name").get_query =
|
||||||
|
erpnext.utils.customer_query;
|
@ -51,3 +51,35 @@ erpnext.utils.lead_query = function() {
|
|||||||
case when company_name like \"%s%%\" then 0 else 1 end, \
|
case when company_name like \"%s%%\" then 0 else 1 end, \
|
||||||
lead_name asc limit 50";
|
lead_name asc limit 50";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// searches for customer
|
||||||
|
erpnext.utils.customer_query = function() {
|
||||||
|
if(sys_defaults.cust_master_name == "Customer Name") {
|
||||||
|
var fields = ["name", "customer_group", "country", "territory"];
|
||||||
|
} else {
|
||||||
|
var fields = ["name", "customer_name", "customer_group", "country", "territory"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return "select " + fields.join(", ") + " from `tabCustomer` where docstatus < 2 and \
|
||||||
|
(%(key)s like \"%s\" or customer_name like \"%%%s\") \
|
||||||
|
order by \
|
||||||
|
case when name like \"%s%%\" then 0 else 1 end, \
|
||||||
|
case when customer_name like \"%s%%\" then 0 else 1 end, \
|
||||||
|
name, customer_name limit 50";
|
||||||
|
};
|
||||||
|
|
||||||
|
// searches for supplier
|
||||||
|
erpnext.utils.supplier_query = function() {
|
||||||
|
if(sys_defaults.supp_master_name == "Supplier Name") {
|
||||||
|
var fields = ["name", "supplier_type"];
|
||||||
|
} else {
|
||||||
|
var fields = ["name", "supplier_name", "supplier_type"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return "select " + fields.join(", ") + " from `tabSupplier` where docstatus < 2 and \
|
||||||
|
(%(key)s like \"%s\" or supplier_name like \"%%%s\") \
|
||||||
|
order by \
|
||||||
|
case when name like \"%s%%\" then 0 else 1 end, \
|
||||||
|
case when supplier_name like \"%s%%\" then 0 else 1 end, \
|
||||||
|
name, supplier_name limit 50";
|
||||||
|
};
|
@ -83,3 +83,4 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
|||||||
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -149,3 +149,5 @@ cur_frm.cscript['Create Opportunity'] = function(){
|
|||||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -211,3 +211,5 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
|||||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';}
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';}
|
||||||
|
|
||||||
cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query;
|
cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query;
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -857,3 +857,5 @@ cur_frm.cscript.validate_items = function(doc) {
|
|||||||
validated = false;
|
validated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -18,3 +18,5 @@
|
|||||||
// =====================================================================
|
// =====================================================================
|
||||||
cur_frm.add_fetch('customer','customer_name','customer_name');
|
cur_frm.add_fetch('customer','customer_name','customer_name');
|
||||||
cur_frm.add_fetch('customer','address','customer_address');
|
cur_frm.add_fetch('customer','address','customer_address');
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -273,7 +273,7 @@ class DocType:
|
|||||||
self.exc_list = []
|
self.exc_list = []
|
||||||
for sle in sll:
|
for sle in sll:
|
||||||
# block if stock level goes negative on any date
|
# block if stock level goes negative on any date
|
||||||
if val_method != 'Moving Average' or flt(allow_negative_stock) == 0:
|
if (val_method != 'Moving Average') or (cint(allow_negative_stock) == 0):
|
||||||
if self.validate_negative_stock(cqty, sle):
|
if self.validate_negative_stock(cqty, sle):
|
||||||
cqty += sle['actual_qty']
|
cqty += sle['actual_qty']
|
||||||
continue
|
continue
|
||||||
|
@ -142,3 +142,6 @@ cur_frm.fields_dict['ref_rate_details'].grid.onrowadd = function(doc, cdt, cdn){
|
|||||||
locals[cdt][cdn].ref_currency = sys_defaults.currency;
|
locals[cdt][cdn].ref_currency = sys_defaults.currency;
|
||||||
refresh_field('ref_currency',cdn,'ref_rate_details');
|
refresh_field('ref_currency',cdn,'ref_rate_details');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.item_customer_details.grid.get_field("customer_name").get_query =
|
||||||
|
erpnext.utils.customer_query;
|
@ -68,3 +68,5 @@ cur_frm.fields_dict['item_code'].get_query = function(doc,cdt,cdn) {
|
|||||||
AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") \
|
AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") \
|
||||||
AND `tabItem`.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` ASC LIMIT 50';
|
AND `tabItem`.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -230,3 +230,5 @@ cur_frm.cscript.validate_items = function(doc) {
|
|||||||
validated = false;
|
validated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -137,3 +137,5 @@ cur_frm.cscript.hide_dialog = function() {
|
|||||||
if(cur_frm.communication_list)
|
if(cur_frm.communication_list)
|
||||||
cur_frm.communication_list.run();
|
cur_frm.communication_list.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -144,3 +144,5 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
|||||||
WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 \
|
WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 \
|
||||||
AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -131,3 +131,5 @@ cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) {
|
|||||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -114,3 +114,5 @@ cur_frm.fields_dict['maintenance_schedule'].get_query = function(doc) {
|
|||||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -190,3 +190,5 @@ EmailMessage = function(parent, args, list, idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict.allocated_to.get_query = erpnext.utils.profile_query;
|
cur_frm.fields_dict.allocated_to.get_query = erpnext.utils.profile_query;
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -56,7 +56,7 @@ class DocType(TransactionBase):
|
|||||||
msg=response)
|
msg=response)
|
||||||
|
|
||||||
self.doc.new_response = None
|
self.doc.new_response = None
|
||||||
webnotes.conn.set(self.doc,'status','Waiting for Customer')
|
webnotes.conn.set(self.doc, 'status', 'Waiting for Customer')
|
||||||
self.make_response_record(response)
|
self.make_response_record(response)
|
||||||
|
|
||||||
def last_response(self):
|
def last_response(self):
|
||||||
|
@ -41,4 +41,4 @@ cur_frm.cscript.hide_dialog = function() {
|
|||||||
cur_frm.address_list.run();
|
cur_frm.address_list.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -42,4 +42,4 @@ cur_frm.cscript.hide_dialog = function() {
|
|||||||
cur_frm.contact_list.run();
|
cur_frm.contact_list.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user