From b45cbda7fa27466fdf7245b4a354d3d77255a8cc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 21 Nov 2012 18:00:22 +0530 Subject: [PATCH 01/10] fixed order by for common queries, should be ordered based on startswith match and then alphabetical order for fuzzy match --- public/js/utils.js | 17 ++++- selling/doctype/lead/lead.txt | 110 ++++++++++++++------------- utilities/doctype/address/address.js | 4 +- 3 files changed, 74 insertions(+), 57 deletions(-) diff --git a/public/js/utils.js b/public/js/utils.js index 6cd2c19a497..185baa6e290 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -22,7 +22,11 @@ erpnext.utils.profile_query = function() { from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and \ name not in ('Administrator', 'Guest') and (%(key)s like \"%s\" or \ concat_ws(' ', first_name, middle_name, last_name) like \"%%%s\") \ - order by name asc limit 50"; + order by \ + case when name like \"%s%%\" then 0 else 1 end, \ + case when concat_ws(' ', first_name, middle_name, last_name) like \"%s%%\" \ + then 0 else 1 end, \ + name asc limit 50"; }; // searches for active employees @@ -30,7 +34,10 @@ erpnext.utils.employee_query = function() { return "select name, employee_name from `tabEmployee` \ where status = 'Active' and docstatus < 2 and \ (%(key)s like \"%s\" or employee_name like \"%%%s\") \ - order by name asc limit 50"; + order by \ + case when name like \"%s%%\" then 0 else 1 end, \ + case when employee_name like \"%s%%\" then 0 else 1 end, \ + name limit 50"; }; // searches for leads which are not converted @@ -38,5 +45,9 @@ erpnext.utils.lead_query = function() { return "select name, lead_name, company_name from `tabLead` \ where docstatus < 2 and ifnull(status, '') != 'Converted' and \ (%(key)s like \"%s\" or lead_name like \"%%%s\" or company_name like \"%%%s\") \ - order by lead_name asc limit 50"; + order by \ + case when name like \"%s%%\" then 0 else 1 end, \ + case when lead_name like \"%s%%\" then 0 else 1 end, \ + case when company_name like \"%s%%\" then 0 else 1 end, \ + lead_name asc limit 50"; }; diff --git a/selling/doctype/lead/lead.txt b/selling/doctype/lead/lead.txt index b41fc51abe4..666d702eff5 100644 --- a/selling/doctype/lead/lead.txt +++ b/selling/doctype/lead/lead.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - u'creation': '2012-08-08 10:41:31', + u'creation': '2012-11-19 12:06:56', u'docstatus': 0, - u'modified': '2012-11-16 12:26:14', + u'modified': '2012-11-21 17:12:54', u'modified_by': u'Administrator', u'owner': u'Administrator' }, @@ -40,12 +40,14 @@ # These values are common for all DocPerm { + 'amend': 0, u'doctype': u'DocPerm', u'name': u'__common__', 'parent': u'Lead', 'parentfield': u'permissions', 'parenttype': u'DocType', - 'read': 1 + 'read': 1, + 'submit': 0 }, # DocType, Lead @@ -146,7 +148,7 @@ { 'colour': u'White:FFF', 'depends_on': u"eval:doc.source == 'Existing Customer'", - 'description': u'Source of th', + 'description': u'Source of the Lead', u'doctype': u'DocField', 'fieldname': u'customer', 'fieldtype': u'Link', @@ -626,77 +628,81 @@ # DocPerm { + 'cancel': 0, + 'create': 0, + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'All', + 'write': 0 + }, + + # DocPerm + { + 'cancel': 0, 'create': 1, u'doctype': u'DocPerm', 'permlevel': 0, - 'role': u'Guest', + 'role': u'Sales User', 'write': 1 }, # DocPerm { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Sales User', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Sales Manager', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, 'cancel': 1, 'create': 1, u'doctype': u'DocPerm', 'permlevel': 0, 'role': u'Sales Manager', - 'submit': 0, 'write': 1 }, # DocPerm { - 'amend': 0, - 'cancel': 0, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Sales User', - 'submit': 0, - 'write': 1 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All' - }, - - # DocPerm - { - 'amend': 0, 'cancel': 0, 'create': 1, u'doctype': u'DocPerm', 'permlevel': 0, 'role': u'System Manager', - 'submit': 0, + 'write': 1 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 0, + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Sales Manager', + 'write': 0 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 0, + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Sales User', + 'write': 0 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'System Manager', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Guest', 'write': 1 } ] \ No newline at end of file diff --git a/utilities/doctype/address/address.js b/utilities/doctype/address/address.js index c4631f8063a..3b27ba81f0e 100644 --- a/utilities/doctype/address/address.js +++ b/utilities/doctype/address/address.js @@ -15,8 +15,8 @@ // along with this program. If not, see . cur_frm.cscript.onload = function(doc, cdt, cdn) { - if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name'); - if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name'); + cur_frm.add_fetch('customer', 'customer_name', 'customer_name'); + cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name'); var route = wn.get_route(); if(route[1]=='Supplier') { From 009d3e1952a86863f4a5751e76cceae6ae835038 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 21 Nov 2012 18:00:51 +0530 Subject: [PATCH 02/10] updated latest_updates page --- home/page/latest_updates/latest_updates.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index 38ff40f2b85..a99185cd423 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,16 @@ erpnext.updates = [ + ["21st November 2012", [ + "Tree Report: Added missing expand / collapse buttons.", + "List View: Do not show restricted records, as defined in Permission Manager.", + "Customer Link Field: Search by Customer Name instead of ID", + "Customer Link Field: Show only ID in auto-suggest \ + if ID created using Customer Name (as defined in Global Defaults)", + "Letter Head: Fixed bug causing cursor position to reset in Content", + ], + ["20th November 2012", [ + "Auto-suggest: Show main label in bold", + "Data Import Tool: Fixed #Name error faced by MS Excel users in import template", + ]], ["19th November 2012", [ "Sales Order: Bugfix - Shipping Address should be a Link field.", "Link Fields: Search Profile, Employee and Lead using Full Names instead of ID.", From 93a35cab19b67d95c1f88a2cf726ee2b65e1feaa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 21 Nov 2012 18:02:22 +0530 Subject: [PATCH 03/10] 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 --- accounts/doctype/c_form/c_form.js | 4 ++- .../production_planning_tool.js | 5 +++ projects/doctype/project/project.js | 4 ++- projects/doctype/task/task.js | 2 ++ projects/doctype/task/task.py | 3 +- projects/doctype/timesheet/timesheet.js | 5 ++- public/js/account_tree_grid.js | 2 +- public/js/utils.js | 32 +++++++++++++++++++ .../installation_note/installation_note.js | 1 + selling/doctype/lead/lead.js | 4 ++- selling/doctype/opportunity/opportunity.js | 4 ++- selling/doctype/sales_common/sales_common.js | 2 ++ .../shipping_address/shipping_address.js | 2 ++ stock/doctype/bin/bin.py | 2 +- stock/doctype/delivery_note/delivery_note.js | 2 +- stock/doctype/item/item.js | 5 ++- stock/doctype/serial_no/serial_no.js | 4 ++- stock/doctype/stock_entry/stock_entry.js | 2 ++ .../doctype/communication/communication.js | 4 ++- .../doctype/customer_issue/customer_issue.js | 2 ++ .../maintenance_schedule.js | 2 ++ .../maintenance_visit/maintenance_visit.js | 2 ++ .../doctype/support_ticket/support_ticket.js | 4 ++- .../doctype/support_ticket/support_ticket.py | 2 +- utilities/doctype/address/address.js | 2 +- utilities/doctype/contact/contact.js | 2 +- 26 files changed, 89 insertions(+), 16 deletions(-) diff --git a/accounts/doctype/c_form/c_form.js b/accounts/doctype/c_form/c_form.js index d9e5c68d2b5..adb989d8f7f 100644 --- a/accounts/doctype/c_form/c_form.js +++ b/accounts/doctype/c_form/c_form.js @@ -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); -} \ No newline at end of file +} + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/production/doctype/production_planning_tool/production_planning_tool.js b/production/doctype/production_planning_tool/production_planning_tool.js index 11d6e44c10f..9caf829127a 100644 --- a/production/doctype/production_planning_tool/production_planning_tool.js +++ b/production/doctype/production_planning_tool/production_planning_tool.js @@ -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; \ No newline at end of file diff --git a/projects/doctype/project/project.js b/projects/doctype/project/project.js index 560544152db..7f847b97f8e 100644 --- a/projects/doctype/project/project.js +++ b/projects/doctype/project/project.js @@ -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); } -} \ No newline at end of file +} + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/projects/doctype/task/task.js b/projects/doctype/task/task.js index 295c58eb935..18c16538cad 100644 --- a/projects/doctype/task/task.js +++ b/projects/doctype/task/task.js @@ -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'; diff --git a/projects/doctype/task/task.py b/projects/doctype/task/task.py index 423d34307ff..175379f78ea 100644 --- a/projects/doctype/task/task.py +++ b/projects/doctype/task/task.py @@ -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: diff --git a/projects/doctype/timesheet/timesheet.js b/projects/doctype/timesheet/timesheet.js index 81f0420ec8d..dc973fe149a 100644 --- a/projects/doctype/timesheet/timesheet.js +++ b/projects/doctype/timesheet/timesheet.js @@ -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}); -} \ No newline at end of file +} + +cur_frm.fields_dict.timesheet_details.grid.get_field("customer_name").get_query = + erpnext.utils.customer_query; \ No newline at end of file diff --git a/public/js/account_tree_grid.js b/public/js/account_tree_grid.js index cf33ee4f6d7..10e1daccded 100644 --- a/public/js/account_tree_grid.js +++ b/public/js/account_tree_grid.js @@ -105,7 +105,7 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({ } me.init_account(d); - }); + }); } this.set_indent(); this.prepare_balances(); diff --git a/public/js/utils.js b/public/js/utils.js index 185baa6e290..43984988208 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -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"; +}; \ No newline at end of file diff --git a/selling/doctype/installation_note/installation_note.js b/selling/doctype/installation_note/installation_note.js index 44f6ac8bf90..f298eda2fb9 100644 --- a/selling/doctype/installation_note/installation_note.js +++ b/selling/doctype/installation_note/installation_note.js @@ -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; \ No newline at end of file diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 78182f21e47..8c940bcf812 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -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'; -} \ No newline at end of file +} + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 4070f5e9dc7..a7290928d73 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -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; \ No newline at end of file +cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query; + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index be6f3f13013..65112b5ca44 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -857,3 +857,5 @@ cur_frm.cscript.validate_items = function(doc) { validated = false; } } + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/selling/doctype/shipping_address/shipping_address.js b/selling/doctype/shipping_address/shipping_address.js index 0ac173a6ccc..deea4ed445f 100755 --- a/selling/doctype/shipping_address/shipping_address.js +++ b/selling/doctype/shipping_address/shipping_address.js @@ -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; \ No newline at end of file diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index 2f78f9c2fe6..fdf9eeb9a3c 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -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 diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index e1f8b3784e5..4a3910abecb 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -332,4 +332,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { doctype: 'Delivery Note' } cur_frm.cscript.notify(doc, args); -} +} \ No newline at end of file diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index 332a3f093ec..c5501d5166b 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -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'); -} \ No newline at end of file +} + +cur_frm.fields_dict.item_customer_details.grid.get_field("customer_name").get_query = + erpnext.utils.customer_query; \ No newline at end of file diff --git a/stock/doctype/serial_no/serial_no.js b/stock/doctype/serial_no/serial_no.js index 901acd2e7d4..62a912670d4 100644 --- a/stock/doctype/serial_no/serial_no.js +++ b/stock/doctype/serial_no/serial_no.js @@ -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'; -} \ No newline at end of file +} + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index b40a4137b8f..859bd5823fe 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -230,3 +230,5 @@ cur_frm.cscript.validate_items = function(doc) { validated = false; } } + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/support/doctype/communication/communication.js b/support/doctype/communication/communication.js index 76161ab2dbc..9995729b992 100644 --- a/support/doctype/communication/communication.js +++ b/support/doctype/communication/communication.js @@ -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(); -} \ No newline at end of file +} + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/support/doctype/customer_issue/customer_issue.js b/support/doctype/customer_issue/customer_issue.js index 545ff5669fd..81c10d4d118 100644 --- a/support/doctype/customer_issue/customer_issue.js +++ b/support/doctype/customer_issue/customer_issue.js @@ -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; \ No newline at end of file diff --git a/support/doctype/maintenance_schedule/maintenance_schedule.js b/support/doctype/maintenance_schedule/maintenance_schedule.js index efa3eac0379..21d2e62e533 100644 --- a/support/doctype/maintenance_schedule/maintenance_schedule.js +++ b/support/doctype/maintenance_schedule/maintenance_schedule.js @@ -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; \ No newline at end of file diff --git a/support/doctype/maintenance_visit/maintenance_visit.js b/support/doctype/maintenance_visit/maintenance_visit.js index 1e5e9c80097..a53c0903c06 100644 --- a/support/doctype/maintenance_visit/maintenance_visit.js +++ b/support/doctype/maintenance_visit/maintenance_visit.js @@ -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; \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 50f49b011c1..6ab2c689724 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -189,4 +189,6 @@ EmailMessage = function(parent, args, list, idx) { this.make(); } -cur_frm.fields_dict.allocated_to.get_query = erpnext.utils.profile_query; \ No newline at end of file +cur_frm.fields_dict.allocated_to.get_query = erpnext.utils.profile_query; + +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index d04f4730f1d..dde4fd2c7b8 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -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): diff --git a/utilities/doctype/address/address.js b/utilities/doctype/address/address.js index 3b27ba81f0e..0ace1678874 100644 --- a/utilities/doctype/address/address.js +++ b/utilities/doctype/address/address.js @@ -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; \ No newline at end of file diff --git a/utilities/doctype/contact/contact.js b/utilities/doctype/contact/contact.js index 1b0894ee219..5c71acf4a5c 100644 --- a/utilities/doctype/contact/contact.js +++ b/utilities/doctype/contact/contact.js @@ -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; From b3cb970eefaf133b707f714c9bfee00929c3d088 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 12:23:50 +0530 Subject: [PATCH 04/10] compose support ticket reply using markdown --- home/page/latest_updates/latest_updates.js | 5 ++++- support/doctype/support_ticket/support_ticket.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index a99185cd423..dfd6c10e426 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,7 @@ erpnext.updates = [ + ["22nd November 2012", [ + "Support Ticket: Compose a reply using Markdown", + ]], ["21st November 2012", [ "Tree Report: Added missing expand / collapse buttons.", "List View: Do not show restricted records, as defined in Permission Manager.", @@ -6,7 +9,7 @@ erpnext.updates = [ "Customer Link Field: Show only ID in auto-suggest \ if ID created using Customer Name (as defined in Global Defaults)", "Letter Head: Fixed bug causing cursor position to reset in Content", - ], + ]], ["20th November 2012", [ "Auto-suggest: Show main label in bold", "Data Import Tool: Fixed #Name error faced by MS Excel users in import template", diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index dde4fd2c7b8..39686187b6c 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -36,16 +36,19 @@ class DocType(TransactionBase): if not self.doc.new_response: webnotes.msgprint("Please write something as a response", raise_exception=1) + import markdown2 + self.doc.new_response = markdown2.markdown(self.doc.new_response) + subject = '[' + self.doc.name + '] ' + (self.doc.subject or 'No Subject Specified') - response = self.doc.new_response + '\n\n[Please do not change the subject while responding.]' + response = self.doc.new_response + '

[Please do not change the subject while responding.]

' # add last response to new response response += self.last_response() signature = webnotes.conn.get_value('Email Settings',None,'support_signature') if signature: - response += '\n\n' + signature + response += '

' + signature + '

' from webnotes.utils.email_lib import sendmail From d7f1bcbde6875c64a1128cfece7a13559a90114d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 16:34:09 +0530 Subject: [PATCH 05/10] changes to make select field compatible to chosen --- .../page/general_ledger/general_ledger.js | 23 ++++++++++++++++--- home/page/attributions/attributions.html | 8 +++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js index ecc8626a8b7..d9fb4bb0ce4 100644 --- a/accounts/page/general_ledger/general_ledger.js +++ b/accounts/page/general_ledger/general_ledger.js @@ -104,23 +104,40 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ var $filter = me.filter_inputs.account; var company = $(this).val(); var default_company = me.filter_inputs.company.get(0).opts.default_value; - $filter.empty().add_options([$filter.get(0).opts.default_value].concat( + var default_account = $filter.get(0).opts.default_value; + var new_options = [default_account].concat( $.map(wn.report_dump.data["Account"], function(ac) { return (company===default_company || accounts_by_company[company].indexOf(ac.name)!=-1) ? ac.name : null; - }))); + })); + var old_account = me.filter_inputs.account.val(); + + $filter.empty().add_options(new_options); + + if((old_account != default_account) && new_options.indexOf(old_account)!=-1) { + $filter.val(old_account); + } + + // chosen + $filter.trigger("liszt:updated"); + me.filter_inputs.refresh.click(); }); this.filter_inputs.account && this.filter_inputs.account.change(function() { me.filter_inputs.refresh.click(); }); + }, init_filter_values: function() { this._super(); this.filter_inputs.company.change(); }, + apply_filters_from_route: function() { + this._super(); + this.filter_inputs.company.change(); + }, make_accounts_by_company: function() { var accounts_by_company = {}; var me = this; @@ -134,7 +151,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ account = this.account_by_name[account]; item_account = this.account_by_name[item_account]; - return (item_account.lft >= account.lft && item_account.rgt <= account.rgt) + return ((item_account.lft >= account.lft) && (item_account.rgt <= account.rgt)); }, prepare_data: function() { // add Opening, Closing, Totals rows diff --git a/home/page/attributions/attributions.html b/home/page/attributions/attributions.html index 9952908eda9..113b969c133 100644 --- a/home/page/attributions/attributions.html +++ b/home/page/attributions/attributions.html @@ -40,10 +40,14 @@
  • Ace - code editor
  • Slick Grid - report grid
  • jQPlot - graphs
  • -
  • JQuery.Gantt - Gantt Chart
  • +
  • + JQuery.Gantt - Gantt Chart
  • JSON2 - JSON builder, parser
  • JSColor - color picker
  • -
  • Downloadify - Export CSV files from the browser
  • +
  • + Downloadify - Export CSV files from the browser
  • +
  • + Chosen - a searchable select dropdown
  • From 293e0124cd18930b32a69d99d6dce527299b6825 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 16:53:04 +0530 Subject: [PATCH 06/10] convert select to chosen, if specified in filters --- accounts/page/general_ledger/general_ledger.js | 7 +++++-- buying/page/purchase_analytics/purchase_analytics.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js index d9fb4bb0ce4..ebe24dc5581 100644 --- a/accounts/page/general_ledger/general_ledger.js +++ b/accounts/page/general_ledger/general_ledger.js @@ -69,7 +69,8 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ filter: function(val, item, opts) { return item.company == val || val == opts.default_value; }}, - {fieldtype:"Select", label: "Account", link:"Account", default_value: "Select Account...", + {fieldtype:"Select", label: "Account", link:"Account", + default_value: "Select Account...", chosen: true, filter: function(val, item, opts, me) { if(val == opts.default_value) { return true; @@ -120,7 +121,9 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ } // chosen - $filter.trigger("liszt:updated"); + if(me.filter_inputs.company.get(0).opts.chosen) { + $filter.trigger("liszt:updated"); + } me.filter_inputs.refresh.click(); }); diff --git a/buying/page/purchase_analytics/purchase_analytics.js b/buying/page/purchase_analytics/purchase_analytics.js index ac0e41fe438..23db139c4d8 100644 --- a/buying/page/purchase_analytics/purchase_analytics.js +++ b/buying/page/purchase_analytics/purchase_analytics.js @@ -32,7 +32,7 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ parent: $(wrapper).find('.layout-main'), appframe: wrapper.appframe, doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", - "Purchase Invoice", "Purchase Invoice Item"], + "Purchase Invoice", "Purchase Invoice Item", "Fiscal Year"], tree_grid: { show: true } }); From 1e6f25086faed0f61c189790770ba0745912d1f0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 16:54:54 +0530 Subject: [PATCH 07/10] syntax fix in voucher import tool --- accounts/page/voucher_import_tool/voucher_import_tool.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 4fb033bac8e..4a94ad6bae6 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -90,8 +90,12 @@ def import_vouchers(common_values, data, start_idx, import_type): webnotes.conn.commit() try: + jv = Document("Journal Voucher") + webnotes.conn.begin() for i in xrange(len(data)): + jv = Document("Journal Voucher") + d = data[i][0] if import_type == "Voucher Import: Two Accounts" and flt(d.get("amount")) == 0: webnotes.message_log = ["Amount not specified"] @@ -112,7 +116,6 @@ def import_vouchers(common_values, data, start_idx, import_type): d.company = common_values.company - jv = Document("Journal Voucher") map_fields(["voucher_type", "posting_date", "naming_series", "remarks:user_remark", "ref_number:cheque_no", "ref_date:cheque_date", "is_opening", "due_date", "company"], d, jv.fields) From ba6aafedad9ebeb46c133644da394cd366dc9713 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 17:38:48 +0530 Subject: [PATCH 08/10] commented out chosen code -- unable to adjust the margin/position correctly --- accounts/page/general_ledger/general_ledger.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js index ebe24dc5581..b6fa3a0770d 100644 --- a/accounts/page/general_ledger/general_ledger.js +++ b/accounts/page/general_ledger/general_ledger.js @@ -121,9 +121,9 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ } // chosen - if(me.filter_inputs.company.get(0).opts.chosen) { - $filter.trigger("liszt:updated"); - } + // if(me.filter_inputs.company.get(0).opts.chosen) { + // $filter.trigger("liszt:updated"); + // } me.filter_inputs.refresh.click(); }); From 83350bc94665b98ee837cd69543f8cce57b091fc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 17:39:19 +0530 Subject: [PATCH 09/10] supplier can now be searched using name --- buying/doctype/purchase_common/purchase_common.js | 4 +++- stock/doctype/item/item.js | 5 ++++- stock/doctype/serial_no/serial_no.js | 4 +++- stock/doctype/stock_entry/stock_entry.js | 4 +++- support/doctype/communication/communication.js | 4 +++- utilities/doctype/address/address.js | 4 +++- utilities/doctype/contact/contact.js | 2 ++ 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index f295aa00ef3..7553a49c459 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -668,4 +668,6 @@ cur_frm.cscript.project_name = function(doc, cdt, cdn) { }); refresh_field(cur_frm.cscript.fname); } -} \ No newline at end of file +} + +cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; \ No newline at end of file diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index c5501d5166b..828beab3841 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -144,4 +144,7 @@ cur_frm.fields_dict['ref_rate_details'].grid.onrowadd = function(doc, cdt, cdn){ } cur_frm.fields_dict.item_customer_details.grid.get_field("customer_name").get_query = - erpnext.utils.customer_query; \ No newline at end of file + erpnext.utils.customer_query; + +cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query = + erpnext.utils.supplier_query; \ No newline at end of file diff --git a/stock/doctype/serial_no/serial_no.js b/stock/doctype/serial_no/serial_no.js index 62a912670d4..49e88e28263 100644 --- a/stock/doctype/serial_no/serial_no.js +++ b/stock/doctype/serial_no/serial_no.js @@ -69,4 +69,6 @@ cur_frm.fields_dict['item_code'].get_query = function(doc,cdt,cdn) { AND `tabItem`.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` ASC LIMIT 50'; } -cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; + +cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 859bd5823fe..bf7582652f8 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -231,4 +231,6 @@ cur_frm.cscript.validate_items = function(doc) { } } -cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; + +cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; \ No newline at end of file diff --git a/support/doctype/communication/communication.js b/support/doctype/communication/communication.js index 9995729b992..f56b7a12567 100644 --- a/support/doctype/communication/communication.js +++ b/support/doctype/communication/communication.js @@ -138,4 +138,6 @@ cur_frm.cscript.hide_dialog = function() { cur_frm.communication_list.run(); } -cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; + +cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; \ No newline at end of file diff --git a/utilities/doctype/address/address.js b/utilities/doctype/address/address.js index 0ace1678874..034806e1fb4 100644 --- a/utilities/doctype/address/address.js +++ b/utilities/doctype/address/address.js @@ -41,4 +41,6 @@ cur_frm.cscript.hide_dialog = function() { cur_frm.address_list.run(); } -cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; \ No newline at end of file +cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; + +cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; \ No newline at end of file diff --git a/utilities/doctype/contact/contact.js b/utilities/doctype/contact/contact.js index 5c71acf4a5c..43bba1a7424 100644 --- a/utilities/doctype/contact/contact.js +++ b/utilities/doctype/contact/contact.js @@ -43,3 +43,5 @@ cur_frm.cscript.hide_dialog = function() { } cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; + +cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; \ No newline at end of file From 510281c5825dc12e443cbe9416e359b8b36c6d28 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Nov 2012 17:41:09 +0530 Subject: [PATCH 10/10] updates latest updates --- home/page/latest_updates/latest_updates.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index dfd6c10e426..dbd9f8c858b 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,6 +1,9 @@ erpnext.updates = [ ["22nd November 2012", [ "Support Ticket: Compose a reply using Markdown", + "Supplier Link Field: Search by Supplier Name instead of ID", + "Supplier Link Field: Show only ID in auto-suggest \ + if ID created using Supplier Name (as defined in Global Defaults)", ]], ["21st November 2012", [ "Tree Report: Added missing expand / collapse buttons.",