Merge pull request #6249 from rohitwaghchaure/rfq_webform_issue

[RFQ] Web form alignment issue
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 93b058e..cbc8ad6 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.0.34'
+__version__ = '7.0.36'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/asset/asset.js b/erpnext/accounts/doctype/asset/asset.js
index 38be263..8ff4b83 100644
--- a/erpnext/accounts/doctype/asset/asset.js
+++ b/erpnext/accounts/doctype/asset/asset.js
@@ -18,7 +18,8 @@
 		frm.set_query("warehouse", function() {
 			return {
 				"filters": {
-					"company": frm.doc.company
+					"company": frm.doc.company,
+					"is_group": 0
 				}
 			};
 		});
@@ -232,7 +233,10 @@
 				"options": "Warehouse",
 				"get_query": function () {
 					return {
-						filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]]
+						filters: [
+							["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
+							["Warehouse", "is_group", "=", 0]
+						]
 					}
 				}, 
 				"reqd": 1 
diff --git a/erpnext/accounts/doctype/asset_movement/asset_movement.js b/erpnext/accounts/doctype/asset_movement/asset_movement.js
index 680eedc..808f01a 100644
--- a/erpnext/accounts/doctype/asset_movement/asset_movement.js
+++ b/erpnext/accounts/doctype/asset_movement/asset_movement.js
@@ -7,7 +7,10 @@
 		
 		frm.set_query("target_warehouse", function() {
 			return {
-				filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]]
+				filters: [
+					["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
+					["Warehouse", "is_group", "=", 0]
+				]
 			}
 		})
 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index c51231e..ccdd87f 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -340,14 +340,20 @@
 		$.each(["warehouse", "rejected_warehouse"], function(i, field) {
 			frm.set_query(field, "items", function() {
 				return {
-					filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]]
+					filters: [
+						["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
+						["Warehouse", "is_group", "=", 0]
+					]
 				}
 			})
 		})
 
 		frm.set_query("supplier_warehouse", function() {
 			return {
-				filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]]
+				filters: [
+					["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
+					["Warehouse", "is_group", "=", 0]
+				]
 			}
 		})
 	},
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
index 712d35b..75c3e8c 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
@@ -1,5 +1,5 @@
 <div style="margin-bottom: 7px;" class="text-center">
-	{%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}
+	{%= frappe.boot.letter_heads[frappe.get_doc(":Company", filters.company).default_letter_head || frappe.defaults.get_default("letter_head")] %}
 </div>
 <h2 class="text-center">{%= __(report.report_name) %}</h2>
 <h4 class="text-center">{%= filters.customer || filters.supplier %} </h4>
diff --git a/erpnext/accounts/report/financial_statements.html b/erpnext/accounts/report/financial_statements.html
index 84cad16..6959e5d 100644
--- a/erpnext/accounts/report/financial_statements.html
+++ b/erpnext/accounts/report/financial_statements.html
@@ -13,7 +13,9 @@
 		height: 37px;
 	}
 </style>
-
+<div style="margin-bottom: 7px;" class="text-center">
+	{%= frappe.boot.letter_heads[frappe.get_doc(":Company", filters.company).default_letter_head || frappe.defaults.get_default("letter_head")] %}
+</div>
 <h2 class="text-center">{%= __(report.report_name) %}</h2>
 <h4 class="text-center">{%= filters.company %}</h3>
 <h4 class="text-center">{%= filters.fiscal_year %}</h3>
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html
index f22e721..7552eed 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.html
+++ b/erpnext/accounts/report/general_ledger/general_ledger.html
@@ -1,5 +1,5 @@
 <div style="margin-bottom: 7px;" class="text-center">
-	{%= frappe.boot.letter_heads[filters.letter_head || frappe.defaults.get_default("letter_head")] %}
+	{%= frappe.boot.letter_heads[filters.letter_head || frappe.get_doc(":Company", filters.company).default_letter_head || frappe.defaults.get_default("letter_head")] %}
 </div>
 <h2 class="text-center">{%= __("Statement of Account") %}</h2>
 <h4 class="text-center">{%= (filters.party || filters.account) && ((filters.party || filters.account) + ", ")  || "" %} {%= filters.company %}</h4>
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index 9b97bd1..d0e0d86 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -174,7 +174,8 @@
 		var company_filter = function(doc) {
 			return {
 				filters: {
-					'company': frm.doc.company
+					'company': frm.doc.company,
+					'is_group': 0
 				}
 			}
 		}
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 68a717b..6483ecd 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -313,4 +313,5 @@
 erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice
 erpnext.patches.v7_0.fix_duplicate_icons
 erpnext.patches.v7_0.repost_gle_for_pos_sales_return
-erpnext.patches.v7_0.update_missing_employee_in_timesheet
\ No newline at end of file
+erpnext.patches.v7_0.update_missing_employee_in_timesheet
+erpnext.patches.v7_0.update_status_for_timesheet
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
index 6a6fa26..a176a8f 100644
--- a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
+++ b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
@@ -19,13 +19,14 @@
 		time_sheet.employee = data.employee
 		time_sheet.note = data.note
 		time_sheet.company = company
-		
+
 		time_sheet.set_status()
+		time_sheet.set_dates()
 		time_sheet.update_cost()
 		time_sheet.calculate_total_amounts()
 		time_sheet.flags.ignore_validate = True
 		time_sheet.save(ignore_permissions=True)
-		
+
 		# To ignore validate_mandatory_fields function
 		if data.docstatus == 1:
 			time_sheet.db_set("docstatus", 1)
@@ -33,7 +34,6 @@
 				d.db_set("docstatus", 1)
 			time_sheet.update_production_order(time_sheet.name)
 			time_sheet.update_task_and_project()
-			
 
 def get_timelog_data(data):
 	return {
diff --git a/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py b/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py
index c74a40a..57f5189 100644
--- a/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py
+++ b/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py
@@ -2,18 +2,19 @@
 import frappe
 
 def execute():
-	timesheet = frappe.db.sql("""select tl.employee as employee, ts.name as name,
-			tl.modified as modified, tl.modified_by as modified_by, tl.creation as creation, tl.owner as owner
-		from 
-			`tabTimesheet` ts, `tabTimesheet Detail` tsd, `tabTime Log` tl
-		where 
-			tsd.parent = ts.name and tl.from_time = tsd.from_time and tl.to_time = tsd.to_time 
-			and tl.hours = tsd.hours and tl.billing_rate = tsd.billing_rate and tsd.idx=1 
-			and tl.docstatus < 2 and (ts.employee = '' or ts.employee is null)""", as_dict=1)
+	if frappe.db.table_exists("Time Log"):
+		timesheet = frappe.db.sql("""select tl.employee as employee, ts.name as name,
+				tl.modified as modified, tl.modified_by as modified_by, tl.creation as creation, tl.owner as owner
+			from 
+				`tabTimesheet` ts, `tabTimesheet Detail` tsd, `tabTime Log` tl
+			where 
+				tsd.parent = ts.name and tl.from_time = tsd.from_time and tl.to_time = tsd.to_time 
+				and tl.hours = tsd.hours and tl.billing_rate = tsd.billing_rate and tsd.idx=1 
+				and tl.docstatus < 2 and (ts.employee = '' or ts.employee is null)""", as_dict=1)
 		
-	for data in timesheet:
-		ts_doc = frappe.get_doc('Timesheet', data.name)
-		if len(ts_doc.time_logs) == 1:
-			frappe.db.sql(""" update `tabTimesheet` set creation = %(creation)s,
-				owner = %(owner)s, modified = %(modified)s, modified_by = %(modified_by)s,
-				employee = %(employee)s where name = %(name)s""", data)
+		for data in timesheet:
+			ts_doc = frappe.get_doc('Timesheet', data.name)
+			if len(ts_doc.time_logs) == 1:
+				frappe.db.sql(""" update `tabTimesheet` set creation = %(creation)s,
+					owner = %(owner)s, modified = %(modified)s, modified_by = %(modified_by)s,
+					employee = %(employee)s where name = %(name)s""", data)
diff --git a/erpnext/patches/v7_0/update_status_for_timesheet.py b/erpnext/patches/v7_0/update_status_for_timesheet.py
new file mode 100644
index 0000000..117c40c
--- /dev/null
+++ b/erpnext/patches/v7_0/update_status_for_timesheet.py
@@ -0,0 +1,11 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.db.sql("""update 
+		`tabTimesheet` as ts,
+		(
+			select min(from_time)as from_time, max(to_time) as to_time, parent from `tabTimesheet Detail` group by parent
+		) as tsd
+		set ts.status = 'Submitted', ts.start_date = tsd.from_time, ts.end_date = tsd.to_time 
+		where tsd.parent = ts.name and ts.status = 'Draft' and ts.docstatus =1""")
\ No newline at end of file
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 792f269..d477189 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -25,14 +25,20 @@
 		$.each(["warehouse", "rejected_warehouse"], function(i, field) {
 			frm.set_query(field, "items", function() {
 				return {
-					filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]]
+					filters: [
+						["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
+						["Warehouse", "is_group", "=", 0]
+					]
 				}
 			})
 		})
 
 		frm.set_query("supplier_warehouse", function() {
 			return {
-				filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]]
+				filters: [
+					["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
+					["Warehouse", "is_group", "=", 0]
+				]
 			}
 		})
 	}