fix: Added dashboard and module links for accounting dimensions
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js
index 0676731..9a6ea73 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js
@@ -2,7 +2,9 @@
 // For license information, please see license.txt
 
 frappe.ui.form.on('Accounting Dimension', {
-	// refresh: function(frm) {
 
-	// }
+	document_type: function(frm){
+		frm.set_value('label', frm.doc.document_type);
+		frm.set_value('fieldname', frappe.scrub(frm.doc.document_type))
+	}
 });
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json
index 13902d6..0e9ab9e 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json
@@ -6,7 +6,8 @@
  "field_order": [
   "document_type",
   "label",
-  "fieldname"
+  "fieldname",
+  "is_mandatory"
  ],
  "fields": [
   {
@@ -27,9 +28,14 @@
    "label": "Document Type",
    "options": "DocType",
    "reqd": 1
+  },
+  {
+   "fieldname": "is_mandatory",
+   "fieldtype": "Check",
+   "label": "Is Mandatory"
   }
  ],
- "modified": "2019-05-09 15:30:55.339917",
+ "modified": "2019-05-16 13:37:04.240148",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Accounting Dimension",
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
index ab66fe3..147b808 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
@@ -13,8 +13,6 @@
 
 	def before_insert(self):
 		self.set_fieldname_and_label()
-
-	def after_insert(self):
 		self.make_accounting_dimension_in_accounting_doctypes()
 
 	def on_trash(self):
@@ -28,21 +26,27 @@
 			self.fieldname = scrub(self.label)
 
 	def make_accounting_dimension_in_accounting_doctypes(self):
-		last_created_accounting_dimension = get_last_created_accounting_dimension()
 
-		doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order",
-			"Stock Entry", "Budget", "Payroll Entry", "Delivery Note"]
+		doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order", "Asset",
+			"Stock Entry", "Budget", "Payroll Entry", "Delivery Note", "Sales Invoice Item", "Purchase Invoice Item", "Sales Order Item",
+			"Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
+			"Purchase Order Item"]
 
-		df = {
-			"fieldname": self.fieldname,
-			"label": self.label,
-			"fieldtype": "Link",
-			"options": self.document_type,
-			"insert_after": last_created_accounting_dimension if last_created_accounting_dimension else "project"
-		}
+		if self.is_mandatory:
+			df.update({
+				"reqd": 1
+			})
 
 		for doctype in doclist:
 
+			df = {
+				"fieldname": self.fieldname,
+				"label": self.label,
+				"fieldtype": "Link",
+				"options": self.document_type,
+				"insert_after": "cost_center"
+			}
+
 			if doctype == "Budget":
 				df.update({
 					"depends_on": "eval:doc.budget_against == '{0}'".format(self.document_type)
@@ -73,12 +77,16 @@
 						"property_type": "Text",
 						"value": "\nCost Center\nProject\n" + self.document_type
 					}).insert(ignore_permissions=True)
+				frappe.clear_cache(doctype=doctype)
 			else:
 				create_custom_field(doctype, df)
+				frappe.clear_cache(doctype=doctype)
 
 	def delete_accounting_dimension(self):
-		doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order",
-			"Stock Entry", "Budget", "Payroll Entry", "Delivery Note"]
+		doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order", "Asset",
+			"Stock Entry", "Budget", "Payroll Entry", "Delivery Note", "Sales Invoice Item", "Purchase Invoice Item", "Sales Order Item",
+			"Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
+			"Purchase Order Item"]
 
 		frappe.db.sql("""
 			DELETE FROM `tabCustom Field`
@@ -92,21 +100,16 @@
 			AND doc_type IN (%s)""" %
 			('%s', ', '.join(['%s']* len(doclist))), tuple([self.fieldname] + doclist))
 
-		# budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
-		# value_list = budget_against_property.value.split('\n')[3:]
-		# value_list.remove(self.document_type)
+		budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
+		value_list = budget_against_property.value.split('\n')[3:]
+		value_list.remove(self.document_type)
 
-		# budget_against_property.value = "\nCost Center\nProject\n" + "\n".join(value_list)
+		budget_against_property.value = "\nCost Center\nProject\n" + "\n".join(value_list)
+		budget_against_property.save()
 
 		for doc in doclist:
 			frappe.clear_cache(doctype=doc)
 
-def get_last_created_accounting_dimension():
-	last_created_accounting_dimension = frappe.db.sql("select fieldname, max(creation) from `tabAccounting Dimension`", as_dict=1)
-
-	if last_created_accounting_dimension[0]:
-		return last_created_accounting_dimension[0].fieldname
-
 def get_accounting_dimensions():
 	accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["fieldname"])
 
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension_dashboard.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension_dashboard.py
new file mode 100644
index 0000000..62a1291
--- /dev/null
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension_dashboard.py
@@ -0,0 +1,12 @@
+from __future__ import unicode_literals
+
+from frappe import _
+
+def get_data():
+	return {
+		'transactions': [
+			{
+				'label': _('Accounting Doctypes')
+			}
+		]
+	}
\ No newline at end of file
diff --git a/erpnext/config/accounting.py b/erpnext/config/accounting.py
index 6664c4d..0ab1f52 100644
--- a/erpnext/config/accounting.py
+++ b/erpnext/config/accounting.py
@@ -174,6 +174,11 @@
 					"name": "Cheque Print Template",
 					"description": _("Setup cheque dimensions for printing")
 				},
+				{
+					"type": "doctype",
+					"name": "Accounting Dimension",
+					"description": _("Setup custom dimensions for accounting")
+				},
 			]
 		},
 		{