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
@ -26,4 +26,6 @@ cur_frm.fields_dict.invoice_details.grid.get_field("invoice_no").get_query = fun
|
||||
cur_frm.cscript.invoice_no = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
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];
|
||||
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;
|
@ -27,4 +27,6 @@ cur_frm.cscript.refresh = function(doc) {
|
||||
cur_frm.gantt_area.empty();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// TODO: remove these? field doesn't exist, but custom field could exist
|
||||
cur_frm.fields_dict['customer'].get_query = function(doc,cdt,cdn){
|
||||
var cond='';
|
||||
if(doc.project) cond = 'ifnull(`tabProject`.customer, "") = `tabCustomer`.name AND ifnull(`tabProject`.name, "") = "'+doc.project+'" AND';
|
||||
|
@ -41,7 +41,8 @@ class DocType:
|
||||
if cust:
|
||||
ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
|
||||
return ret
|
||||
|
||||
|
||||
# TODO: Remove these? as the field customer doesn't exists
|
||||
def get_customer_details(self):
|
||||
cust = sql("select customer_name from `tabCustomer` where name=%s", self.doc.customer)
|
||||
if cust:
|
||||
|
@ -44,4 +44,7 @@ cur_frm.fields_dict['timesheet_details'].grid.get_field("task_name").get_query =
|
||||
if(d.project_name) cond = 'ifnull(`tabTask`.project, "") = "'+d.project_name+'" AND';
|
||||
|
||||
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;
|
@ -105,7 +105,7 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
|
||||
}
|
||||
|
||||
me.init_account(d);
|
||||
});
|
||||
});
|
||||
}
|
||||
this.set_indent();
|
||||
this.prepare_balances();
|
||||
|
@ -51,3 +51,35 @@ erpnext.utils.lead_query = function() {
|
||||
case when company_name like \"%s%%\" then 0 else 1 end, \
|
||||
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';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -148,4 +148,6 @@ cur_frm.cscript['Create Opportunity'] = function(){
|
||||
//get query select Territory
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -210,4 +210,6 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
|
||||
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';}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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','address','customer_address');
|
||||
|
||||
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -273,7 +273,7 @@ class DocType:
|
||||
self.exc_list = []
|
||||
for sle in sll:
|
||||
# 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):
|
||||
cqty += sle['actual_qty']
|
||||
continue
|
||||
|
@ -332,4 +332,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
doctype: 'Delivery Note'
|
||||
}
|
||||
cur_frm.cscript.notify(doc, args);
|
||||
}
|
||||
}
|
@ -141,4 +141,7 @@ cur_frm.cscript.validate = function(doc,cdt,cdn){
|
||||
cur_frm.fields_dict['ref_rate_details'].grid.onrowadd = function(doc, cdt, cdn){
|
||||
locals[cdt][cdn].ref_currency = sys_defaults.currency;
|
||||
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;
|
@ -67,4 +67,6 @@ cur_frm.fields_dict['item_code'].get_query = function(doc,cdt,cdn) {
|
||||
WHERE `tabItem`.`docstatus`!= 2 AND ifnull(`tabItem`.`has_serial_no`, "No") = "Yes" \
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -230,3 +230,5 @@ cur_frm.cscript.validate_items = function(doc) {
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
@ -136,4 +136,6 @@ cur_frm.cscript.contact = function(doc, dt, dn) {
|
||||
cur_frm.cscript.hide_dialog = function() {
|
||||
if(cur_frm.communication_list)
|
||||
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 \
|
||||
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) {
|
||||
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) {
|
||||
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;
|
@ -189,4 +189,6 @@ EmailMessage = function(parent, args, list, idx) {
|
||||
this.make();
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
def last_response(self):
|
||||
|
@ -41,4 +41,4 @@ cur_frm.cscript.hide_dialog = function() {
|
||||
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.fields_dict.customer.get_query = erpnext.utils.customer_query;
|
||||
|
Loading…
Reference in New Issue
Block a user