diff --git a/css/all-app.css b/css/all-app.css
index 367404c54ae..f706a03f00d 100644
--- a/css/all-app.css
+++ b/css/all-app.css
@@ -1577,6 +1577,11 @@ div.list-row:hover {
background-color: #eef
}
+div.paging-button {
+ text-align: center;
+ padding: 11px 0px;
+}
+
div.show_filters {
display: none;
}
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index c86c6805109..972a4671ab7 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -108,12 +108,19 @@ cur_frm.cscript.customer = function(doc,dt,dn) {
cur_frm.refresh();
}
- if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
- if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+ if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
+ 'get_default_customer_address', '', callback);
+ if(doc.customer) unhide_field(['customer_address','contact_person','customer_name',
+ 'address_display','contact_display','contact_mobile','contact_email','territory',
+ 'customer_group']);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
- if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+ if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({
+ customer: doc.customer,
+ address: doc.customer_address,
+ contact: doc.contact_person
+ }),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index fe3ba286897..deec159c5b9 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -212,13 +212,16 @@ cur_frm.cscript.price_list_currency = cur_frm.cscript.currency;
cur_frm.cscript.conversion_rate = cur_frm.cscript.currency;
cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency;
-cur_frm.cscript.company = function(doc, dt, dn) {
+cur_frm.cscript.company = function(doc, cdt, cdn) {
wn.call({
method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
args: {company:doc.company},
callback: function(r, rt) {
- var doc = locals[dt][dn];
- set_multiple(doc.doctype, doc.name, {currency:r.message, price_list_currency:r.message});
+ var doc = locals[cdt][cdn];
+ set_multiple(doc.doctype, doc.name, {
+ currency:r.message,
+ price_list_currency:r.message
+ });
cur_frm.cscript.currency(doc, cdt, cdn);
}
});
@@ -249,9 +252,20 @@ cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
// ******************** ITEM CODE ********************************
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
if (doc.order_type == 'Maintenance')
- return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 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" LIMIT 50';
+ return 'SELECT tabItem.name,tabItem.item_name,tabItem.description \
+ FROM tabItem WHERE tabItem.is_service_item="Yes" \
+ AND tabItem.docstatus != 2 \
+ 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" LIMIT 50';
else
- return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 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" LIMIT 50';
+ return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem \
+ WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 \
+ 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" LIMIT 50';
}
@@ -267,8 +281,14 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var callback = function(r, rt){
cur_frm.cscript.recalc(doc, 1);
}
- var args = {'item_code':d.item_code, 'income_account':d.income_account, 'cost_center': d.cost_center, 'warehouse': d.warehouse};
- get_server_fields('get_item_details',JSON.stringify(args), fname,doc,cdt,cdn,1,callback);
+ var args = {
+ 'item_code':d.item_code,
+ 'income_account':d.income_account,
+ 'cost_center': d.cost_center,
+ 'warehouse': d.warehouse
+ };
+ get_server_fields('get_item_details',JSON.stringify(args),
+ fname,doc,cdt,cdn,1,callback);
}
}
if(cur_frm.cscript.custom_item_code){
@@ -358,8 +378,14 @@ cur_frm.cscript.recalc = function(doc, n) {
var sales_team = cur_frm.cscript.sales_team_fname;
var other_fname = cur_frm.cscript.other_fname;
- if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); }
- if(!flt(doc.plc_conversion_rate)) { doc.plc_conversion_rate = 1; refresh_field('plc_conversion_rate'); }
+ if(!flt(doc.conversion_rate)) {
+ doc.conversion_rate = 1;
+ refresh_field('conversion_rate');
+ }
+ if(!flt(doc.plc_conversion_rate)) {
+ doc.plc_conversion_rate = 1;
+ refresh_field('plc_conversion_rate');
+ }
if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n, other_fname); // updates all values in table (i.e. amount, export amount, net total etc.)
@@ -378,7 +404,7 @@ cur_frm.cscript.recalc = function(doc, n) {
}
cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
}
- cur_frm.cscript.calc_doc_values(doc, cdt, cdn, tname, fname, other_fname); // calculates total amounts
+ cur_frm.cscript.calc_doc_values(doc, null, null, tname, fname, other_fname); // calculates total amounts
// ******************* calculate allocated amount of sales person ************************
cl = getchildren('Sales Team', doc.name, sales_team);
diff --git a/js/all-app.js b/js/all-app.js
index 4d808ac17a5..356ac166ea3 100644
--- a/js/all-app.js
+++ b/js/all-app.js
@@ -587,13 +587,13 @@ if(this.input.focus){try{this.input.focus();}catch(e){}}}
if(this.txt){try{this.txt.focus();}catch(e){}
this.txt.field_object=this;}}
function DataField(){}DataField.prototype=new Field();DataField.prototype.make_input=function(){var me=this;this.input=$a_input(this.input_area,this.df.fieldtype=='Password'?'password':'text');this.get_value=function(){var v=this.input.value;if(this.validate)v=this.validate(v);return v;}
-this.input.name=this.df.fieldname;this.set_value=function(val){if(!me.last_value)me.last_value='';if(me.validate){val=me.validate(val);me.input.value=val;}
+this.input.name=this.df.fieldname;$(this.input).change(function(){me.set_value($(this).val());});this.set_value=function(val){if(!me.last_value)me.last_value='';if(me.validate){val=me.validate(val);me.input.value=val;}
me.set(val);if(me.format_input)
me.format_input();if(in_list(['Currency','Float','Int'],me.df.fieldtype)){if(flt(me.last_value)==flt(val)){me.last_value=val;return;}}
me.last_value=val;me.run_trigger();}
this.input.set_input=function(val){if(val==null)val='';me.input.value=val;if(me.format_input)me.format_input();}
if(this.df.options=='Suggest'){if(this.suggest_icon)$di(this.suggest_icon);$(me.input).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':repl('SELECT DISTINCT `%(fieldname)s` FROM \
- `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});},select:function(event,ui){me.set_value(ui.item.value);return false;}});}}
+ `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});},select:function(event,ui){me.set_input_value(ui.item.value);return false;}});}}
DataField.prototype.validate=function(v){if(this.df.options=='Phone'){if(v+''=='')return'';v1=''
v=v.replace(/ /g,'').replace(/-/g,'').replace(/\(/g,'').replace(/\)/g,'');if(v&&v.substr(0,1)=='+'){v1='+';v=v.substr(1);}
if(v&&v.substr(0,2)=='00'){v1+='00';v=v.substr(2);}
@@ -636,7 +636,6 @@ var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(selector&&selector.display)return;if(r.message=='Ok'){if(r.fetch_values)
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('Click here to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
msgprint(repl('error:%(val)s is not a valid %(dt)s. You must first create a new %(dt)s %(val)s and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s',{val:me.txt.value,dt:get_doctype_label(me.df.options),add:astr}));me.txt.value='';me.set('');}});}
-LinkField.prototype.set_onchange=function(){var me=this;$(me.txt).change(function(event){});}
LinkField.prototype.set_fetch_values=function(fetch_values){var fl=cur_frm.fetch_dict[this.df.fieldname].fields;var changed_fields=[];for(var i=0;iClick here to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
msgprint(repl('error:%(val)s is not a valid %(dt)s. You must first create a new %(dt)s %(val)s and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s',{val:me.txt.value,dt:get_doctype_label(me.df.options),add:astr}));me.txt.value='';me.set('');}});}
-LinkField.prototype.set_onchange=function(){var me=this;$(me.txt).change(function(event){});}
LinkField.prototype.set_fetch_values=function(fetch_values){var fl=cur_frm.fetch_dict[this.df.fieldname].fields;var changed_fields=[];for(var i=0;iClick here to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
msgprint(repl('error:%(val)s is not a valid %(dt)s. You must first create a new %(dt)s %(val)s and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s',{val:me.txt.value,dt:get_doctype_label(me.df.options),add:astr}));me.txt.value='';me.set('');}});}
-LinkField.prototype.set_onchange=function(){var me=this;$(me.txt).change(function(event){});}
LinkField.prototype.set_fetch_values=function(fetch_values){var fl=cur_frm.fetch_dict[this.df.fieldname].fields;var changed_fields=[];for(var i=0;i\
\
-
\
+
\
\
\
- \
- More...
\
+ \
+ More...
\
\
\
',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},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-refresh').click(function(){me.run();});this.$w.find('.btn-more').click(function(){me.run({append:true});});this.$w.find('.btn-list').click(function(){me.show_view($(this),me.$w.find('.result-list'),me.$w.find('.btn-grid'),me.$w.find('.result-grid'))});this.$w.find('.btn-grid').click(function(){me.show_view($(this),me.$w.find('.result-grid'),me.$w.find('.btn-list'),me.$w.find('.result-list'))});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
-if(this.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype);})}else{this.$w.find('.btn-new').toggle(false).attr('hidden','true');}
-if(!me.show_filters){this.$w.find('.btn-filter').toggle(false).attr('hidden','true');}
-if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').toggle(false).attr('hidden','true');}
+if(this.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype);})}else{this.$w.find('.btn-new').toggle(false).attr('hidden','hidden');}
+if(!me.show_filters){this.$w.find('.btn-filter').toggle(false).attr('hidden','hidden');}
+if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').toggle(false).attr('hidden','hidden');}
if(this.show_grid){this.$w.find('.select-view').toggle(true);}
-if(this.$w.find('.list-toolbar [hidden!="true"]').length>1){this.$w.find('.list-toolbar').addClass('btn-group')}},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')
+if(this.$w.find('.list-toolbar a[hidden!="hidden"]').length>1){this.$w.find('.list-toolbar').addClass('btn-group')}},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)
-this.onrun=a0.callback;if(!a1||(a0&&a0.append))
+this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
this.start=0;me.$w.find('.img-load').toggle(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.$w.find('.img-load').toggle(false);me.render_results(r)},no_spinner:this.opts.no_loading,btn:this.run_btn});},get_call_args:function(){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
if(this.args)
@@ -834,7 +833,7 @@ var docname=history_get_name(t);if(t[0]=='Form'){_history_current=newLocation;if
/*
* lib/js/legacy/webpage/search.js
*/
-search_fields={};function setlinkvalue(name){selector.input.set_input(name);selector.hide();}
+search_fields={};function setlinkvalue(name){selector.input.set_input_value(name);selector.hide();}
function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Help'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;}
d.style='Link';d.set_query_description()
if(!d.sel_type)d.sel_type='Value';d.set_title('Select a "'+d.sel_type+'" for field "'+label+'"');}
@@ -848,8 +847,7 @@ inp.value='';if(d.input&&d.input.txt.value){inp.value=d.input.txt.value;}
try{inp.focus();}catch(e){}
if(d.input)d.input.set_get_query();var get_sf_list=function(dt){var l=[];var lf=search_fields[dt];for(var i=0;i