Merge pull request #21942 from scmmishra/manu-tour

feat: added tour to manufacturing settings
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.js b/erpnext/buying/doctype/buying_settings/buying_settings.js
index a27950a..01b40cd 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.js
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.js
@@ -11,7 +11,7 @@
 	{
 		fieldname: "supp_master_name",
 		title: "Supplier Naming By",
-		description: __("By default, the Item Name is set as per the Item Code entered. If you want Items to be named by a set ") + "<a href='https://docs.erpnext.com/docs/user/manual/en/setting-up/settings/naming-series'>Naming Series</a>" + __(" choose the 'Naming Series' option."),
+		description: __("By default, the Item Name is set as per the Item Code entered. If you want Items to be named by a set ") + "<a href='https://docs.erpnext.com/docs/user/manual/en/setting-up/settings/naming-series' target='_blank'>Naming Series</a>" + __(" choose the 'Naming Series' option."),
 	},
 	{
 		fieldname: "buying_price_list",
diff --git a/erpnext/change_log/v13/v13_0_0_beta_1.md b/erpnext/change_log/v13/v13_0_0-beta_1.md
similarity index 89%
rename from erpnext/change_log/v13/v13_0_0_beta_1.md
rename to erpnext/change_log/v13/v13_0_0-beta_1.md
index f84dc24..5bd13dd 100644
--- a/erpnext/change_log/v13/v13_0_0_beta_1.md
+++ b/erpnext/change_log/v13/v13_0_0-beta_1.md
@@ -30,6 +30,14 @@
 - [Item-wise Sales Register](https://docs.erpnext.com/docs/user/manual/en/accounts/accounting-reports)
 - [Territory-wise Sales](https://github.com/frappe/erpnext/pull/20428)
 
+## Regional
+
+- Germany
+
+  - [Update report DATEV Export to version 7.0](https://github.com/frappe/erpnext/pull/20582) and [allow to filter by voucher type](https://github.com/frappe/erpnext/pull/21060).
+
+- [Use any available Address Template](https://github.com/frappe/erpnext/pull/19862), not just your country's.
+
 ## Other Changes
 - [Report Summary in Financial Statement](https://github.com/frappe/erpnext/pull/20876)
 - [Accounts Payable Report based on Payment Terms](https://docs.erpnext.com/docs/user/manual/en/accounts/accounting-reports)
diff --git a/erpnext/change_log/v13/v13_0_0_beta_2.md b/erpnext/change_log/v13/v13_0_0-beta_2.md
similarity index 100%
rename from erpnext/change_log/v13/v13_0_0_beta_2.md
rename to erpnext/change_log/v13/v13_0_0-beta_2.md
diff --git a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json
index 3952a81..15c9434 100644
--- a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json
+++ b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json
@@ -11,6 +11,7 @@
   "patient",
   "assessment_template",
   "column_break_4",
+  "company",
   "healthcare_practitioner",
   "assessment_datetime",
   "assessment_description",
@@ -127,11 +128,18 @@
    "fieldname": "assessment_description",
    "fieldtype": "Small Text",
    "label": "Assessment Description"
+  },
+  {
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "in_standard_filter": 1,
+   "label": "Company",
+   "options": "Company"
   }
  ],
  "is_submittable": 1,
  "links": [],
- "modified": "2020-04-21 13:23:09.815007",
+ "modified": "2020-05-25 14:38:38.302399",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient Assessment",
diff --git a/erpnext/healthcare/doctype/sample_collection/sample_collection.json b/erpnext/healthcare/doctype/sample_collection/sample_collection.json
index c352287..016cfbc 100644
--- a/erpnext/healthcare/doctype/sample_collection/sample_collection.json
+++ b/erpnext/healthcare/doctype/sample_collection/sample_collection.json
@@ -85,11 +85,9 @@
   {
    "fieldname": "company",
    "fieldtype": "Link",
-   "hidden": 1,
+   "in_standard_filter": 1,
    "label": "Company",
-   "options": "Company",
-   "print_hide": 1,
-   "report_hide": 1
+   "options": "Company"
   },
   {
    "fieldname": "section_break_6",
@@ -167,7 +165,7 @@
  ],
  "is_submittable": 1,
  "links": [],
- "modified": "2020-04-04 19:17:02.707203",
+ "modified": "2020-05-25 14:36:46.990469",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Sample Collection",
diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json
index ca78b66..9edfeb2 100644
--- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json
+++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json
@@ -10,6 +10,7 @@
   "patient",
   "patient_name",
   "column_break_4",
+  "company",
   "status",
   "start_date",
   "section_break_3",
@@ -98,10 +99,17 @@
    "label": "Status",
    "options": "Not Started\nIn Progress\nCompleted\nCancelled",
    "read_only": 1
+  },
+  {
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "in_standard_filter": 1,
+   "label": "Company",
+   "options": "Company"
   }
  ],
  "links": [],
- "modified": "2020-04-21 13:13:43.956014",
+ "modified": "2020-05-25 14:38:53.649315",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Therapy Plan",
diff --git a/erpnext/healthcare/setup.py b/erpnext/healthcare/setup.py
index 2087f49..0684080 100644
--- a/erpnext/healthcare/setup.py
+++ b/erpnext/healthcare/setup.py
@@ -195,10 +195,21 @@
 
 def add_healthcare_service_unit_tree_root():
 	record = [
-	 {
-	  "doctype": "Healthcare Service Unit",
-	  "healthcare_service_unit_name": "All Healthcare Service Units",
-	  "is_group": 1
-	 }
+		{
+			"doctype": "Healthcare Service Unit",
+			"healthcare_service_unit_name": "All Healthcare Service Units",
+			"is_group": 1,
+			"company": get_company()
+	 	}
 	]
 	insert_record(record)
+
+def get_company():
+	company = frappe.defaults.get_defaults().company
+	if company:
+		return company
+	else:
+		company = frappe.get_list("Company", limit=1)
+		if company:
+			return company[0].name
+	return None
diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py
index f092578..9abaa07 100644
--- a/erpnext/healthcare/utils.py
+++ b/erpnext/healthcare/utils.py
@@ -512,10 +512,10 @@
 def get_patient_vitals(patient, from_date=None, to_date=None):
 	if not patient: return
 
-	vitals = frappe.db.get_all('Vital Signs', {
+	vitals = frappe.db.get_all('Vital Signs', filters={
 			'docstatus': 1,
 			'patient': patient
-		}, order_by='signs_date, signs_time')
+		}, order_by='signs_date, signs_time', fields=['*'])
 
 	if len(vitals):
 		return vitals
diff --git a/erpnext/manufacturing/dashboard_fixtures.py b/erpnext/manufacturing/dashboard_fixtures.py
index ef61f23..4a17fd0 100644
--- a/erpnext/manufacturing/dashboard_fixtures.py
+++ b/erpnext/manufacturing/dashboard_fixtures.py
@@ -3,7 +3,7 @@
 
 import frappe, erpnext, json
 from frappe import _
-from frappe.utils import nowdate, get_date_str
+from frappe.utils import nowdate, get_first_day, get_last_day, add_months
 from erpnext.accounts.utils import get_fiscal_year
 
 def get_data():
@@ -28,10 +28,10 @@
 			{ "chart": "Job Card Analysis", "width": "Full" }
 		],
 		"cards": [
-			{ "card": "Total Work Order" },
-			{ "card": "Completed Work Order" },
+			{ "card": "Monthly Total Work Order" },
+			{ "card": "Monthly Completed Work Order" },
 			{ "card": "Ongoing Job Card" },
-			{ "card": "Total Quality Inspection"}
+			{ "card": "Monthly Quality Inspection"}
 		]
 	}]
 
@@ -180,38 +180,37 @@
 	}]
 
 def get_number_cards():
-	fiscal_year = get_fiscal_year(date=nowdate())
-	year_start_date = get_date_str(fiscal_year[1])
-	year_end_date = get_date_str(fiscal_year[2])
+	start_date = add_months(nowdate(), -1)
+	end_date = nowdate()
 
 	return [{
 		"doctype": "Number Card",
 		"document_type": "Work Order",
-		"name": "Total Work Order",
+		"name": "Monthly Total Work Order",
 		"filters_json": json.dumps([
 			['Work Order', 'docstatus', '=', 1],
-			['Work Order', 'creation', 'between', [year_start_date, year_end_date]]
+			['Work Order', 'creation', 'between', [start_date, end_date]]
 		]),
 		"function": "Count",
 		"is_public": 1,
-		"label": _("Total Work Order"),
+		"label": _("Monthly Total Work Order"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	},
 	{
 		"doctype": "Number Card",
 		"document_type": "Work Order",
-		"name": "Completed Work Order",
+		"name": "Monthly Completed Work Order",
 		"filters_json": json.dumps([
 			['Work Order', 'status', '=', 'Completed'],
 			['Work Order', 'docstatus', '=', 1],
-			['Work Order', 'creation', 'between', [year_start_date, year_end_date]]
+			['Work Order', 'creation', 'between', [start_date, end_date]]
 		]),
 		"function": "Count",
 		"is_public": 1,
-		"label": _("Completed Work Order"),
+		"label": _("Monthly Completed Work Order"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	},
 	{
 		"doctype": "Number Card",
@@ -225,16 +224,19 @@
 		"is_public": 1,
 		"label": _("Ongoing Job Card"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	},
 	{
 		"doctype": "Number Card",
 		"document_type": "Quality Inspection",
-		"name": "Total Quality Inspection",
-		"filters_json": json.dumps([['Quality Inspection', 'docstatus', '=', 1]]),
+		"name": "Monthly Quality Inspection",
+		"filters_json": json.dumps([
+			['Quality Inspection', 'docstatus', '=', 1],
+			['Quality Inspection', 'creation', 'between', [start_date, end_date]]
+		]),
 		"function": "Count",
 		"is_public": 1,
-		"label": _("Total Quality Inspection"),
+		"label": _("Monthly Quality Inspection"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	}]
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
index 9acb4f0..b301a9e 100644
--- a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
+++ b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
@@ -1,11 +1,13 @@
 {
  "actions": [],
  "allow_import": 1,
+ "autoname": "naming_series:",
  "creation": "2020-04-18 04:50:46.187638",
  "doctype": "DocType",
  "editable_grid": 1,
  "engine": "InnoDB",
  "field_order": [
+  "naming_series",
   "workstation",
   "operator",
   "column_break_4",
@@ -78,10 +80,17 @@
    "fieldname": "remarks",
    "fieldtype": "Text",
    "label": "Remarks"
+  },
+  {
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Naming Series",
+   "options": "DT-",
+   "reqd": 1
   }
  ],
  "links": [],
- "modified": "2020-05-19 12:59:37.358483",
+ "modified": "2020-05-26 22:14:54.479831",
  "modified_by": "Administrator",
  "module": "Manufacturing",
  "name": "Downtime Entry",
diff --git a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
index 2b2be4f..093309a 100644
--- a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
+++ b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
@@ -24,7 +24,12 @@
 	if filters.get("workstation"):
 		query_filters["workstation"] = filters.get("workstation")
 
-	return frappe.get_all("Downtime Entry", fields= fields, filters=query_filters)
+	data = frappe.get_all("Downtime Entry", fields= fields, filters=query_filters) or []
+	for d in data:
+		if d.downtime:
+			d.downtime = d.downtime / 60
+
+	return data
 
 def get_chart_data(data, columns):
 	labels = sorted(list(set([d.workstation for d in data])))
@@ -44,7 +49,7 @@
 		"data": {
 			"labels": labels,
 			"datasets": [
-				{"name": "Dataset 1", "values": datasets}
+				{"name": "Machine Downtime", "values": datasets}
 			]
 		},
 		"type": "bar"
@@ -88,7 +93,7 @@
 			"width": 160
 		},
 		{
-			"label": _("Downtime (In Mins)"),
+			"label": _("Downtime (In Hours)"),
 			"fieldname": "downtime",
 			"fieldtype": "Float",
 			"width": 150
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
index bc09ed4..fb047b2 100644
--- a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
@@ -56,7 +56,7 @@
 		return get_chart_based_on_qty(data, filters)
 
 def get_chart_based_on_status(data):
-	labels = ["Not Started", "In Process", "Stopped", "Completed"]
+	labels = ["Completed", "In Process", "Stopped", "Not Started"]
 
 	status_wise_data = {
 		"Not Started": 0,
@@ -66,13 +66,10 @@
 	}
 
 	for d in data:
-		if d.status == "In Process" and d.produced_qty:
-			status_wise_data["Completed"] += d.produced_qty
+		status_wise_data[d.status] += 1
 
-		status_wise_data[d.status] += d.qty
-
-	values = [status_wise_data["Not Started"], status_wise_data["In Process"],
-		status_wise_data["Stopped"], status_wise_data["Completed"]]
+	values = [status_wise_data["Completed"], status_wise_data["In Process"],
+		status_wise_data["Stopped"], status_wise_data["Not Started"]]
 
 	chart = {
 		"data": {
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index cb82901..481cd35 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -688,7 +688,7 @@
 erpnext.patches.v12_0.update_price_list_currency_in_bom
 execute:frappe.delete_doc_if_exists('Dashboard', 'Accounts')
 erpnext.patches.v13_0.update_actual_start_and_end_date_in_wo
-erpnext.patches.v13_0.set_company_field_in_healthcare_doctypes
+erpnext.patches.v13_0.set_company_field_in_healthcare_doctypes #2020-05-25
 erpnext.patches.v12_0.update_bom_in_so_mr
 execute:frappe.delete_doc("Report", "Department Analytics")
 execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True)
diff --git a/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py b/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py
index 9d0dae4..a7d4c66 100644
--- a/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py
+++ b/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py
@@ -3,8 +3,8 @@
 
 def execute():
 	company = frappe.db.get_single_value('Global Defaults', 'default_company')
-	doctypes = ['Clinical Procedure', 'Inpatient Record', 'Lab Test', 'Patient Appointment', 'Patient Encounter', 'Vital Signs']
+	doctypes = ['Clinical Procedure', 'Inpatient Record', 'Lab Test', 'Sample Collection' 'Patient Appointment', 'Patient Encounter', 'Vital Signs', 'Therapy Session', 'Therapy Plan', 'Patient Assessment']
 	for entry in doctypes:
 		if frappe.db.exists('DocType', entry):
-			frappe.reload_doc("Healthcare", "doctype", entry)
+			frappe.reload_doc('Healthcare', 'doctype', entry)
 			frappe.db.sql("update `tab{dt}` set company = '{company}' where ifnull(company, '') = ''".format(dt=entry, company=company))
diff --git a/erpnext/projects/report/project_summary/project_summary.js b/erpnext/projects/report/project_summary/project_summary.js
index 15367ac..c12a83e 100644
--- a/erpnext/projects/report/project_summary/project_summary.js
+++ b/erpnext/projects/report/project_summary/project_summary.js
@@ -16,7 +16,7 @@
 			"fieldname": "status",
 			"label": __("Status"),
 			"fieldtype": "Select",
-			"options": "Open\nComplete\nCancelled",
+			"options": "Open\nCompleted\nCancelled",
 			"default": "Open"
 		}
 	]
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js
index 6f97572..877d0c3 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.js
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.js
@@ -36,7 +36,7 @@
 	{
 		fieldname: "valuation_method",
 		title: __("Valuation Method"),
-		description: __("Choose between FIFO and Moving Average Valuation Methods. Click ") + "<a href='https://docs.erpnext.com/docs/user/manual/en/stock/articles/item-valuation-fifo-and-moving-average'>here</a>" + __(" to know more about them.")
+		description: __("Choose between FIFO and Moving Average Valuation Methods. Click ") + "<a href='https://docs.erpnext.com/docs/user/manual/en/stock/articles/item-valuation-fifo-and-moving-average' target='_blank'>here</a>" + __(" to know more about them.")
 	},
 	{
 		fieldname: "show_barcode_field",
diff --git a/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json b/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json
index 447611f..009a44f 100644
--- a/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json
+++ b/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json
@@ -8,12 +8,12 @@
  "is_mandatory": 0,
  "is_single": 0,
  "is_skipped": 0,
- "modified": "2020-05-19 18:55:41.457289",
+ "modified": "2020-05-26 15:55:41.457289",
  "modified_by": "Administrator",
  "name": "Introduction to Stock Entry",
  "owner": "Administrator",
  "show_full_form": 0,
- "title": "Introduction to the multi-purpose stock transaction",
+ "title": "Introduction to Stock Entry",
  "validate_action": 1,
  "video_url": "https://www.youtube.com/watch?v=Njt107hlY3I"
 }
\ No newline at end of file