Merge pull request #16435 from deepeshgarg007/support-fix

fix(accounts_receivable): Bug fix in accounts receivable report
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 7348e1f..287da08 100755
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -250,10 +250,12 @@
 
 	cond = "1=1"
 	if pos_profile.get('update_stock') and pos_profile.get('warehouse'):
-		cond = "warehouse = '{0}'".format(pos_profile.get('warehouse'))
+		cond = "warehouse = %(warehouse)s"
 
-	serial_nos = frappe.db.sql("""select name, warehouse, item_code from `tabSerial No` where {0}
-				and company = %(company)s """.format(cond), {'company': company}, as_dict=1)
+	serial_nos = frappe.db.sql("""select name, warehouse, item_code
+		from `tabSerial No` where {0} and company = %(company)s """.format(cond),{
+			'company': company, 'warehouse': frappe.db.escape(pos_profile.get('warehouse'))
+		}, as_dict=1)
 
 	itemwise_serial_no = {}
 	for sn in serial_nos:
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js
index 7b2f9a4..22d74e8 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.js
+++ b/erpnext/manufacturing/doctype/work_order/work_order.js
@@ -349,7 +349,8 @@
 	before_submit: function(frm) {
 		frm.toggle_reqd(["fg_warehouse", "wip_warehouse"], true);
 		frm.fields_dict.required_items.grid.toggle_reqd("source_warehouse", true);
-		frm.toggle_reqd("transfer_material_against", frm.doc.operations);
+		frm.toggle_reqd("transfer_material_against",
+			frm.doc.operations && frm.doc.operations.length > 0);
 		frm.fields_dict.operations.grid.toggle_reqd("workstation", frm.doc.operations);
 	},
 
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index cefdbe7..cb9c23b 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -28,7 +28,10 @@
 
 		if (this.frm.doc.__islocal
 			&& frappe.meta.has_field(this.frm.doc.doctype, "disable_rounded_total")) {
-			this.frm.set_value("disable_rounded_total", cint(frappe.sys_defaults.disable_rounded_total));
+
+				var df = frappe.meta.get_docfield(this.frm.doc.doctype, "disable_rounded_total");
+				var disable = df.default || cint(frappe.sys_defaults.disable_rounded_total);
+				this.frm.set_value("disable_rounded_total", disable);
 		}
 
 		/* eslint-disable */
@@ -119,7 +122,7 @@
 		if (doc.doctype == "Purchase Order" && item.blanket_order_rate) {
 			item_rate = item.blanket_order_rate;
 		}
-		item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100;		
+		item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100;
 		item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item));
 
 		this.calculate_taxes_and_totals();
@@ -266,26 +269,26 @@
 								d.qty = d.qty  - my_qty;
 								cur_frm.doc.items[i].stock_qty = my_qty*cur_frm.doc.items[i].conversion_factor;
 								cur_frm.doc.items[i].qty = my_qty;
-	
+
 								frappe.msgprint("Assigning " + d.mr_name + " to " + d.item_code + " (row " + cur_frm.doc.items[i].idx + ")");
 								if (qty > 0)
 								{
 									frappe.msgprint("Splitting " + qty + " units of " + d.item_code);
 									var newrow = frappe.model.add_child(cur_frm.doc, cur_frm.doc.items[i].doctype, "items");
 									item_length++;
-	
+
 									for (var key in cur_frm.doc.items[i])
 									{
 										newrow[key] = cur_frm.doc.items[i][key];
 									}
-	
+
 									newrow.idx = item_length;
 									newrow["stock_qty"] = newrow.conversion_factor*qty;
 									newrow["qty"] = qty;
-	
+
 									newrow["material_request"] = "";
 									newrow["material_request_item"] = "";
-	
+
 								}
 							}
 						});
@@ -302,7 +305,7 @@
 		if (doc.auto_repeat) {
 			frappe.call({
 				method:"frappe.desk.doctype.auto_repeat.auto_repeat.update_reference",
-				args:{ 
+				args:{
 					docname: doc.auto_repeat,
 					reference:doc.name
 				},
@@ -427,4 +430,3 @@
 	});
 	dialog.show();
 }
-
diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.json b/erpnext/setup/doctype/authorization_rule/authorization_rule.json
index e70bf5c..caca56c 100644
--- a/erpnext/setup/doctype/authorization_rule/authorization_rule.json
+++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
  "allow_guest_to_view": 0, 
  "allow_import": 1, 
  "allow_rename": 0, 
@@ -352,7 +353,7 @@
    "fieldname": "to_emp", 
    "fieldtype": "Link", 
    "hidden": 0, 
-   "ignore_user_permissions": 0, 
+   "ignore_user_permissions": 1, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_global_search": 0, 
@@ -618,7 +619,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-08-21 16:15:42.627233", 
+ "modified": "2019-01-21 17:10:39.822125", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Authorization Rule",