Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index ada4beb..bf2cbce 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -23,7 +23,11 @@
wn.require("app/js/transaction.js");
erpnext.buying.BuyingController = erpnext.TransactionController.extend({
- setup: function() {
+ onload: function() {
+ this.setup_queries();
+ },
+
+ setup_queries: function() {
var me = this;
if(this.frm.fields_dict.price_list_name) {
@@ -473,15 +477,5 @@
}
});
-// to save previous state of cur_frm.cscript
-var prev_cscript = {};
-$.extend(prev_cscript, cur_frm.cscript);
-
-cur_frm.cscript = new erpnext.buying.BuyingController({frm: cur_frm});
-
-// for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, prev_cscript);
-
-
var tname = cur_frm.cscript.tname;
var fname = cur_frm.cscript.fname;
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index 0649f54..f108271 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -15,12 +15,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Module CRM
+// =====================================================================================
cur_frm.cscript.tname = "Quotation Item";
cur_frm.cscript.fname = "quotation_details";
cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
-// =====================================================================================
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/selling/doctype/sales_common/sales_common.js');
@@ -107,8 +107,7 @@
},
});
-// for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new erpnext.selling.QuotationController({frm: cur_frm}));
+cur_frm.script_manager.make(erpnext.selling.QuotationController);
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({
@@ -180,31 +179,6 @@
}
-//================ Last Quoted Price and Last Sold Price suggestion ======================
-cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- var cond = (doc.order_type == 'Maintenance') ? " and item.is_service_item = 'Yes'" : " and item.is_sales_item = 'Yes'";
- if(doc.customer) {
- var export_rate_field = wn.meta.get_docfield(cdt, 'export_rate', cdn);
- var precision = (export_rate_field && export_rate_field.fieldtype) === 'Float' ? 6 : 2;
- return {
- query: "selling.doctype.quotation.quotation.quotation_details",
- filters:{
- cust: doc.customer,
- cond: cond,
- precision: precision
- }
- }
- } else {
- return {
- query: 'selling.doctype.quotation.quotation.quotation_details',
- filters:{
- cond: cond
- }
- }
- }
-}
-
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
if(cint(wn.boot.notification_settings.quotation)) {
cur_frm.email_doc(wn.boot.notification_settings.quotation_message);
diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py
index ee4975d..f1e11a0 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -286,41 +286,3 @@
return customer
else:
raise e
-
-def quotation_details(doctype, txt, searchfield, start, page_len, filters):
- from controllers.queries import get_match_cond
-
- if filters.has_key('cust') and filters.has_key('precision'):
- return webnotes.conn.sql("""select item.name,
- (select concat('Last Quote @ ', q.currency, ' ',
- format(q_item.export_rate, %(precision)s))
- from `tabQuotation` q, `tabQuotation Item` q_item
- where q.name = q_item.parent
- and q_item.item_code = item.name
- and q.docstatus = 1
- and q.customer = "%(cust)s"
- order by q.transaction_date desc
- limit 1) as quote_rate,
- (select concat('Last Sale @ ', si.currency, ' ',
- format(si_item.basic_rate, %(precision)s))
- from `tabSales Invoice` si, `tabSales Invoice Item` si_item
- where si.name = si_item.parent
- and si_item.item_code = item.name
- and si.docstatus = 1
- and si.customer ="%(cust)s"
- order by si.posting_date desc
- limit 1) as sales_rate,
- item.item_name, item.description
- from `tabItem` item
- where %(cond)s %(mcond)s
- and item.%(searchfield)s like '%(txt)s'
- order by item.name desc limit %(start)s, %(page_len)s """ % {'precision': filters["precision"],
- 'cust': filters['cust'], 'cond': filters['cond'], 'searchfield': searchfield,
- 'txt': "%%%s%%" % txt, 'mcond': get_match_cond(doctype, searchfield),
- 'start': start, 'page_len': page_len})
-
- else:
- return webnotes.conn.sql(""" select name, item_name, description from `tabItem` item
- where %s %s and %s like %s order by name desc limit %s, %s""" %
- ("%s", get_match_cond(doctype, searchfield), searchfield, "%s", "%s", "%s"),
- (filters["cond"], "%%%s%%" % txt, start, page_len))
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index 8d86950..01ea8f5 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -25,7 +25,13 @@
wn.require("app/js/transaction.js");
erpnext.selling.SellingController = erpnext.TransactionController.extend({
- setup: function() {
+ onload: function() {
+ this._super();
+ this.toggle_rounded_total();
+ this.setup_queries();
+ },
+
+ setup_queries: function() {
var me = this;
this.frm.add_fetch("sales_partner", "commission_rate", "commission_rate");
@@ -64,18 +70,19 @@
this.frm.fields_dict.lead && this.frm.set_query("lead", function(doc,cdt,cdn) {
return{ query:"controllers.queries.lead_query" } });
-
+
if(!this.fname) {
return;
}
if(this.frm.fields_dict[this.fname].grid.get_field('item_code')) {
this.frm.set_query("item_code", this.fname, function() {
- return me.frm.doc.order_type === "Maintenance" ?
- { query:"controllers.queries.item_query",
- filters:{'is_service_item': 'Yes'}} :
- { query:"controllers.queries.item_query",
- filters:{'is_sales_item': 'Yes' }} ;
+ return {
+ query: "controllers.queries.item_query",
+ filters: (me.frm.doc.order_type === "Maintenance" ?
+ {'is_service_item': 'Yes'}:
+ {'is_sales_item': 'Yes' })
+ }
});
}
@@ -108,11 +115,6 @@
}
},
- onload: function() {
- this._super();
- this.toggle_rounded_total();
- },
-
refresh: function(doc) {
this.frm.toggle_display("customer_name",
(this.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer));
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index cbcd488..8fa99b8 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -90,7 +90,7 @@
"""
customer_defaults = self.get_customer_defaults()
- customer_defaults["price_list"] = customer_defaults["price_list"] or \
+ customer_defaults["price_list"] = customer_defaults.get("price_list") or \
webnotes.conn.get_value("Customer Group", self.doc.customer_group, "default_price_list") or \
self.doc.price_list