Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index c802622..90239fa 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -197,10 +197,6 @@
cur_frm.cscript.hide_fields(doc, dt, dn);
}
-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);
-}
-
cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
cl = getchildren('Sales Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index f108271..af49bb3 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -109,14 +109,6 @@
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({
- customer: doc.customer,
- address: doc.customer_address,
- contact: doc.contact_person
- }),'', doc, dt, dn, 1);
-}
-
cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.lead_query" } }
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index 01ea8f5..919de22 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -58,7 +58,6 @@
return {
filters: [
['Sales Taxes and Charges Master', 'company', '=', me.frm.doc.company],
- ['Sales Taxes and Charges Master', 'company', 'is not', 'NULL'],
['Sales Taxes and Charges Master', 'docstatus', '!=', 2]
]
}
@@ -146,6 +145,29 @@
}
},
+ customer_address: function() {
+ var me = this;
+ if(this.frm.doc.customer) {
+ this.frm.call({
+ doc: this.frm.doc,
+ args: {
+ customer: this.frm.doc.customer,
+ address: this.frm.doc.customer_address,
+ contact: this.frm.doc.contact_person
+ },
+ method: "get_customer_address",
+ freeze: true,
+ callback: function(r) {
+ me.frm.refresh_fields();
+ }
+ });
+ }
+ },
+
+ contact_person: function() {
+ this.customer_address();
+ },
+
barcode: function(doc, cdt, cdn) {
this.item_code(doc, cdt, cdn);
},
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index 509ecf7..4368d5b 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -141,11 +141,6 @@
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
-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);
-}
-
-
cur_frm.cscript.new_contact = function(){
tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_customer = 1;
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index 38f7d7b..be57853 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -80,27 +80,11 @@
def validate_for_items(self):
check_list, flag = [], 0
chk_dupl_itm = []
- # Sales Order Items Validations
for d in getlist(self.doclist, 'sales_order_details'):
- if self.doc.quotation_no and cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname):
- flag = 1
- if d.prevdoc_docname:
- if self.doc.quotation_date and getdate(self.doc.quotation_date) > getdate(self.doc.transaction_date):
- msgprint("Sales Order Date cannot be before Quotation Date")
- raise Exception
- # validates whether quotation no in doctype and in table is same
- if not cstr(d.prevdoc_docname) == cstr(self.doc.quotation_no):
- msgprint("Items in table does not belong to the Quotation No mentioned.")
- raise Exception
-
- # validates whether item is not entered twice
e = [d.item_code, d.description, d.reserved_warehouse, d.prevdoc_docname or '']
f = [d.item_code, d.description]
- #check item is stock item
- st_itm = sql("select is_stock_item from `tabItem` where name = %s", d.item_code)
-
- if st_itm and st_itm[0][0] == 'Yes':
+ if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
if not d.reserved_warehouse:
msgprint("""Please enter Reserved Warehouse for item %s
as it is stock Item""" % d.item_code, raise_exception=1)
@@ -109,7 +93,7 @@
msgprint("Item %s has been entered twice." % d.item_code)
else:
check_list.append(e)
- elif st_itm and st_itm[0][0]== 'No':
+ else:
if f in chk_dupl_itm:
msgprint("Item %s has been entered twice." % d.item_code)
else:
@@ -121,9 +105,6 @@
tot_avail_qty = sql("select projected_qty from `tabBin` \
where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
-
- if getlist(self.doclist, 'sales_order_details') and self.doc.quotation_no and flag == 0:
- msgprint("There are no items of the quotation selected", raise_exception=1)
def validate_sales_mntc_quotation(self):
for d in getlist(self.doclist, 'sales_order_details'):
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 62d6529..e93e6d3 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -92,10 +92,6 @@
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm}));
-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);
-}
-
cur_frm.cscript.new_contact = function(){
tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_customer = 1;
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index 502e30f..77038bb 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -58,14 +58,6 @@
"""Get Commission rate of Sales Partner"""
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
- def validate_prev_docname(self):
- """Validates that Sales Order is not pulled twice"""
- for d in getlist(self.doclist, 'delivery_note_details'):
- if self.doc.sales_order_no == d.prevdoc_docname:
- msgprint(cstr(self.doc.sales_order_no) + " sales order details have already been pulled. ")
- raise Exception, "Validation Error. "
-
-
def set_actual_qty(self):
for d in getlist(self.doclist, 'delivery_note_details'):
if d.item_code and d.warehouse:
@@ -246,7 +238,6 @@
d.fields.get('packed_qty', 0)
])
if packing_error_list:
- from webnotes.utils import cstr
err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
+ ", Packed: " + cstr(d[2])) for d in packing_error_list])
webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 8fa99b8..ed404dd 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -145,9 +145,9 @@
'customer_address' : args["address"],
'address_display' : get_address_display(args["address"]),
}
+ if args.get('contact'):
+ ret.update(map_party_contact_details(args['contact']))
- ret.update(map_party_contact_details(args['contact']))
-
return ret
# TODO deprecate this - used only in sales_order.js
@@ -347,7 +347,7 @@
def get_address_display(address_dict):
if not isinstance(address_dict, dict):
- address_dict = webnotes.conn.get_value("Address", address_dict, "*", as_dict=True)
+ address_dict = webnotes.conn.get_value("Address", address_dict, "*", as_dict=True) or {}
meta = webnotes.get_doctype("Address")
sequence = (("", "address_line1"), ("\n", "address_line2"), ("\n", "city"),
@@ -386,23 +386,23 @@
if not contact_name:
contact_name = get_default_contact(party_field, party_name)
+ if party_field:
+ contact = webnotes.conn.sql("""select * from `tabContact` where `%s`=%s
+ order by is_primary_contact desc, name asc limit 1""" % (party_field, "%s"),
+ (party_name,), as_dict=True)
- contact = webnotes.conn.sql("""select * from `tabContact` where `%s`=%s
- order by is_primary_contact desc, name asc limit 1""" % (party_field, "%s"),
- (party_name,), as_dict=True)
-
- if contact:
- contact = contact[0]
- out.update({
- "contact_person": contact.get("name"),
- "contact_display": " ".join(filter(None,
- [contact.get("first_name"), contact.get("last_name")])),
- "contact_email": contact.get("email_id"),
- "contact_mobile": contact.get("mobile_no"),
- "contact_phone": contact.get("phone"),
- "contact_designation": contact.get("designation"),
- "contact_department": contact.get("department")
- })
+ if contact:
+ contact = contact[0]
+ out.update({
+ "contact_person": contact.get("name"),
+ "contact_display": " ".join(filter(None,
+ [contact.get("first_name"), contact.get("last_name")])),
+ "contact_email": contact.get("email_id"),
+ "contact_mobile": contact.get("mobile_no"),
+ "contact_phone": contact.get("phone"),
+ "contact_designation": contact.get("designation"),
+ "contact_department": contact.get("department")
+ })
return out