diff --git a/erpnext/accounts/__init__.py b/erpnext/accounts/__init__.py index 6934003957..c750d25462 100644 --- a/erpnext/accounts/__init__.py +++ b/erpnext/accounts/__init__.py @@ -19,8 +19,8 @@ from webnotes.utils import flt from webnotes.model.code import get_obj install_docs = [ - {"doctype":"Role", "name":"Accounts Manager"}, - {"doctype":"Role", "name":"Accounts User"} + {"doctype":"Role", "role_name":"Accounts Manager", "name":"Accounts Manager"}, + {"doctype":"Role", "role_name":"Accounts User", "name":"Accounts User"} ] @webnotes.whitelist() diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 11239d595d..f880eb7ecf 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -334,10 +334,9 @@ cur_frm.cscript.tax_code = function(doc, dt, dn) { } /* ***************************** UTILITY FUNCTIONS ************************ */ - // Calculate Advance // ------------------ -var calc_total_advance = function(doc,cdt,cdn) { +calc_total_advance = function(doc,cdt,cdn) { var doc = locals[doc.doctype][doc.name]; var el = getchildren('Purchase Invoice Advance',doc.name,'advance_allocation_details') var tot_tds=0; diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 6c956a0dae..1878526b61 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -193,9 +193,14 @@ class DocType(TransactionBase): item = webnotes.conn.sql("select default_income_account, default_sales_cost_center, default_warehouse from tabItem where name = '%s'" %(args['item_code']), as_dict=1) - ret['income_account'] = item and item[0]['default_income_account'] or dtl and dtl[0]['income_account'] or args['income_account'] - ret['cost_center'] = item and item[0]['default_sales_cost_center'] or dtl and dtl[0]['cost_center'] or args['cost_center'] - ret['warehouse'] = item and item[0]['default_warehouse'] or dtl and dtl[0]['warehouse'] or args['warehouse'] + ret['income_account'] = item and item[0].get('default_income_account') \ + or (dtl and dtl[0].get('income_account') or args.get('income_account')) + + ret['cost_center'] = item and item[0].get('default_sales_cost_center') \ + or (dtl and dtl[0].get('cost_center') or args.get('cost_center')) + + ret['warehouse'] = item and item[0].get('default_warehouse') \ + or (dtl and dtl[0].get('warehouse') or args.get('warehouse')) if ret['warehouse']: actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], ret['warehouse'])) diff --git a/erpnext/buying/__init__.py b/erpnext/buying/__init__.py index 8e18bc5a54..1bcab3d99c 100644 --- a/erpnext/buying/__init__.py +++ b/erpnext/buying/__init__.py @@ -1,6 +1,6 @@ install_docs = [ - {"doctype":"Role", "name":"Purchase Manager"}, - {"doctype":"Role", "name":"Purchase User"}, - {"doctype":"Role", "name":"Purchase Master Manager"}, - {"doctype":"Role", "name":"Supplier"} -] \ No newline at end of file + {"doctype":"Role", "role_name":"Purchase Manager", "name":"Purchase Manager"}, + {"doctype":"Role", "role_name":"Purchase User", "name":"Purchase User"}, + {"doctype":"Role", "role_name":"Purchase Master Manager", "name":"Purchase Master Manager"}, + {"doctype":"Role", "role_name":"Supplier", "name":"Supplier"} +] diff --git a/erpnext/hr/__init__.py b/erpnext/hr/__init__.py index ab2d1976b1..930b9eeeec 100644 --- a/erpnext/hr/__init__.py +++ b/erpnext/hr/__init__.py @@ -1,5 +1,5 @@ install_docs = [ - {"doctype":"Role", "name":"Employee"}, - {"doctype":"Role", "name":"HR Manager"}, - {"doctype":"Role", "name":"HR User"}, + {"doctype":"Role", "role_name":"Employee", "name":"Employee"}, + {"doctype":"Role", "role_name":"HR Manager", "name":"HR Manager"}, + {"doctype":"Role", "role_name":"HR User", "name":"HR User"}, ] diff --git a/erpnext/hr/page/hr_home/hr_home.html b/erpnext/hr/page/hr_home/hr_home.html index b49ce092d7..47e7e6734e 100644 --- a/erpnext/hr/page/hr_home/hr_home.html +++ b/erpnext/hr/page/hr_home/hr_home.html @@ -57,7 +57,7 @@
Holiday List + href="#!List/Holiday List">Holiday List
diff --git a/erpnext/patches/jan_mar_2012/rename_dt.py b/erpnext/patches/jan_mar_2012/rename_dt.py index 693fd77d0e..7847ee1d6b 100644 --- a/erpnext/patches/jan_mar_2012/rename_dt.py +++ b/erpnext/patches/jan_mar_2012/rename_dt.py @@ -129,7 +129,8 @@ def delete_search_criteria(): 'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order', 'sales_order1', 'sales_agentwise_commission', 'test_report', 'territory_wise_sales_-_target_vs_actual_', - 'pending_po_items_to_bill1', 'pending_po_items_to_receive1', 'expense_vouchers', 'pending_expense_vouchers')""") + 'pending_po_items_to_bill1', 'pending_po_items_to_receive1', + 'expense_vouchers', 'pending_expense_vouchers', 'shortage_to_indent')""") webnotes.conn.sql(""" DELETE FROM `tabSearch Criteria` diff --git a/erpnext/production/__init__.py b/erpnext/production/__init__.py index 4da0c58ae9..4fb00a34be 100644 --- a/erpnext/production/__init__.py +++ b/erpnext/production/__init__.py @@ -1,4 +1,4 @@ install_docs = [ - {"doctype":"Role", "name":"Production Manager"}, - {"doctype":"Role", "name":"Production User"}, + {"doctype":"Role", "role_name":"Production Manager", "name":"Production Manager"}, + {"doctype":"Role", "role_name":"Production User", "name":"Production User"}, ] diff --git a/erpnext/projects/__init__.py b/erpnext/projects/__init__.py index 636248f51f..61a6eb6a1a 100644 --- a/erpnext/projects/__init__.py +++ b/erpnext/projects/__init__.py @@ -1,3 +1,3 @@ install_docs = [ - {"doctype":"Role", "name":"Projects User"}, + {"doctype":"Role", "role_name":"Projects User", "name":"Projects User"}, ] diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index 801ba56881..faa175fded 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -52,4 +52,4 @@ cur_frm.cscript.project_value = function(doc, cdt, cdn){ //--------- calculate gross profit -------------------------------- cur_frm.cscript.est_material_cost = function(doc, cdt, cdn){ get_server_fields('get_gross_profit','','',doc, cdt, cdn, 1); -} \ No newline at end of file +} diff --git a/erpnext/projects/doctype/task/task.js b/erpnext/projects/doctype/task/task.js index c88382bf08..af4864bc44 100644 --- a/erpnext/projects/doctype/task/task.js +++ b/erpnext/projects/doctype/task/task.js @@ -119,4 +119,4 @@ cur_frm.cscript.declare_completed = function(){ cur_frm.cscript.refresh(cur_frm.doc, cur_frm.doc.doctype, cur_frm.doc.name); } }); -} \ No newline at end of file +} diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 51a9875183..9cca9a71e7 100644 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -51,7 +51,7 @@ class DocType: def get_allocated_to_name(self): as_em = sql("select first_name, last_name from `tabProfile` where name=%s",str(self.doc.allocated_to)) - ret = { 'allocated_to_name' : as_em and (as_em[0][0] + ' ' + as_em[0][1]) or ''} + ret = { 'allocated_to_name' : as_em and (cstr(as_em[0][0]) + ' ' + cstr(as_em[0][1])) or ''} return ret # validate @@ -95,7 +95,7 @@ class DocType: sql("delete from tabEvent where ref_type='Task' and ref_name=%s", self.doc.name) self.add_calendar_event() else: - msgprint("An Expeted start date has not been set for this task.Please set a, 'Expected Start date'\ + msgprint("An Expeted start date has not been set for this task.Please set 'Expected Start date'\ to add an event to allocated persons calender.You can save a task without this also.") diff --git a/erpnext/selling/__init__.py b/erpnext/selling/__init__.py index c61f23cc04..f8a457a4cf 100644 --- a/erpnext/selling/__init__.py +++ b/erpnext/selling/__init__.py @@ -1,7 +1,7 @@ install_docs = [ - {"doctype":"Role", "name":"Customer"}, - {"doctype":"Role", "name":"Partner"}, - {"doctype":"Role", "name":"Sales Manager"}, - {"doctype":"Role", "name":"Sales Master Manager"}, - {"doctype":"Role", "name":"Sales User"}, + {"doctype":"Role", "role_name":"Customer", "name":"Customer"}, + {"doctype":"Role", "role_name":"Partner", "name":"Partner"}, + {"doctype":"Role", "role_name":"Sales Manager", "name":"Sales Manager"}, + {"doctype":"Role", "role_name":"Sales Master Manager", "name":"Sales Master Manager"}, + {"doctype":"Role", "role_name":"Sales User", "name":"Sales User"}, ] diff --git a/erpnext/setup/__init__.py b/erpnext/setup/__init__.py index dad187308d..c4b3773744 100644 --- a/erpnext/setup/__init__.py +++ b/erpnext/setup/__init__.py @@ -1,3 +1,3 @@ install_docs = [ - {'doctype':'Role', 'name': 'System Manager'} -] \ No newline at end of file + {'doctype':'Role', 'role_name': 'System Manager', 'name': 'System Manager'} +] diff --git a/erpnext/startup/js/feature_setup.js b/erpnext/startup/js/feature_setup.js index b929a7cec6..f7fdb26d50 100644 --- a/erpnext/startup/js/feature_setup.js +++ b/erpnext/startup/js/feature_setup.js @@ -30,10 +30,10 @@ pscript.feature_dict = { 'fs_projects': { 'BOM': {'fields':['project_name']}, 'Delivery Note': {'fields':['project_name']}, - 'Purchase Invoice': {'fields':['project_name']}, + 'Purchase Invoice': {'entries':['project_name']}, 'Production Order': {'fields':['project_name']}, - 'Purchase Order': {'fields':['project_name']}, - 'Purchase Receipt': {'fields':['project_name']}, + 'Purchase Order': {'po_details':['project_name']}, + 'Purchase Receipt': {'purchase_receipt_details':['project_name']}, 'Sales Invoice': {'fields':['project_name']}, 'Sales Order': {'fields':['project_name']}, 'Stock Entry': {'fields':['project_name']}, diff --git a/erpnext/stock/__init__.py b/erpnext/stock/__init__.py index ee2b061cdc..f171425006 100644 --- a/erpnext/stock/__init__.py +++ b/erpnext/stock/__init__.py @@ -1,6 +1,6 @@ install_docs = [ - {"doctype":"Role", "name":"Material Manager"}, - {"doctype":"Role", "name":"Material Master Manager"}, - {"doctype":"Role", "name":"Material User"}, - {"doctype":"Role", "name":"Quality Manager"}, + {"doctype":"Role", "role_name":"Material Manager", "name":"Material Manager"}, + {"doctype":"Role", "role_name":"Material Master Manager", "name":"Material Master Manager"}, + {"doctype":"Role", "role_name":"Material User", "name":"Material User"}, + {"doctype":"Role", "role_name":"Quality Manager", "name":"Quality Manager"}, ] diff --git a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js index 771cb8272c..19cec92a2e 100644 --- a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js +++ b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js @@ -44,17 +44,17 @@ cur_frm.fields_dict.purchase_receipt_no.get_query = function(doc) { cur_frm.cscript.return_type = function(doc, cdt, cdn) { var cp = wn.control_panel; hide_field(['purchase_receipt_no', 'delivery_note_no', 'sales_invoice_no', - 'return_details', 'Get Items', 'Make Excise Invoice', 'Make Stock Entry', + 'return_details', 'get_items', 'Make Excise Invoice', 'Make Stock Entry', 'Make Debit Note', 'Make Credit Note']); if(doc.return_type == 'Sales Return') { - unhide_field(['delivery_note_no', 'sales_invoice_no', 'Get Items', + unhide_field(['delivery_note_no', 'sales_invoice_no', 'get_items', 'return_details', 'Make Credit Note', 'Make Stock Entry']); if(cp.country == 'India') { unhide_field(['Make Excise Invoice']); } } else if(doc.return_type == 'Purchase Return') { - unhide_field(['purchase_receipt_no', 'Get Items', 'return_details', + unhide_field(['purchase_receipt_no', 'get_items', 'return_details', 'Make Debit Note', 'Make Stock Entry']); if(cp.country == 'India') { unhide_field(['Make Excise Invoice']); } diff --git a/erpnext/support/__init__.py b/erpnext/support/__init__.py index b94538b23f..71ef684bb1 100644 --- a/erpnext/support/__init__.py +++ b/erpnext/support/__init__.py @@ -1,6 +1,6 @@ install_docs = [ - {'doctype':'Role', 'name':'Support Team'}, - {'doctype':'Role', 'name':'Support Manager'}, - {'doctype':'Role', 'name':'Maintenance User'}, - {'doctype':'Role', 'name':'Maintenance Manager'} -] \ No newline at end of file + {'doctype':'Role', 'role_name':'Support Team', 'name':'Support Team'}, + {'doctype':'Role', 'role_name':'Support Manager', 'name':'Support Manager'}, + {'doctype':'Role', 'role_name':'Maintenance User', 'name':'Maintenance User'}, + {'doctype':'Role', 'role_name':'Maintenance Manager', 'name':'Maintenance Manager'} +] diff --git a/erpnext/support/doctype/support_ticket/listview.js b/erpnext/support/doctype/support_ticket/listview.js index 67ba9ea457..944c08fb4f 100644 --- a/erpnext/support/doctype/support_ticket/listview.js +++ b/erpnext/support/doctype/support_ticket/listview.js @@ -10,6 +10,7 @@ wn.doclistviews['Support Ticket'] = wn.views.ListView.extend({ "`tabSupport Ticket`.description" ]); this.stats = this.stats.concat(['status']); + this.show_hide_check_column(); }, prepare_data: function(data) { @@ -43,9 +44,10 @@ wn.doclistviews['Support Ticket'] = wn.views.ListView.extend({ }, columns: [ + {width: '3%', content:'check'}, {width: '20%', content:'name'}, {width: '10%', content:'status_html'}, - {width: '56%', content:'tags+description', css: {color:'#aaa'}}, + {width: '53%', content:'tags+description', css: {color:'#aaa'}}, {width: '14%', content:'modified', css: {'text-align': 'right', 'color':'#777'}} ] diff --git a/erpnext/website/__init__.py b/erpnext/website/__init__.py index 1ed1cf1818..97062cffc3 100644 --- a/erpnext/website/__init__.py +++ b/erpnext/website/__init__.py @@ -1,4 +1,4 @@ install_docs = [ - {"doctype":"Role", "name":"Blogger"}, - {"doctype":"Role", "name":"Website Manager"}, -] \ No newline at end of file + {"doctype":"Role", "role_name":"Blogger", "name":"Blogger"}, + {"doctype":"Role", "role_name":"Website Manager", "name":"Website Manager"}, +] diff --git a/js/all-app.js b/js/all-app.js index c53302a49d..769d6caf70 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -290,7 +290,7 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico if(icon){$('').addClass(icon).appendTo($button);} $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);} if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');} -if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){wn.views.formview.create(me.new_doctype)},'icon-plus');} +if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');} if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');} if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') this.onrun=a0;if(a0&&a0.callback) @@ -402,7 +402,7 @@ args.label=v[0];args.width=flt(v[1])/max*100;args.count=v[1];args.field=field;$i %(label)s \ (%(count)s)\ ',args));this.setup_stat_item_click($item);return $item;},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}} -this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});} +this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});} if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;} if(typeof opts.content=='function'){opts.content(parent,data);} else if(opts.content=='name'){$(parent).append(repl('%(name)s',data));} @@ -423,7 +423,7 @@ else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:f if(diff==1){data.when='Yesterday'} if(diff==2){data.when='2 days ago'} if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){$.each(data._user_tags.split(','),function(i,t){if(t){$('' -+strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}}}) ++strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}}) /* * lib/js/wn/views/pageview.js */ @@ -2227,7 +2227,7 @@ if(user_roles.indexOf("System Manager")!=-1){$('.navbar .modules').append('
  • ').addClass(icon).appendTo($button);} $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);} if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');} -if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){wn.views.formview.create(me.new_doctype)},'icon-plus');} +if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');} if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');} if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') this.onrun=a0;if(a0&&a0.callback) @@ -289,7 +289,7 @@ args.label=v[0];args.width=flt(v[1])/max*100;args.count=v[1];args.field=field;$i %(label)s \ (%(count)s)\ ',args));this.setup_stat_item_click($item);return $item;},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}} -this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});} +this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});} if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;} if(typeof opts.content=='function'){opts.content(parent,data);} else if(opts.content=='name'){$(parent).append(repl('%(name)s',data));} @@ -310,7 +310,7 @@ else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:f if(diff==1){data.when='Yesterday'} if(diff==2){data.when='2 days ago'} if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){$.each(data._user_tags.split(','),function(i,t){if(t){$('' -+strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}}}) ++strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}}) /* * lib/js/wn/views/pageview.js */ @@ -686,7 +686,7 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico if(icon){$('').addClass(icon).appendTo($button);} $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);} if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');} -if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){wn.views.formview.create(me.new_doctype)},'icon-plus');} +if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');} if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');} if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') this.onrun=a0;if(a0&&a0.callback)