Sourced wnframework-modules from Google Code as erpnext
diff --git a/setup/Module Def/Setup/Setup.txt b/setup/Module Def/Setup/Setup.txt
new file mode 100644
index 0000000..5a0dcf7
--- /dev/null
+++ b/setup/Module Def/Setup/Setup.txt
@@ -0,0 +1,652 @@
+[
+	{
+		'_last_update': None,
+		'creation': '2010-11-30 22:43:08',
+		'disabled': 'No',
+		'docstatus': 0,
+		'doctype': 'Module Def',
+		'doctype_list': None,
+		'file_list': None,
+		'idx': None,
+		'is_hidden': 'No',
+		'last_updated_date': '2011-03-21 12:13:39',
+		'modified': '2010-09-25 00:00:00',
+		'modified_by': 'Administrator',
+		'module_desc': None,
+		'module_icon': 'wired.png',
+		'module_label': 'Setup',
+		'module_name': 'Setup',
+		'module_page': 'Setup',
+		'module_seq': 1,
+		'name': 'Setup',
+		'owner': 'Administrator',
+		'parent': None,
+		'parentfield': None,
+		'parenttype': None,
+		'trash_reason': None,
+		'widget_code': None
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'All important setup items in one place',
+		'display_name': 'Setup Wizard',
+		'doc_name': 'Setup Wizard',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'lightbulb.gif',
+		'idx': 1,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00221',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Personalize settings like company banner, date format, print format header etc.',
+		'display_name': 'Personalize',
+		'doc_name': 'Personalize Page',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'star.gif',
+		'idx': 2,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00222',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Enable / Disable users. Set user roles.',
+		'display_name': 'Manage Users',
+		'doc_name': 'Manage Users',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'group.gif',
+		'idx': 3,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00223',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Set global default values and account settings',
+		'display_name': 'Setup Defaults',
+		'doc_name': 'Manage Account',
+		'doc_type': 'Single DocType',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'folder.gif',
+		'idx': 4,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00224',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'General Masters',
+		'display_name': 'Setup Masters',
+		'doc_name': 'Setup Masters',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'wrench.gif',
+		'idx': 5,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00225',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': None,
+		'display_name': 'Sales Browser',
+		'doc_name': 'Sales Browser',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 6,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00226',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': None,
+		'doc_name': None,
+		'doc_type': 'Separator',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 7,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003107',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': "Import data like Customers, Items etc in 'CSV' format",
+		'display_name': 'Import Data',
+		'doc_name': 'Import Data',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'disk.gif',
+		'idx': 8,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00228',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Set series prefix for transactions',
+		'display_name': 'Setup Series',
+		'doc_name': 'Naming Series',
+		'doc_type': 'Single DocType',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'paperclip.gif',
+		'idx': 9,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00229',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Set approval rights for transactions based on grand total and discount.',
+		'display_name': 'Authorization Rule',
+		'doc_name': 'Authorization Rule',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'transaction\nbased_on\nmaster_name\nsystem_user\nsystem_role\napproving_role\napproving_user\nvalue',
+		'hide': None,
+		'icon': 'accept.gif',
+		'idx': 10,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00230',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Add fields in transactions, masters...',
+		'display_name': 'Custom Field',
+		'doc_name': 'Custom Field',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'dt\nlabel\nfieldtype\noptions',
+		'hide': None,
+		'icon': 'paperclip.gif',
+		'idx': 11,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00231',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 22:43:08',
+		'description': 'Contains records that you have trashed.',
+		'display_name': 'Trash',
+		'doc_name': 'Trash',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 12,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': 'MDI00232',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Price List',
+		'doc_name': 'Price List',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 13,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003108',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Warehouse Type',
+		'doc_name': 'Warehouse Type',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 14,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003109',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Warehouse',
+		'doc_name': 'Warehouse',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 15,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003110',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'UOM',
+		'doc_name': 'UOM',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 16,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003111',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Term',
+		'doc_name': 'Term',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 17,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003112',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Taxes and Charges',
+		'doc_name': 'Other Charges',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 18,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003113',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Business Letter Type',
+		'doc_name': 'Business Letter Type',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 19,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003114',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Business Letter Template',
+		'doc_name': 'Business Letter Template',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 20,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003115',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-24 15:04:47',
+		'description': None,
+		'display_name': 'Mode of Payment',
+		'doc_name': 'Mode of Payment',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 21,
+		'modified': '2011-03-24 15:04:47',
+		'modified_by': 'Administrator',
+		'name': '000003116',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 1,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00042',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Administrator'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 2,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00043',
+		'owner': 'Administrator',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'System Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 3,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00044',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Sales User'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 4,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00045',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Sales Master Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 5,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00046',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Sales Master Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 6,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00047',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Purchase User'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 7,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00048',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Purchase Master Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 8,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00049',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Purchase Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 9,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00050',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Material User'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 10,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00051',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Material Master Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 11,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00052',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Material Manager'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 12,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00053',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Accounts User'
+	},
+	{
+		'creation': '2010-11-30 22:43:08',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 13,
+		'modified': '2010-11-30 22:43:08',
+		'modified_by': 'Administrator',
+		'name': 'MDR00054',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Setup',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Accounts Manager'
+	}
+]
\ No newline at end of file
diff --git a/setup/__init__.py b/setup/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/__init__.py
diff --git a/setup/doctype/__init__.py b/setup/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/__init__.py
diff --git a/setup/doctype/brand/__init__.py b/setup/doctype/brand/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/brand/__init__.py
diff --git a/setup/doctype/brand/brand.js b/setup/doctype/brand/brand.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/brand/brand.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/brand/brand.txt b/setup/doctype/brand/brand.txt
new file mode 100644
index 0000000..f7a92d2
--- /dev/null
+++ b/setup/doctype/brand/brand.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-05-26 14:59:10', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 6, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:brand', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Brand', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00874', 'parent': 'Brand', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-20 08:57:33', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00875', 'parent': 'Brand', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-20 08:57:33', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00899', 'parent': 'Brand', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-20 08:57:33', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00900', 'parent': 'Brand', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-20 08:57:33', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00549', 'parent': 'Brand', 'read': 1, 'create': 1, 'creation': '2009-12-30 12:15:49', 'modified': '2010-09-20 08:57:33', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 5, 'parenttype': 'DocType', 'role': 'Material Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00302', 'parent': 'Brand', 'read': 1, 'create': 1, 'creation': '2009-05-26 14:59:10', 'modified': '2010-09-20 08:57:33', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 6, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Brand', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04828', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 08:57:33', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-26 14:59:10', 'doctype': 'DocField', 'oldfieldname': 'brand', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Brand Name', 'width': '', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Brand', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02186', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 08:57:33', 'parenttype': 'DocType', 'fieldname': 'brand', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-05-26 14:59:10', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Brand', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02187', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 08:57:33', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': '', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/company/__init__.py b/setup/doctype/company/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/company/__init__.py
diff --git a/setup/doctype/company/company.js b/setup/doctype/company/company.js
new file mode 100644
index 0000000..e27052c
--- /dev/null
+++ b/setup/doctype/company/company.js
@@ -0,0 +1,17 @@
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  if(doc.abbr && !doc.__islocal) set_field_permlevel('abbr',1);
+}
+
+cur_frm.fields_dict.default_bank_account.get_query = function(doc) {    
+  return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';   
+}
+
+
+cur_frm.fields_dict.receivables_group.get_query = function(doc) {  
+  return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
+}
+
+
+cur_frm.fields_dict.payables_group.get_query = function(doc) {  
+  return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
+}
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
new file mode 100644
index 0000000..fe60a2b
--- /dev/null
+++ b/setup/doctype/company/company.py
@@ -0,0 +1,228 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,d,dl):
+    self.doc, self.doclist = d,dl
+  
+  # Create default accounts
+  # ---------------------------------------------------
+  def create_default_accounts(self):
+    self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'debit_or_credit':5,'company':6,'tax_rate':7}
+    acc_list_common = [['Application of Funds (Assets)','','Group','No','','Debit',self.doc.name,''],
+                        ['Current Assets','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
+                          ['Accounts Receivable','Current Assets','Group','No','','Debit',self.doc.name,''],
+                          ['Bank Accounts','Current Assets','Group','No','Bank or Cash','Debit',self.doc.name,''],
+                          ['Cash In Hand','Current Assets','Group','No','Bank or Cash','Debit',self.doc.name,''],
+                            ['Cash','Cash In Hand','Ledger','No','Bank or Cash','Debit',self.doc.name,''],
+                          ['Loans and Advances (Assets)','Current Assets','Group','No','','Debit',self.doc.name,''],
+                          ['Securities and Deposits','Current Assets','Group','No','','Debit',self.doc.name,''],
+                            ['Earnest Money','Securities and Deposits','Ledger','No','','Debit',self.doc.name,''],
+                          ['Stock In Hand','Current Assets','Group','No','','Debit',self.doc.name,''],
+                            ['Stock','Stock In Hand','Ledger','No','','Debit',self.doc.name,''],
+                          ['Tax Assets','Current Assets','Group','No','','Debit',self.doc.name,''],
+                        ['Fixed Assets','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
+                          ['Capital Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
+                          ['Computers','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
+                          ['Furniture and Fixture','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
+                          ['Office Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
+                          ['Plant and Machinery','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
+                        ['Investments','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
+                        ['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
+                          ['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','No','','Debit',self.doc.name,''],
+                  ['Source of Funds (Liabilities)','','Group','No','','Credit',self.doc.name,''],
+                    ['Capital Account','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
+                      ['Reserves and Surplus','Capital Account','Group','No','','Credit',self.doc.name,''],
+                      ['Shareholders Funds','Capital Account','Group','No','','Credit',self.doc.name,''],
+                    ['Current Liabilities','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
+                      ['Accounts Payable','Current Liabilities','Group','No','','Credit',self.doc.name,''],
+                      ['Duties and Taxes','Current Liabilities','Group','No','','Credit',self.doc.name,''],
+                      ['Loans (Liabilities)','Current Liabilities','Group','No','','Credit',self.doc.name,''],
+                        ['Secured Loans','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
+                        ['Unsecured Loans','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
+                        ['Bank Overdraft Account','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
+                    ['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
+                      ['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','No','','Credit',self.doc.name,''],
+                  ['Income','','Group','Yes','','Credit',self.doc.name,''],
+                    ['Direct Income','Income','Group','Yes','Income Account','Credit',self.doc.name,''],
+                      ['Sales','Direct Income','Ledger','Yes','Income Account','Credit',self.doc.name,''],
+                      ['Service','Direct Income','Ledger','Yes','Income Account','Credit',self.doc.name,''],
+                    ['Indirect Income','Income','Group','Yes','Income Account','Credit',self.doc.name,''],
+                  ['Expenses','','Group','Yes','Expense Account','Debit',self.doc.name,''],
+                    ['Direct Expenses','Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Cost of Goods Sold','Direct Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                    ['Indirect Expenses','Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Advertising and Publicity','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
+                      ['Bad Debts Written Off','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Bank Charges','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Books and Periodicals','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Charity and Donations','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Commission on Sales','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Conveyance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Customer Entertainment Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Depreciation Account','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Freight and Forwarding Charges','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
+                      ['Legal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Miscellaneous Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
+                      ['Office Maintenance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Office Rent','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Postal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Print and Stationary','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Rounded Off','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Salary','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Sales Promotion Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
+                      ['Service Charges Paid','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Staff Welfare Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Telephone Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Travelling Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
+                      ['Water and Electricity Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,'']
+                  ]
+    
+    acc_list_india = [
+                      ['CENVAT Capital Goods','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
+                      ['CENVAT','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
+                      ['CENVAT Service Tax','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
+                      ['CENVAT Service Tax Cess 1','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
+                      ['CENVAT Service Tax Cess 2','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
+                      ['CENVAT Edu Cess','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
+                      ['CENVAT SHE Cess','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
+                      ['Excise Duty 4','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'4.00'],
+                      ['Excise Duty 8','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'8.00'],
+                      ['Excise Duty 10','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'10.00'],
+                      ['Excise Duty 14','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'14.00'],
+                      ['Excise Duty Edu Cess 2','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'2.00'],
+                      ['Excise Duty SHE Cess 1','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'1.00'],
+                      ['P L A','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
+                      ['P L A - Cess Portion','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
+                      ['Edu. Cess on Excise','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
+                      ['Edu. Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
+                      ['Edu. Cess on TDS','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
+                      ['Excise Duty @ 4','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'4.00'],
+                      ['Excise Duty @ 8','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'8.00'],
+                      ['Excise Duty @ 10','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'10.00'],
+                      ['Excise Duty @ 14','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'14.00'],
+                      ['Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'10.3'],
+                      ['SHE Cess on Excise','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
+                      ['SHE Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
+                      ['SHE Cess on TDS','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
+                      ['Professional Tax','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['VAT','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['TDS (Advertisement)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['TDS (Commission)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['TDS (Contractor)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['TDS (Interest)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['TDS (Rent)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
+                      ['TDS (Salary)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,'']
+                     ]
+    # load common account heads
+    for d in acc_list_common:
+      self.add_acc(d)
+
+    country = sql("select value from tabSingles where field = 'country' and doctype = 'Control Panel'")
+    country = country and cstr(country[0][0]) or ''
+
+    # load taxes (only for India)
+    if country == 'India':
+      for d in acc_list_india:
+        self.add_acc(d)
+
+  # Create account
+  # ---------------------------------------------------
+  def add_acc(self,lst):
+    ac = Document('Account')
+    for d in self.fld_dict.keys():
+      ac.fields[d] = (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.doc.abbr or lst[self.fld_dict[d]]
+    ac.old_parent = ''
+    ac_obj = get_obj(doc=ac)
+    ac_obj.validate()
+    ac_obj.doc.save(1)
+    ac_obj.on_update()
+    sql("commit")
+    sql("start transaction")
+
+
+  # Set letter head
+  # ---------------------------------------------------  
+  def set_letter_head(self):
+    if not self.doc.letter_head:
+      if self.doc.address:
+        header = """ 
+<div><h3> %(comp)s </h3> %(add)s </div>
+
+      """ % {'comp':self.doc.name,
+         'add':self.doc.address.replace("\n",'<br>')}
+       
+        self.doc.letter_head = header
+
+  # Set default AR and AP group
+  # ---------------------------------------------------
+  def set_default_groups(self):
+    if not self.doc.receivables_group:
+      set(self.doc, 'receivables_group', 'Accounts Receivable - '+self.doc.abbr)
+    if not self.doc.payables_group:
+      set(self.doc, 'payables_group', 'Accounts Payable - '+self.doc.abbr)
+      
+      
+  # Create default cost center
+  # ---------------------------------------------------
+  def create_default_cost_center(self):
+    glc = get_obj('GL Control')
+    cc_list = [{'cost_center_name':'Root','company_name':self.doc.name,'company_abbr':self.doc.abbr,'group_or_ledger':'Group','parent_cost_center':'','old_parent':''}, {'cost_center_name':'Default CC Ledger','company_name':self.doc.name,'company_abbr':self.doc.abbr,'group_or_ledger':'Ledger','parent_cost_center':'Root - ' + self.doc.abbr,'old_parent':''}]
+    for c in cc_list:
+      glc.add_cc(str(c))
+      
+      
+  # On update
+  # ---------------------------------------------------
+  def on_update(self):
+    self.set_letter_head()
+    ac = sql("select name from tabAccount where account_name='Income' and company=%s", self.doc.name)
+    if not ac:
+      self.create_default_accounts()
+    self.set_default_groups()
+    cc = sql("select name from `tabCost Center` where cost_center_name = 'Root' and company_name = '%s'"%(self.doc.name))
+    if not cc:
+      self.create_default_cost_center()
+
+  # Trash accounts and cost centers for this company
+  # ---------------------------------------------------
+  def on_trash(self):
+    acc = sql("select name from tabAccount where company = '%s' and docstatus = 1" % self.doc.name)
+    for each in acc:
+      get_obj('Account', each[0]).on_trash()
+      
+    cc = sql("select name from `tabCost Center` where company_name = '%s' and docstatus = 1" % self.doc.name)
+    for each in cc:
+      get_obj('Cost Center', each[0]).on_trash()
+    
+    msgprint("Company trashed. All the accounts and cost centers related to this company also trashed. You can restore it anytime from Setup -> Manage Trash")
+
+
+  # Restore accounts and cost centers for this company  
+  # ---------------------------------------------------
+  def on_restore(self):
+    acc = sql("select name from tabAccount where company = '%s' and docstatus = 2" % self.doc.name)
+    for each in acc:
+      get_obj('Account', each[0]).on_restore()
+      
+    cc = sql("select name from `tabCost Center` where company_name = '%s' and docstatus = 2" % self.doc.name)
+    for each in cc:
+      get_obj('Cost Center', each[0]).on_restore()
+    
+    msgprint("Company restored. All the accounts and cost centers related to this company also restored.")
diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt
new file mode 100644
index 0000000..d1664fa
--- /dev/null
+++ b/setup/doctype/company/company.txt
@@ -0,0 +1,930 @@
+[
+	{
+		'_last_update': '1303215455',
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': 'field:company_name',
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:08:55',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': None,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-04-20 12:17:16',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'Company',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': None,
+		'read_only_onload': None,
+		'search_fields': None,
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'use_template': None,
+		'version': 86
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'creation': '2010-08-08 17:08:55',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': '',
+		'modified': '2010-08-08 17:08:55',
+		'modified_by': 'Administrator',
+		'name': 'PERM00119',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'creation': '2010-08-08 17:08:55',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': '',
+		'modified': '2010-08-08 17:08:55',
+		'modified_by': 'Administrator',
+		'name': 'PERM00120',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Administrator',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': 0,
+		'create': None,
+		'creation': '2010-08-08 17:08:55',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-08-08 17:08:55',
+		'modified_by': 'Administrator',
+		'name': 'PERM00121',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'All',
+		'submit': None,
+		'write': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 11:04:28',
+		'default': None,
+		'depends_on': None,
+		'description': 'Please Enter Company Name and Abbr and save the document. Once saved Accounting Settings will be populated automatically',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Details',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': '000000437',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Company',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00695',
+		'no_copy': 1,
+		'oldfieldname': 'company_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': 'Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'abbr',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Abbr',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00696',
+		'no_copy': 1,
+		'oldfieldname': 'abbr',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Address',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00697',
+		'no_copy': None,
+		'oldfieldname': 'address',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 11:04:28',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_currency',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Default Currency',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': '000000434',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'link:Currency',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 11:04:28',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': '000000438',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'phone_no',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Phone No',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00699',
+		'no_copy': None,
+		'oldfieldname': 'phone_no',
+		'oldfieldtype': 'Data',
+		'options': 'Phone',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'email',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Email',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00700',
+		'no_copy': None,
+		'oldfieldname': 'email',
+		'oldfieldtype': 'Data',
+		'options': 'Email',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'fax',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Fax',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00701',
+		'no_copy': None,
+		'oldfieldname': 'fax',
+		'oldfieldtype': 'Data',
+		'options': 'Phone',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-12-14 10:32:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Trash Company',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL04130',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'website',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Website',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00702',
+		'no_copy': None,
+		'oldfieldname': 'website',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-09 11:04:28',
+		'default': None,
+		'depends_on': None,
+		'description': 'Company registration numbers for your reference. Example: VAT Registration Numbers etc.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': None,
+		'label': 'Registration Info',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': '000000439',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': 'Company registration numbers for your reference. Tax numbers etc.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'registration_details',
+		'fieldtype': 'Code',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Registration Details',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00704',
+		'no_copy': None,
+		'oldfieldname': 'registration_details',
+		'oldfieldtype': 'Code',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 11:04:28',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'Accounting Settings',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': '000000440',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_bank_account',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Default Bank Account',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00706',
+		'no_copy': 1,
+		'oldfieldname': 'default_bank_account',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'receivables_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Receivables Group',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00707',
+		'no_copy': 1,
+		'oldfieldname': 'receivables_group',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'payables_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': 'Payables Group',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00708',
+		'no_copy': 1,
+		'oldfieldname': 'payables_group',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 11:04:28',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': '000000441',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'yearly_bgt_flag',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'If Yearly Budget Exceeded',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00710',
+		'no_copy': None,
+		'oldfieldname': 'yearly_bgt_flag',
+		'oldfieldtype': 'Select',
+		'options': '\nWarn\nIgnore\nStop',
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'monthly_bgt_flag',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'If Monthly Budget Exceeded',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00711',
+		'no_copy': None,
+		'oldfieldname': 'monthly_bgt_flag',
+		'oldfieldtype': 'Select',
+		'options': '\nWarn\nIgnore\nStop',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'credit_days',
+		'fieldtype': 'Int',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': None,
+		'label': 'Credit Days',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00712',
+		'no_copy': None,
+		'oldfieldname': 'credit_days',
+		'oldfieldtype': 'Int',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'credit_limit',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Credit Limit',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00713',
+		'no_copy': None,
+		'oldfieldname': 'credit_limit',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:08:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 23,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-05-09 11:04:28',
+		'modified_by': 'Administrator',
+		'name': 'FL00716',
+		'no_copy': 1,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Company',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/contact_control/__init__.py b/setup/doctype/contact_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/contact_control/__init__.py
diff --git a/setup/doctype/contact_control/contact_control.js b/setup/doctype/contact_control/contact_control.js
new file mode 100755
index 0000000..b6825eb
--- /dev/null
+++ b/setup/doctype/contact_control/contact_control.js
@@ -0,0 +1,562 @@
+// common partner functions
+// =========================
+
+/*
+// make shipping list body
+// ------------------------
+cur_frm.cscript.make_sl_body = function(){
+	cur_frm.fields_dict['Shipping HTML'].wrapper.innerHTML = '';
+	cur_frm.shipping_html = $a(cur_frm.fields_dict['Shipping HTML'].wrapper,'div');
+}
+*/
+
+// make history list body
+// -----------------------
+cur_frm.cscript.make_hl_body = function(){
+	cur_frm.fields_dict['History HTML'].wrapper.innerHTML = '';
+	cur_frm.history_html = $a(cur_frm.fields_dict['History HTML'].wrapper,'div');
+}
+
+
+/*
+// set shipping list message
+// --------------------------
+cur_frm.cscript.set_sl_msg = function(doc){
+	cur_frm.shipping_html.innerHTML = 'Shipping Address Details will appear only when you save the ' + doc.doctype.toLowerCase();
+}
+*/
+/*
+// set history list message
+// -------------------------
+cur_frm.cscript.set_hl_msg = function(doc){
+	cur_frm.history_html.innerHTML= 'History Details will appear only when you save the ' + doc.doctype.toLowerCase();
+}
+*/
+
+
+/*
+// make shipping address
+// -------------
+cur_frm.cscript.make_shipping_address = function(doc, dt, dn){
+  	cur_frm.shipping_html.innerHTML = '';
+
+	var dsn = cur_frm.doc.customer_name;
+	var dsa = cur_frm.doc.address;
+	cl = new AddressList(cur_frm.shipping_html,dt,dn,dsn,dsa);
+}
+*/
+
+
+// make history
+// -------------
+cur_frm.cscript.make_history = function(doc,dt,dn){
+	cur_frm.history_html.innerHTML = '';
+	cur_frm.cscript.make_history_list(cur_frm.history_html,doc);
+}
+
+// make history list
+// ------------------
+cur_frm.cscript.make_history_list = function(parent,doc){
+
+	var sel = $a(parent,'select');
+	
+	var ls = ['Select Transaction..'];
+	for(d in cur_frm.history_dict){
+		ls.push(d);
+	}
+	
+	add_sel_options(sel,ls,'Select..');
+	
+	var body = $a(parent,'div');
+	body.innerHTML = '<div class="help_box">Please select a transaction type to see History</div>';
+	
+	sel.body = body;
+	sel.doc = doc;
+	
+	sel.onchange = function(){
+		for(d in cur_frm.history_dict){
+			if(sel_val(this) == d){
+				this.body.innerHTML = '';
+				eval(cur_frm.history_dict[d]);
+				return;
+			}
+			else{
+				// pass
+			}
+		}
+	}
+}
+
+// run list
+// ---------
+cur_frm.cscript.run_list = function(lst,parent,q,q_max,doc,dn,nm){
+	
+	parent.innerHTML = '';
+	$dh(parent);
+	
+	lst.doc = doc;
+	lst.dn = dn;
+	lst.nm = nm;
+	lst.page_len = 10;
+	
+	lst.get_query = function(){
+		this.query = q;
+		this.query_max = q_max;
+	}
+	
+	lst.make(parent);
+	lst.run();
+	
+	lst.onrun = function(){
+		$ds(parent);
+		if(!this.has_data()){
+			parent.innerHTML = '';
+			var dv = $a(parent,'div','help_box');
+			$a(dv,'span').innerHTML = "No " + this.dn + " found. ";
+			
+			var lbl = 'Create the <b>first</b> ' + this.dn + ' for ' + this.doc.name;
+			var sp = $a(dv,'span');
+			sp.nm = this.nm;
+			$(sp).html(lbl).addClass('link_type').click(function(){ newdoc(this.nm); });
+		}
+	}
+}
+
+
+// get sates on country trigger
+// -----------------------------
+cur_frm.cscript.get_states=function(doc,dt,dn){
+   $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
+    function(r,rt){
+      if(r.message) {
+        set_field_options('state', r.message);
+      }
+    }  
+  );
+
+}
+
+cur_frm.cscript.country = function(doc, dt, dn) {
+  cur_frm.cscript.get_states(doc, dt, dn);
+}
+
+// territory help - cutsomer + sales partner
+// -----------------------------------------
+cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
+  var call_back = function(){
+
+    var sb_obj = new SalesBrowser();        
+    sb_obj.set_val('Territory');
+  }
+  loadpage('Sales Browser',call_back);
+}
+
+// get query select Territory
+// ---------------------------
+if(cur_frm.fields_dict['territory']){
+	cur_frm.fields_dict['territory'].get_query = function(doc,dt,dn) {
+		return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s"  ORDER BY  `tabTerritory`.`name` ASC LIMIT 50';
+	}
+}
+
+
+// =======================================================================================================
+
+// contact list
+// --------------
+ContactList = function(parent,dt,dn,dsn){
+	
+	var me = this;
+	
+	this.dt = dt;
+	this.dn = dn;
+	this.dsn = dsn ? dsn : dn;
+
+	this.wrapper = $a(parent,'div');
+	me.get_list();
+}
+
+// add contact
+// ------------
+ContactList.prototype.add_contact = function(){
+	var me = this;
+	
+	// onload - set default values
+	var cont = LocalDB.create('Contact');
+
+	var c = locals['Contact'][cont];
+	
+	if(me.dt == 'Customer')	{
+		c.is_customer = 1;
+		c.customer = me.dn;
+		c.customer_name = me.dsn;
+	}
+	else if(me.dt == 'Supplier'){
+		c.is_supplier = 1;
+		c.supplier = me.dn;
+		c.supplier_name = me.dsn;
+	}
+	else if(me.dt == 'Sales Partner'){
+		c.is_sales_partner = 1;
+		c.sales_partner = me.dn;
+		//c.sales_partner_name = me.dsn;
+	}
+	
+	loaddoc('Contact',c.name);
+}
+
+// get contact list
+// -----------------
+ContactList.prototype.get_list = function(){
+	var me = this;
+	
+	me.make_list();
+	
+	var dt = me.dt.toLowerCase().split(' ').join('_');
+	
+	// build query
+	me.lst.get_query = function(){
+		this.query = repl("select name, first_name, last_name, concat_ws(' ', first_name, last_name), email_id, contact_no, department, designation, is_primary_contact, has_login, disable_login from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
+
+		this.query_max = repl("select count(name) from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
+	}
+	
+	// render list ui
+	me.lst.show_cell = function(cell,ri,ci,d){
+		me.render_list(cell,ri,ci,d);
+	}
+	
+	// run query
+	me.lst.run();
+	
+	// onrun
+	me.lst.onrun = function(){
+		if(!this.has_data()){
+			this.rec_label.innerHTML = '';
+			
+			$a(this.rec_label,'span').innerHTML = "You do not have any contact. ";
+			$($a(this.rec_label,'span')).html('Add a new contact').addClass('link_type').click(function(){ me.add_contact(); });
+			
+			$dh(this.results);
+		}
+		else{
+			$ds(this.results);
+		}
+	}	
+}
+
+// make list
+// -----------
+ContactList.prototype.make_list = function(){
+	var me = this;
+	
+	var l = new Listing();
+	l.colwidths = ['5%','30%','30%','20%','20%'];
+	l.colnames = ['Sr.','Contact Name','Email Id','Contact No', 'Action'];
+	l.page_len = 10;
+  
+	me.lst = l;
+	
+	l.make(me.wrapper);
+	
+	// Add contact button
+	me.add_btn = $btn(l.btn_area,'+ Add Contact', function(){ me.add_contact();}, {fontWeight:'bold'});
+}
+
+// make contact cell
+// ------------------
+ContactList.prototype.render_list = function(cell,ri,ci,d){
+	var me = this;
+
+	// name
+	if(ci == 0){
+		var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
+		nm.innerHTML = d[ri][3];
+		nm.id = d[ri][0];
+		
+		nm.onclick = function(){
+			loaddoc('Contact', this.id);
+			
+			// on save callback - refresh list
+		}
+
+		// department and designation
+		var des = d[ri][7] ? d[ri][7] : '';
+		var dep = d[ri][6] ? d[ri][6] : '';
+		
+		var sp = $a(cell,'div','comment');
+		sp.innerHTML = des + (dep ? (', ' + dep) : ''); 
+	}
+	
+	// email id, contact no, department, designation
+	// -----------------------------------------------------
+	if(ci == 1) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
+	if(ci == 2) cell.innerHTML = d[ri][5] ? d[ri][5] : '-';
+	
+	// actions
+	// --------------------------------------
+	if(ci== 3) me.make_actions(cell,ri,ci,d);
+}
+
+// make actions
+// ---------------
+ContactList.prototype.make_actions = function(cell,ri,ci,d){
+	var me = this;
+	
+	var tab = make_table(cell,1,2,'100%',['40%','60%']);
+
+	// Edit and Delete
+	var t = make_table($td(tab,0,0),1,2);
+	
+	var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
+	$(edit).click(function(){ loaddoc('Contact',d[ri][0]); });
+	
+	edit.setAttribute('title','Edit');
+
+// Below code should be uncommented once customer/venodr invitation process is stable
+// ===========================================================================
+/* 
+	var del = $a($td(t,0,1),'div','wn-icon ic-trash');
+	$(del).click(function(){ me.delete_contact(d[ri][0],d[ri][4]) });
+
+	set_custom_tooltip(del, 'Delete');
+	
+	//  Invite, Enable and Disable - Integrate after gateway logic incorporated
+
+	if(d[ri][9] == 'Yes')	{
+		if(d[ri][10] == 'Yes'){
+			var enb = $a($td(tab,0,1),'div','wn-icon ic-checkmark');
+			$(enb).click(function(){ me.enable_login(d[ri][0], d[ri][4]); });
+		}
+		else{
+			var dsb = $a($td(tab,0,1),'div','wn-icon ic-delete');
+			$(dsb).click(function(){ me.disable_login(d[ri][0], d[ri][4]) });
+		}
+	}
+	else{
+		var inv = $a($td(tab,0,1),'div','wn-icon ic-mail');
+		$(inv).click(function(){ me.invite_contact(d[ri][0], d[ri][4], d[ri][1], d[ri][2]) });
+	}*/
+}
+
+// enable login
+// ----------------------------------------------------------
+ContactList.prototype.enable_login = function(id, email_id){
+	var me = this;
+	
+	var callback = function(r,rt){
+		me.get_list();
+		
+		if(!r.exc) msgprint('Login for contact enabled',1);
+		else errprint(r.exc);
+	}
+	
+	var args = {};
+	args.contact = id;
+	args.email = email_id;
+	
+	$c_obj('Contact Control','enable_login',JSON.stringify(args),callback);
+}
+
+// disable login
+// -------------------------------------------------------------
+ContactList.prototype.disable_login = function(id, email_id){
+	var me = this;
+	
+	var callback = function(r,rt){
+		me.get_list();
+		
+		if(!r.exc) msgprint('Login for contact disabled',1);
+		else errprint(r.exc);
+	}
+
+	var args = {};
+	args.contact = id;
+	args.email = email_id;
+		
+	$c_obj('Contact Control','disable_login',JSON.stringify(args),callback);
+}
+
+// delete contact
+// -----------------
+ContactList.prototype.delete_contact = function(id,email_id,has_login){
+	var me = this;
+	
+	var callback = function(r,rt){
+		me.get_list();
+		
+		if(!r.exc) msgprint('Contact deleted successfully');
+		else errprint(r.exc);
+	}
+	
+	var args = {};
+	args.contact = id;
+	args.email = email_id;
+	args.has_login = has_login;
+	
+	$c_obj('Contact Control','delete_contact',JSON.stringify(args),callback);
+}
+
+// invite user
+// --------------------------------------------------------
+ContactList.prototype.invite_contact = function(id,email_id,first_name,last_name){
+	var me = this;
+
+	if(!email_id){
+		msgprint("Please add email id and save the contact first. You can then invite contact to view transactions.")
+	}
+	else{
+		var callback = function(r,rt){
+			if(!r.exc) msgprint('Invitation sent');
+			else errprint(r.exc);
+		}
+	
+		var args = {
+			'contact' : id,
+			'email' : email_id,
+			'first_name' : first_name ? first_name : '',
+			'last_name' : last_name ? last_name : '',
+			'usert_type' : 'Partner'
+		};
+		
+		$c_obj('Contact Control','invite_contact',JSON.stringify(args),callback);	
+	}
+}
+
+
+// address list
+// --------------
+AddressList = function(parent,dt,dn,dsn,dsa){
+	
+	var me = this;
+	
+	this.dt = dt;
+	this.dn = dn;
+	this.dsn = dsn ? dsn : dn;
+        this.dsa = dsa ? dsa : '';
+
+	this.wrapper = $a(parent,'div');
+	me.get_addr_list();
+}
+
+
+// add contact
+// ------------
+AddressList.prototype.add_address = function(){
+	var me = this;
+	
+	// onload - set default values
+	var addr = LocalDB.create('Shipping Address');
+
+	var a = locals['Shipping Address'][addr];
+	
+	a.customer = me.dn;
+	a.customer_name = me.dsn;
+        a.customer_address = me.dsa;	
+	loaddoc('Shipping Address',a.name);
+}
+
+
+// get address list
+// -----------------
+AddressList.prototype.get_addr_list = function(){
+	var me = this;
+	
+	me.make_addr_list();
+	
+	var dt = me.dt.toLowerCase().split(' ').join('_');
+	
+	// build query
+	me.lst.get_query = function(){
+		this.query = repl("select name, ship_to, shipping_address, is_primary_address, shipping_details from `tabShipping Address` where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
+
+		this.query_max = repl("select count(name) from `tabShipping Address` where %(dt)s = '%(dn)s'",{'dt':dt, 'dn':me.dn});
+	}
+	
+	// render list ui
+	me.lst.show_cell = function(cell,ri,ci,d){
+		me.render_list(cell,ri,ci,d);
+	}
+	
+	// run query
+	me.lst.run();
+	
+	// onrun
+	me.lst.onrun = function(){
+		if(!this.has_data()){
+			this.rec_label.innerHTML = '';
+			
+			$a(this.rec_label,'span').innerHTML = "You do not have any shipping address.";
+			$($a(this.rec_label,'span')).html('Add a new address').addClass('link_type').click(function(){ me.add_address(); });
+			
+			$dh(this.results);
+		}
+		else{
+			$ds(this.results);
+		}
+	}	
+}
+
+
+// make list
+// -----------
+AddressList.prototype.make_addr_list = function(){
+	var me = this;
+	
+	var l = new Listing();
+	l.colwidths = ['5%', '15%', '25%','10%','35%','10%'];
+	l.colnames = ['Sr.', 'Ship To', 'Shipping Address','Primary Address', 'Shipping Details', 'Action'];
+    l.page_len = 10;
+  
+	me.lst = l;
+	
+	l.make(me.wrapper);
+	
+	// Add address button
+	me.add_btn = $btn(l.btn_area,'+ Add Address', function(){ me.add_address();}, {fontWeight:'bold'});
+}
+
+
+
+// make address cell
+// ------------------
+AddressList.prototype.render_list = function(cell,ri,ci,d){
+	var me = this;
+
+	// name
+	if(ci == 0){
+		var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
+		nm.innerHTML = d[ri][1];
+		nm.id = d[ri][0];
+		
+		nm.onclick = function(){
+			loaddoc('Shipping Address', this.id);
+		}
+	}
+	
+	// shipping address, primary address, shipping details
+	// ----------------------------------------------------
+	if(ci == 1) cell.innerHTML = d[ri][2] ? d[ri][2] : '-';
+	if(ci == 2) cell.innerHTML = d[ri][3] ? d[ri][3] : '-';
+	if(ci == 3) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
+	
+	// actions
+	// --------------------------------------
+	if(ci== 4) me.make_actions(cell,ri,ci,d);
+}
+
+// make actions
+// ---------------
+AddressList.prototype.make_actions = function(cell,ri,ci,d){
+	var me = this;
+	
+	var tab = make_table(cell,1,2,'100%',['40%','60%']);
+
+	// Edit and Delete
+	var t = make_table($td(tab,0,0),1,2);
+	
+	var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
+	$(edit).click(function(){ loaddoc('Shipping Address',d[ri][0]); });
+	
+	edit.setAttribute('title','Edit');
+}
diff --git a/setup/doctype/contact_control/contact_control.py b/setup/doctype/contact_control/contact_control.py
new file mode 100644
index 0000000..3c25d7f
--- /dev/null
+++ b/setup/doctype/contact_control/contact_control.py
@@ -0,0 +1,103 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,doc,doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    
+  def enable_login(self,arg):
+    arg = eval(arg)
+    sql("update tabContact set disable_login = 'No' where name=%s",arg['contact'])
+    sql("update tabProfile set enabled=1 where name=%s",arg['email'])
+    
+  def disable_login(self,arg):
+    arg = eval(arg)
+    sql("update tabContact set disable_login = 'Yes' where name=%s",arg['contact'])
+    sql("update tabProfile set enabled=0 where name=%s",arg['email'])
+    
+  def create_login(self,arg):
+    arg = eval(arg)
+    cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
+    if cont_det[0]['docstatus'] !=0:
+      msgprint('Please save the corresponding contact first')
+      raise Exception
+      
+    if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
+      msgprint('Profile with same name already exist.')
+      raise Exception
+    else:
+      p = Document('Profile')
+      p.name = cont_det[0]['email_id']
+      p.first_name = cont_det[0]['first_name']
+      p.last_name = cont_det[0]['last_name']
+      p.email = cont_det[0]['email_id']
+      p.cell_no = cont_det[0]['contact_no']
+      p.password = 'password'
+      p.enabled = 1
+      p.user_type = 'Partner';
+      p.save(1)
+      
+      get_obj(doc=p).on_update()
+      
+      role = []
+      if cont_det[0]['contact_type'] == 'Individual':
+        role = ['Customer']
+      else:
+        if cont_det[0]['is_customer']:
+          role.append('Customer')
+        if cont_det[0]['is_supplier']:
+          role.append('Supplier')
+        if cont_det[0]['is_sales_partner']:
+          role.append('Partner')
+
+      if role:
+        prof_nm = p.name
+        for i in role:
+          r = Document('UserRole')
+          r.parent = p.name
+          r.role = i
+          r.parenttype = 'Profile'
+          r.parentfield = 'userroles'
+          r.save(1)
+        
+          if i == 'Customer':
+            def_keys = ['from_company','customer_name','customer']
+            def_val = cont_det[0]['customer_name']
+            self.set_default_val(def_keys,def_val,prof_nm)
+
+          if i == 'Supplier':
+            def_keys = ['supplier_name','supplier']
+            def_val = cont_det[0]['supplier_name']
+            self.set_default_val(def_keys,def_val,prof_nm)
+
+      sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
+      sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
+      msgprint('User login is created.')
+      
+ #------set default values---------
+  def set_default_val(self,def_keys,def_val,prof_nm):
+    for d in def_keys:
+      kv = Document('DefaultValue')
+      kv.defkey = d
+      kv.defvalue = def_val
+      kv.parent = prof_nm
+      kv.parenttype = 'Profile'
+      kv.parentfield = 'defaults'
+      kv.save(1)
\ No newline at end of file
diff --git a/setup/doctype/contact_control/contact_control.txt b/setup/doctype/contact_control/contact_control.txt
new file mode 100644
index 0000000..f57d7cf
--- /dev/null
+++ b/setup/doctype/contact_control/contact_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-07-23 13:32:22', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 25, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Contact Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00411', 'parent': 'Contact Control', 'read': 1, 'create': 0, 'creation': '2009-09-09 12:17:33', 'modified': '2010-08-06 22:02:45', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-09-09 12:13:02', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Header', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Control', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02926', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-06 22:02:45', 'parenttype': 'DocType', 'fieldname': 'header', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-09-09 12:13:01', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Customer Intro', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Control', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02924', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-06 22:02:45', 'parenttype': 'DocType', 'fieldname': 'customer_intro', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-09-09 12:13:02', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Supplier Intro', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Control', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02925', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-06 22:02:45', 'parenttype': 'DocType', 'fieldname': 'supplier_intro', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/country/__init__.py b/setup/doctype/country/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/country/__init__.py
diff --git a/setup/doctype/country/country.js b/setup/doctype/country/country.js
new file mode 100644
index 0000000..d648a01
--- /dev/null
+++ b/setup/doctype/country/country.js
@@ -0,0 +1,13 @@
+//Tips not required
+/*
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+*/
diff --git a/setup/doctype/country/country.txt b/setup/doctype/country/country.txt
new file mode 100644
index 0000000..ddf0dbd
--- /dev/null
+++ b/setup/doctype/country/country.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-04-24 10:15:27', 'search_fields': '', 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 0, 'read_only': 0, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 12, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:country_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Country', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00501', 'parent': 'Country', 'read': 1, 'create': 1, 'creation': '2009-11-04 16:20:24', 'modified': '2010-09-20 09:22:06', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00765', 'parent': 'Country', 'read': 1, 'create': 1, 'creation': '2010-04-08 14:09:38', 'modified': '2010-09-20 09:22:06', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Purchase Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00829', 'parent': 'Country', 'read': 1, 'create': 1, 'creation': '2010-04-19 10:03:22', 'modified': '2010-09-20 09:22:06', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 3, 'parenttype': 'DocType', 'role': 'HR User', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00830', 'parent': 'Country', 'read': 1, 'create': 1, 'creation': '2010-04-19 10:03:22', 'modified': '2010-09-20 09:22:06', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 4, 'parenttype': 'DocType', 'role': 'HR Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-04-24 10:15:27', 'doctype': 'DocField', 'oldfieldname': 'country_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Country Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Country', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01929', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:22:06', 'parenttype': 'DocType', 'fieldname': 'country_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/currency/__init__.py b/setup/doctype/currency/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/currency/__init__.py
diff --git a/setup/doctype/currency/currency.txt b/setup/doctype/currency/currency.txt
new file mode 100644
index 0000000..25c8c39
--- /dev/null
+++ b/setup/doctype/currency/currency.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-25 10:32:06', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 0, 'read_only': 0, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:currency_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': '', 'name': 'Currency', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-18 16:00:32', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00294', 'parent': 'Currency', 'read': 1, 'create': 1, 'creation': '2009-05-18 12:54:45', 'modified': '2010-11-18 16:00:32', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Accounts Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00247', 'parent': 'Currency', 'read': 1, 'create': 1, 'creation': '2009-03-25 10:32:06', 'modified': '2010-11-18 16:00:32', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00248', 'parent': 'Currency', 'read': 1, 'create': 1, 'creation': '2009-03-25 10:32:06', 'modified': '2010-11-18 16:00:32', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 3, 'parenttype': 'DocType', 'role': 'Purchase Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM01235', 'parent': 'Currency', 'read': 1, 'create': 1, 'creation': '2010-11-18 16:00:32', 'modified': '2010-11-18 16:00:32', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 4, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-25 10:32:06', 'doctype': 'DocField', 'oldfieldname': 'currency_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Currency Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Currency', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01465', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-11-18 16:00:32', 'parenttype': 'DocType', 'fieldname': 'currency_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/customer_group/__init__.py b/setup/doctype/customer_group/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/customer_group/__init__.py
diff --git a/setup/doctype/customer_group/customer_group.js b/setup/doctype/customer_group/customer_group.js
new file mode 100644
index 0000000..080b309
--- /dev/null
+++ b/setup/doctype/customer_group/customer_group.js
@@ -0,0 +1,18 @@
+$import(Tips Common)
+
+cur_frm.cscript.onload = function(){
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+  if(doc.__islocal){
+    doc.parent_customer_group = 'Root';
+    refresh('parent_customer_group');
+  }
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+//get query select Customer Group
+cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) {
+  return 'SELECT `tabCustomer Group`.`name`,`tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "Yes" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY  `tabCustomer Group`.`name` ASC LIMIT 50';
+}
\ No newline at end of file
diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py
new file mode 100644
index 0000000..ae74797
--- /dev/null
+++ b/setup/doctype/customer_group/customer_group.py
@@ -0,0 +1,45 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.nsm_parent_field = 'parent_customer_group';
+
+
+  # update Node Set Model
+  def update_nsm_model(self):
+    import webnotes
+    import webnotes.utils.nestedset
+    webnotes.utils.nestedset.update_nsm(self)
+
+  # ON UPDATE
+  #--------------------------------------
+  def on_update(self):
+    # update nsm
+    self.update_nsm_model()   
+
+
+  def validate(self): 
+
+    r = sql("select name from `tabCustomer Group` where name = '%s' and docstatus = 2"%(self.doc.customer_group_name))
+    if r:
+      msgprint("%s record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.customer_group_name))
+      raise Exception
\ No newline at end of file
diff --git a/setup/doctype/customer_group/customer_group.txt b/setup/doctype/customer_group/customer_group.txt
new file mode 100644
index 0000000..989626c
--- /dev/null
+++ b/setup/doctype/customer_group/customer_group.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:09:56', 'search_fields': 'name,parent_customer_group', 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': 1, 'in_create': 1, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 35, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:customer_group_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Customer Group', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00938', 'parent': 'Customer Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:08:32', 'modified': '2010-09-17 14:57:03', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00939', 'parent': 'Customer Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:08:32', 'modified': '2010-09-17 14:57:03', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00955', 'parent': 'Customer Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:10:54', 'modified': '2010-09-17 14:57:03', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00971', 'parent': 'Customer Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:13:26', 'modified': '2010-09-17 14:57:03', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00972', 'parent': 'Customer Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:13:26', 'modified': '2010-09-17 14:57:03', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 5, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00163', 'parent': 'Customer Group', 'read': 1, 'create': 1, 'creation': '2009-03-12 14:13:07', 'modified': '2010-09-17 14:57:03', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 6, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': '', 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Customer Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04837', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:09:56', 'doctype': 'DocField', 'oldfieldname': 'customer_group_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Customer Group Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Customer Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00768', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'customer_group_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-03-12 12:09:56', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Customer Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00769', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-06-24 09:32:40', 'doctype': 'DocField', 'oldfieldname': 'parent_customer_group', 'owner': 'nabin@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Parent Customer Group', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Customer Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05420', 'idx': 4, 'default': None, 'colour': 'White:FFF', 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'parent_customer_group', 'fieldtype': 'Link', 'options': 'Customer Group', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-30 10:32:15', 'doctype': 'DocField', 'oldfieldname': 'is_group', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Has Child Node', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': 'Only leaf nodes are allowed in transaction', 'parent': 'Customer Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05496', 'idx': 5, 'default': None, 'colour': 'White:FFF', 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'is_group', 'fieldtype': 'Select', 'options': '\nYes\nNo', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Int', 'creation': '2010-06-30 09:55:32', 'doctype': 'DocField', 'oldfieldname': 'lft', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'lft', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Customer Group', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05493', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'lft', 'fieldtype': 'Int', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Int', 'creation': '2010-06-30 09:55:32', 'doctype': 'DocField', 'oldfieldname': 'rgt', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'rgt', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Customer Group', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05494', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'rgt', 'fieldtype': 'Int', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-06-30 09:55:32', 'doctype': 'DocField', 'oldfieldname': 'old_parent', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'old_parent', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Customer Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05495', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:03', 'parenttype': 'DocType', 'fieldname': 'old_parent', 'fieldtype': 'Data', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/erp_setup/__init__.py b/setup/doctype/erp_setup/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/erp_setup/__init__.py
diff --git a/setup/doctype/erp_setup/erp_setup.js b/setup/doctype/erp_setup/erp_setup.js
new file mode 100644
index 0000000..61fd374
--- /dev/null
+++ b/setup/doctype/erp_setup/erp_setup.js
@@ -0,0 +1,3 @@
+cur_frm.cscript['Repost GL'] = function(doc,dt,dn) {
+  $c_obj('GL Control','repost_gl','',function(r,rt) {alert('Done')});
+}
\ No newline at end of file
diff --git a/setup/doctype/erp_setup/erp_setup.py b/setup/doctype/erp_setup/erp_setup.py
new file mode 100644
index 0000000..b0f1474
--- /dev/null
+++ b/setup/doctype/erp_setup/erp_setup.py
@@ -0,0 +1,131 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, d, dl):
+    self.doc, self.doclist = d, dl
+
+  def get_bal(self,arg):
+    bal = sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
+    if bal:
+      return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
+    else:
+      return ''
+  
+  def get_series(self):
+    self.doc.clear_table(self.doclist, 'series_details')
+    
+    if self.doc.select_doctype:
+      sr= sql("Select options from `tabDocField` where fieldname='voucher_series' and parent='%s'"%(self.doc.select_doctype))
+      if sr:
+        sr_list=sr[0][0].split("\n")
+        
+        for x in sr_list:
+          if cstr(x)!='':
+            c = addchild(self.doc, 'series_details', 'Series Detail', 1, self.doclist)
+            c.series=cstr(x)
+      
+      else:
+        msgprint("No series is mentioned")
+    else :
+      msgprint("Please select Doctype")
+  
+  def remove_series(self):
+    if not getlist(self.doclist, 'series_details'):
+      msgprint("Please pull already existed series for the selected doctype and check the series that you want to remove")
+    else:
+      sr= sql("Select options from `tabDocField` where fieldname='voucher_series' and parent='%s'"%(self.doc.select_doctype))
+      if sr:
+        sr_list=sr[0][0].split("\n")
+      
+      for d in getlist(self.doclist, 'series_details'):
+        if d.remove == 1:
+          sr_list.remove(d.series)
+      sql("update `tabDocField` set options='%s' where fieldname='voucher_series' and parent='%s'"%("\n".join(sr_list),self.doc.select_doctype))
+      self.get_series()
+
+  def add_series(self):
+    if not self.doc.select_doctype or not self.doc.new_series:
+      msgprint("Please select Doctype and series name for which series will be added")
+      raise Exception
+    else:
+      sr_list = []
+      sr= sql("select options from `tabDocField` where fieldname='voucher_series' and parent='%s'"% (self.doc.select_doctype))
+      if sr[0][0]:
+        sr_list=sr[0][0].split("\n")
+      self.check_duplicate()
+      if not sr_list:
+        sr_list.append('')
+        sr_list.append(self.get_new_series())
+      else:
+        sr_list.append(self.get_new_series())
+      sql("update `tabDocField` set options='%s' where fieldname='voucher_series' and parent='%s'"%("\n".join(sr_list),self.doc.select_doctype))
+      self.get_series()
+      
+  def check_duplicate(self):
+    sr_list = sql("Select options from `tabDocField` where fieldname='voucher_series' group by parent")
+    nw_sr = self.get_new_series()
+    #msgprint(sr_list)
+    for sr in sr_list:
+      if nw_sr in sr[0]:
+        idx=sql("Select current from `tabSeries` where name='%s'"% (nw_sr + '/'))
+        msgprint("Series name already exist with index '%s'" %(idx[0][0]))
+        raise Exception  
+        
+  def get_new_series(self):
+    if 'FY' in cstr((self.doc.new_series).upper()):
+      abb=sql("select abbreviation from `tabFiscal Year` where name='%s'"%(self.doc.current_fiscal_year))
+      if not abb:
+        msgprint("Abbreviation is not mentioned in Fiscal Year")
+        raise Exception
+      else:
+        return cstr((self.doc.new_series).upper()).strip().replace('FY',abb[0][0])
+    else:
+      return cstr((self.doc.new_series).upper()).strip()
+
+  def on_update(self):
+
+    # fiscal year
+    set_default('fiscal_year', self.doc.current_fiscal_year)
+    ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", self.doc.current_fiscal_year, as_dict = 1)
+    set_default('year_start_date', ysd[0]['year_start_date'].strftime('%Y-%m-%d'))
+    set_default('year_end_date', get_last_day(get_first_day(ysd[0]['year_start_date'],0,11)).strftime('%Y-%m-%d'))
+
+    # company
+    set_default('company', self.doc.default_company)
+
+    set_default('stock_valuation', self.doc.stock_valuation or 'Moving Average')
+    set_default('default_currency', self.doc.default_currency or 'INR')
+
+    # Purchase in transit
+    if self.doc.purchase_in_transit_account:
+      set_default('purchase_in_transit_account', self.doc.purchase_in_transit_account)
+  
+  def get_default_bank_account(self, company):
+    return sql("select default_bank_account from tabCompany where name = '%s'" % company)[0][0]
+
+  def get_bank_defaults(self, arg):
+    arg = eval(arg)
+    return {
+      'def_bv_type': self.doc.default_bank_voucher_type or '',
+      'def_bv_series': self.doc.default_bank_voucher_series or '',
+      'def_bank_account': self.get_default_bank_account(arg['company']) or '',
+      'bank_balance': self.get_bal(self.get_default_bank_account(arg['company'])) or 0.0,
+      'acc_balance': self.get_bal(arg['credit_to']) or 0.0
+    }
diff --git a/setup/doctype/erp_setup/erp_setup.txt b/setup/doctype/erp_setup/erp_setup.txt
new file mode 100644
index 0000000..fc7c14f
--- /dev/null
+++ b/setup/doctype/erp_setup/erp_setup.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-12 12:04:08', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': 1, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 97, 'menu_index': None, 'docstatus': 0, 'allow_copy': 1, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': 1, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'nabin@webnotestech.com', 'document_type': None, 'name': 'ERP Setup', 'idx': None, 'hide_toolbar': 0, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'nabin@webnotestech.com', 'name': 'PERM00148', 'parent': 'ERP Setup', 'read': 1, 'create': 1, 'creation': '2009-03-12 14:03:17', 'modified': '2010-08-08 15:21:42', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': '', 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'nabin@webnotestech.com', 'name': 'PERM00023', 'parent': 'ERP Setup', 'read': 1, 'create': 1, 'creation': '2009-03-12 12:04:08', 'modified': '2010-08-08 15:21:42', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'nabin@webnotestech.com', 'name': 'PERM00321', 'parent': 'ERP Setup', 'read': 1, 'create': None, 'creation': '2009-06-22 12:28:39', 'modified': '2010-08-08 15:21:42', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 3, 'parenttype': 'DocType', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Accounts', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00242', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Default Company', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00243', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'default_company', 'fieldtype': 'Link', 'options': 'Company', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Current Fiscal Year', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00244', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'current_fiscal_year', 'fieldtype': 'Link', 'options': 'Fiscal Year', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Default Bank Account', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00245', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'default_bank_account', 'fieldtype': 'Link', 'options': 'Account', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Default Bank Voucher Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00246', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'default_bank_voucher_type', 'fieldtype': 'Select', 'options': 'Bank Voucher\nCash Voucher\nJournal Entry\nCredit Note\nDebit Note\nCredit Card Voucher\nSalary Voucher', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Default Bank Voucher Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00247', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'default_bank_voucher_series', 'fieldtype': 'Select', 'options': 'BV/08-09/\nCV/08-09/\nJV/08-09/\nCN/08-09/\nDN/08-09/\nCC/08-09/\nSV/08-09/', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Default Currency', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00248', 'idx': 7, 'default': 'INR', 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'default_currency', 'fieldtype': 'Select', 'options': 'link:Currency', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Stock Valuation', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00249', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'stock_valuation', 'fieldtype': 'Select', 'options': 'Moving Average\nFCFS', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Repost GL', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00250', 'idx': 9, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:04:08', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': '', 'width': '50%', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00251', 'idx': 10, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Column Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Naming Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02322', 'idx': 11, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Select Doctype', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02323', 'idx': 12, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'select_doctype', 'fieldtype': 'Link', 'options': 'DocType', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Get Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02324', 'idx': 13, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': 'get_series', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 17:11:58', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Series Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02332', 'idx': 14, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'series_details', 'fieldtype': 'Table', 'options': 'Series Detail', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Update Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02325', 'idx': 15, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': 'remove_series', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Add New Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02326', 'idx': 16, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': 'Simple', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'New Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02327', 'idx': 17, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': 'new_series', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-06-12 16:42:30', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'nabin@webnotestech.com', 'label': 'Add Series', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ERP Setup', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02328', 'idx': 18, 'default': None, 'colour': None, 'modified': '2010-08-08 15:21:42', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': 'add_series', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/import_data_control/__init__.py b/setup/doctype/import_data_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/import_data_control/__init__.py
diff --git a/setup/doctype/import_data_control/import_data_control.py b/setup/doctype/import_data_control/import_data_control.py
new file mode 100644
index 0000000..b9c98f1
--- /dev/null
+++ b/setup/doctype/import_data_control/import_data_control.py
@@ -0,0 +1,34 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,d,dl):
+    self.doc, self.doclist = d,dl
+
+  def get_master_lst(self):
+    
+    return [r[0] for r in sql("select name from `tabDocType` where document_type = 'Master'")]
+
+  def get_child_lst(self,nm):
+    res = [nm]
+    
+    ret=sql("select options from `tabDocField` where parent='%s' and fieldtype = 'Table'"%nm)
+    for r in ret:
+      res.append(r[0])
+    return res
\ No newline at end of file
diff --git a/setup/doctype/import_data_control/import_data_control.txt b/setup/doctype/import_data_control/import_data_control.txt
new file mode 100644
index 0000000..6099670
--- /dev/null
+++ b/setup/doctype/import_data_control/import_data_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-09-17 16:54:59', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'harshada@webnotestech.com', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 13, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': '', 'name': 'Import Data Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-10-14 12:26:41', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/setup/doctype/item_group/__init__.py b/setup/doctype/item_group/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/item_group/__init__.py
diff --git a/setup/doctype/item_group/item_group.js b/setup/doctype/item_group/item_group.js
new file mode 100644
index 0000000..089ba11
--- /dev/null
+++ b/setup/doctype/item_group/item_group.js
@@ -0,0 +1,18 @@
+$import(Tips Common)
+
+cur_frm.cscript.onload = function(){
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+  if(doc.__islocal){
+    doc.parent_item_group = 'Root';
+    refresh('parent_item_group');
+  }
+}
+
+//get query select item group
+cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
+  return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "Yes" AND  `tabItem Group`.`docstatus`!= 2 AND (`tabItem Group`.`rgt` > '+doc.rgt+' or `tabItem Group`.`lft` < '+doc.lft+') AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY  `tabItem Group`.`name` ASC LIMIT 50';
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py
new file mode 100644
index 0000000..223e53d
--- /dev/null
+++ b/setup/doctype/item_group/item_group.py
@@ -0,0 +1,47 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,d,dl):
+    self.doc, self.doclist = d,dl
+    self.nsm_parent_field = 'parent_item_group';
+
+  # update Node Set Model
+  def update_nsm_model(self):
+    import webnotes
+    import webnotes.utils.nestedset
+    webnotes.utils.nestedset.update_nsm(self)
+
+  # ON UPDATE
+  #--------------------------------------
+  def on_update(self):
+    # update nsm
+    self.update_nsm_model()   
+
+  def validate(self): 
+    if self.doc.lft and self.doc.rgt:
+      res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name))
+      if not res:
+        msgprint("Please enter proper parent item group.") 
+        raise Exception
+    
+    r = sql("select name from `tabItem Group` where name = '%s' and docstatus = 2"%(self.doc.item_group_name))
+    if r:
+      msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.item_group_name))
+      raise Exception
\ No newline at end of file
diff --git a/setup/doctype/item_group/item_group.txt b/setup/doctype/item_group/item_group.txt
new file mode 100644
index 0000000..f54679b
--- /dev/null
+++ b/setup/doctype/item_group/item_group.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:09:42', 'search_fields': 'parent_item_group', 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 0, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 57, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:item_group_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Item Group', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00876', 'parent': 'Item Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-20 09:45:17', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00877', 'parent': 'Item Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-20 09:45:17', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00901', 'parent': 'Item Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-20 09:45:17', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00902', 'parent': 'Item Group', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-20 09:45:17', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00373', 'parent': 'Item Group', 'read': 1, 'create': 1, 'creation': '2009-08-25 17:00:42', 'modified': '2010-09-20 09:45:17', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 5, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00557', 'parent': 'Item Group', 'read': 1, 'create': 1, 'creation': '2009-12-31 12:21:10', 'modified': '2010-09-20 09:45:17', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 6, 'parenttype': 'DocType', 'role': 'Material Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04850', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:09:42', 'doctype': 'DocField', 'oldfieldname': 'item_group_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Item Group Name', 'width': '', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00610', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'item_group_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Check', 'creation': '2009-09-10 12:08:39', 'doctype': 'DocField', 'oldfieldname': 'show_in_catalogue', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Show in catalogue', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02931', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'show_in_catalogue', 'fieldtype': 'Check', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-03-26 17:09:28', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01479', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-06-16 10:38:12', 'doctype': 'DocField', 'oldfieldname': 'parent_item_group', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Parent Item Group', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05372', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'parent_item_group', 'fieldtype': 'Link', 'options': 'Item Group', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-17 09:19:13', 'doctype': 'DocField', 'oldfieldname': 'is_group', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Has Child Node', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': 'Only leaf nodes are allowed in transaction', 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05385', 'idx': 6, 'default': None, 'colour': 'White:FFF', 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'is_group', 'fieldtype': 'Select', 'options': '\nYes\nNo', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Int', 'creation': '2010-06-16 10:38:12', 'doctype': 'DocField', 'oldfieldname': 'lft', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'lft', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05376', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'lft', 'fieldtype': 'Int', 'options': None, 'report_hide': 0, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Int', 'creation': '2010-06-16 10:38:12', 'doctype': 'DocField', 'oldfieldname': 'rgt', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'rgt', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05377', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'rgt', 'fieldtype': 'Int', 'options': None, 'report_hide': 0, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-06-16 10:38:12', 'doctype': 'DocField', 'oldfieldname': 'old_parent', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'old_parent', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Item Group', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05378', 'idx': 9, 'default': None, 'colour': None, 'modified': '2010-09-20 09:45:17', 'parenttype': 'DocType', 'fieldname': 'old_parent', 'fieldtype': 'Data', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/manage_account/__init__.py b/setup/doctype/manage_account/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/manage_account/__init__.py
diff --git a/setup/doctype/manage_account/manage_account.js b/setup/doctype/manage_account/manage_account.js
new file mode 100644
index 0000000..7c3b193
--- /dev/null
+++ b/setup/doctype/manage_account/manage_account.js
@@ -0,0 +1,6 @@
+// Validate
+cur_frm.cscript.validate = function(doc, cdt, cdn) {
+  $c_obj(make_doclist(cdt, cdn), 'update_cp', '', function(r, rt){
+    sys_defaults = r.message;
+  });
+}
\ No newline at end of file
diff --git a/setup/doctype/manage_account/manage_account.py b/setup/doctype/manage_account/manage_account.py
new file mode 100644
index 0000000..a0ed2fa
--- /dev/null
+++ b/setup/doctype/manage_account/manage_account.py
@@ -0,0 +1,65 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import cint, cstr, get_defaults, set_default, fmt_money, get_last_day, get_first_day
+from webnotes import session, form, is_testing, msgprint, errprint
+
+sql = webnotes.conn.sql
+
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, d, dl):
+    self.doc, self.doclist = d, dl
+
+#---------------------------------------------------------------------------------------------------------------------------------------------  
+  def get_bal(self,arg):
+    bal = sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
+    if bal:
+      return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
+
+
+# =========================================================================================================================================
+
+  # Update Default
+  # ---------------
+  def set_system_default(self, defkey, defvalue):
+    set_default(defkey, defvalue)
+
+    if defkey == 'fiscal_year':
+      ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", defvalue)
+      ysd = ysd and ysd[0][0] or ''
+      if ysd:
+        set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
+        set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
+
+
+  # Update
+  # --------
+  def update_cp(self):
+    def_list = [['fiscal_year',self.doc.current_fiscal_year],
+                ['company',self.doc.default_company],
+                ['currency',self.doc.default_currency],
+                ['price_list_name',self.doc.default_price_list],
+                ['item_group',self.doc.default_item_group],
+                ['customer_group',self.doc.default_customer_group],
+                ['cust_master_name',self.doc.cust_master_name], 
+                ['supplier_type',self.doc.default_supplier_type],
+                ['supp_master_name',self.doc.supp_master_name], 
+                ['territory',self.doc.default_territory],
+                ['stock_uom',self.doc.default_stock_uom],
+                ['fraction_currency',self.doc.default_currency_fraction],
+                ['valuation_method',self.doc.default_valuation_method]]
+
+    for d in def_list:
+      self.set_system_default(d[0],d[1])
+    # Update Currency Format
+	
+    sql("update `tabSingles` set value = '%s' where field = 'currency_format' and doctype = 'Control Panel'" % self.doc.default_currency_format)
+    sql("update `tabSingles` set value = '%s' where field = 'date_format' and doctype = 'Control Panel'" %self.doc.date_format)
+
+
+    return get_defaults()
+
diff --git a/setup/doctype/manage_account/manage_account.txt b/setup/doctype/manage_account/manage_account.txt
new file mode 100644
index 0000000..0332d6b
--- /dev/null
+++ b/setup/doctype/manage_account/manage_account.txt
@@ -0,0 +1,1686 @@
+[
+	{
+		'_last_update': '1305783824',
+		'_user_tags': None,
+		'allow_attach': None,
+		'allow_copy': 1,
+		'allow_email': 1,
+		'allow_print': 1,
+		'allow_rename': None,
+		'allow_trash': None,
+		'autoname': None,
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': None,
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': 0,
+		'idx': None,
+		'in_create': 1,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': 1,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-05-19 11:16:11',
+		'modified_by': 'Guest',
+		'module': 'Setup',
+		'name': 'Manage Account',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': 1,
+		'read_only_onload': None,
+		'search_fields': None,
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 1,
+		'smallicon': None,
+		'subject': None,
+		'tag_fields': None,
+		'use_template': None,
+		'version': 514
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'creation': '2010-08-08 17:09:09',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': '',
+		'modified': '2010-08-25 12:12:09',
+		'modified_by': 'nabin@webnotestech.com',
+		'name': 'PERM00348',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': 1,
+		'creation': '2010-08-08 17:09:09',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-08-25 12:12:09',
+		'modified_by': 'nabin@webnotestech.com',
+		'name': 'PERM00349',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Administrator',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:09',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-08-25 12:12:09',
+		'modified_by': 'nabin@webnotestech.com',
+		'name': 'PERM00350',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Administrator',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:09',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-08-25 12:12:09',
+		'modified_by': 'nabin@webnotestech.com',
+		'name': 'PERM00351',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'All',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:09',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2010-08-25 12:12:09',
+		'modified_by': 'nabin@webnotestech.com',
+		'name': 'PERM00352',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 2,
+		'read': 1,
+		'role': 'Administrator',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Company',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05014',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_company',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Default Company',
+		'modified': '2011-05-25 12:44:24',
+		'modified_by': 'Guest',
+		'name': 'FL01956',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Company',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'current_fiscal_year',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Current Fiscal Year',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01957',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Fiscal Year',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'date_format',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Date Format',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01958',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05015',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': 'INR',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_currency',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Default Currency',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01960',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'link:Currency',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_currency_format',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Default Currency Format',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01961',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Lacs\nMillions',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-04-14 11:58:00',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_currency_fraction',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Default Currency Fraction',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': '000002366',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-12-31 17:48:36',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'sms_sender_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'SMS Sender Name',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL04394',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Stock',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05016',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05017',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_item_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': None,
+		'label': 'Default Item Group',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01963',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Item Group',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'IGHelp',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05018',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Item Group\');">To manage Item Groups, click here</a>',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_stock_uom',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'Default Stock UOM',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01965',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'UOM',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_valuation_method',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Default Valuation Method',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01966',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'FIFO\nMoving Average',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_warehouse_type',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Default Warehouse Type',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01967',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Warehouse Type',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05019',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Percentage you are allowed to receive or deliver more against the quantity ordered. <p>For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units</p>',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'tolerance',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': 'Allowance Percent',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01968',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': 'Stock level frozen up to this date, nobody can do / modify entry except authorized person',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'stock_frozen_upto',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Stock Frozen Upto',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05010',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': 'Users with this role are allowed to do / modify stock entry before frozen date',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'stock_auth_role',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Authorized Role (Frozen Entry)',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05011',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Role',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': None,
+		'label': 'Accounts',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05020',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Accounting entry frozen up to this date, nobody can do / modify entry except authorized person',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'acc_frozen_upto',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Accounts Frozen Upto',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01970',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Users with this role are allowed to do / modify accounting entry before frozen date',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'bde_auth_role',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 23,
+		'in_filter': None,
+		'label': 'Authourized Role (Frozen Entry)',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01971',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Role',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'credit_controller',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'Credit Controller',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01972',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Role',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': 'Selling',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05021',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-24 14:45:43',
+		'default': 'Customer Name',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'cust_master_name',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 26,
+		'in_filter': None,
+		'label': 'Customer Master created by ',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL03773',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Customer Name\nNaming Series',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_customer_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': None,
+		'label': 'Default Customer Group',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01974',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Customer Group',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 28,
+		'in_filter': None,
+		'label': 'CGHelp',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05022',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Customer Group\');">To manage Customer Groups, click here</a>',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_territory',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 29,
+		'in_filter': None,
+		'label': 'Default Territory',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01976',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 30,
+		'in_filter': None,
+		'label': 'TerritoryHelp',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05023',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Territory\');">To manage Territory, click here</a>',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_price_list',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 31,
+		'in_filter': None,
+		'label': 'Default Price List',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01978',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Price List',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 32,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05024',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': 'No',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'so_required',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 33,
+		'in_filter': None,
+		'label': 'Sales Order Required',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01980',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'No\nYes',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': 'No',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'dn_required',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 34,
+		'in_filter': None,
+		'label': 'Delivery Note Required',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01981',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'No\nYes',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 35,
+		'in_filter': None,
+		'label': 'Buying',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05025',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_supplier_type',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 36,
+		'in_filter': None,
+		'label': 'Default Supplier Type',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01983',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Supplier Type',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-24 14:45:43',
+		'default': 'Supplier Name',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'supp_master_name',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 37,
+		'in_filter': None,
+		'label': 'Supplier Master created by ',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL03774',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Supplier Name\nNaming Series',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 38,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05026',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': 'No',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'po_required',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 39,
+		'in_filter': None,
+		'label': 'Purchase Order Required',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01985',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'No\nYes',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': 'No',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'pr_required',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 40,
+		'in_filter': None,
+		'label': 'Purchase Receipt Required',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01986',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'No\nYes',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:25',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 41,
+		'in_filter': None,
+		'label': 'HR',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL05027',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<div style="padding-top: 8px;" class="columnHeading">HR</div>',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Employee record is created using selected field. ',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'emp_created_by',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 42,
+		'in_filter': None,
+		'label': 'Employee Records to be created by ',
+		'modified': '2011-05-25 12:44:25',
+		'modified_by': 'Guest',
+		'name': 'FL01988',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '\nNaming Series\nEmployee Number',
+		'owner': 'Administrator',
+		'parent': 'Manage Account',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/market_segment/__init__.py b/setup/doctype/market_segment/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/market_segment/__init__.py
diff --git a/setup/doctype/market_segment/market_segment.txt b/setup/doctype/market_segment/market_segment.txt
new file mode 100644
index 0000000..e531282
--- /dev/null
+++ b/setup/doctype/market_segment/market_segment.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:10:00', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 0, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 1, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:segment_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': None, 'name': 'Market Segment', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': 'Title Case', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Market Segment', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04852', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-04-28 11:34:36', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:10:00', 'doctype': 'DocField', 'oldfieldname': 'segment_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Segment Name', 'width': '', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Market Segment', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00912', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-04-28 11:34:36', 'parenttype': 'DocType', 'fieldname': 'segment_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-03-12 12:10:00', 'doctype': 'DocField', 'oldfieldname': 'details', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Market Segment', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00913', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-04-28 11:34:36', 'parenttype': 'DocType', 'fieldname': 'details', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/naming_series_options/__init__.py b/setup/doctype/naming_series_options/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/naming_series_options/__init__.py
diff --git a/setup/doctype/naming_series_options/naming_series_options.txt b/setup/doctype/naming_series_options/naming_series_options.txt
new file mode 100644
index 0000000..21f3f29
--- /dev/null
+++ b/setup/doctype/naming_series_options/naming_series_options.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-16 12:55:19', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 0, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': '__NSO.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Naming Series Options', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM01027', 'parent': 'Naming Series Options', 'read': 1, 'create': None, 'creation': '2010-06-03 11:30:14', 'modified': '2010-06-03 11:40:21', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-04-16 12:55:19', 'doctype': 'DocField', 'oldfieldname': 'doc_type', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Doc Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Naming Series Options', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04662', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-06-03 11:40:21', 'parenttype': 'DocType', 'fieldname': 'doc_type', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2010-04-16 12:55:19', 'doctype': 'DocField', 'oldfieldname': 'series_options', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Series Options', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Naming Series Options', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04663', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-06-03 11:40:21', 'parenttype': 'DocType', 'fieldname': 'series_options', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/order_lost_reason/__init__.py b/setup/doctype/order_lost_reason/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/order_lost_reason/__init__.py
diff --git a/setup/doctype/order_lost_reason/order_lost_reason.js b/setup/doctype/order_lost_reason/order_lost_reason.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/order_lost_reason/order_lost_reason.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/order_lost_reason/order_lost_reason.txt b/setup/doctype/order_lost_reason/order_lost_reason.txt
new file mode 100644
index 0000000..87fcf72
--- /dev/null
+++ b/setup/doctype/order_lost_reason/order_lost_reason.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-07-07 10:35:41', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 5, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:order_lost_reason', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Order Lost Reason', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00344', 'parent': 'Order Lost Reason', 'read': 1, 'create': 1, 'creation': '2009-07-07 10:35:41', 'modified': '2010-09-20 09:51:33', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00555', 'parent': 'Order Lost Reason', 'read': 1, 'create': 1, 'creation': '2009-12-31 12:18:01', 'modified': '2010-09-20 09:51:33', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Order Lost Reason', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04854', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:51:33', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-07-07 10:35:41', 'doctype': 'DocField', 'oldfieldname': 'order_lost_reason', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Order Lost Reason', 'width': '', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Order Lost Reason', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02544', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 09:51:33', 'parenttype': 'DocType', 'fieldname': 'order_lost_reason', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/other_charges/__init__.py b/setup/doctype/other_charges/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/other_charges/__init__.py
diff --git a/setup/doctype/other_charges/other_charges.comp.js b/setup/doctype/other_charges/other_charges.comp.js
new file mode 100644
index 0000000..403a4ce
--- /dev/null
+++ b/setup/doctype/other_charges/other_charges.comp.js
@@ -0,0 +1,29 @@
+
+cur_frm.cscript.onload=function(doc,cdt,cdn){}
+cur_frm.pformat.other_charges=function(doc){var make_row=function(title,val,bold){var bstart='<b>';var bend='</b>';return'<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
++'<td style="width:25%;text-align:right;">'+doc.currency+'</td>'
++'<td style="width:25%;text-align:right;">'+val+'</td>'
++'</tr>'}
+function convert_rate(val){var new_val=flt(val)/flt(doc.conversion_rate);return new_val;}
+out='';if(!doc.print_without_amount){var cl=getchildren('RV Tax Detail',doc.name,'other_charges');var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';out+='<table class="noborder" style="width:100%">'+make_row('Net Total',fmt_money(convert_rate(doc.net_total)),1);if(cl.length){for(var i=0;i<cl.length;i++){if(fmt_money(convert_rate(cl[i].tax_amount))!=0)
+out+=make_row(cl[i].description,fmt_money(convert_rate(cl[i].tax_amount)),0);}}
+out+=make_row('Grand Total',fmt_money(doc.grand_total_export),1)+make_row('Rounded Total',fmt_money(doc.rounded_total_export),1)
+if(doc.in_words_export){out+='</table></td></tr>';out+='<tr><td colspan = "2">';out+='<table><tr><td style="width:25%;"><b>In Words</b></td>'
+out+='<td style="width:50%;">'+doc.in_words_export+'</td></tr>'}
+out+='</table></td></tr></table></div>';}
+return out;}
+cur_frm.cscript.charge_type=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.idx==1&&(d.charge_type=='On Previous Row Amount'||d.charge_type=='On Previous Row Total')){alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");d.charge_type='';}
+validated=false;refresh_field('charge_type',d.name,'other_charges');cur_frm.cscript.row_id(doc,cdt,cdn);cur_frm.cscript.rate(doc,cdt,cdn);cur_frm.cscript.tax_amount(doc,cdt,cdn);}
+cur_frm.cscript.row_id=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.row_id){alert("Please select Charge Type first");d.row_id='';}
+else if((d.charge_type=='Actual'||d.charge_type=='On Net Total')&&d.row_id){alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");d.row_id='';}
+else if((d.charge_type=='On Previous Row Amount'||d.charge_type=='On Previous Row Total')&&d.row_id){if(d.row_id>=d.idx){alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");d.row_id='';}}
+validated=false;refresh_field('row_id',d.name,'other_charges');}
+cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query=function(doc,cdt,cdn){return'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND tabAccount.company = "'+doc.company+'" AND  tabAccount.name LIKE "%s"'}
+cur_frm.cscript.account_head=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.account_head){alert("Please select Charge Type first");validated=false;d.account_head='';}
+else if(d.account_head&&d.charge_type){arg="{'charge_type' : '"+d.charge_type+"', 'account_head' : '"+d.account_head+"'}";get_server_fields('get_rate',arg,'other_charges',doc,cdt,cdn,1);}
+refresh_field('account_head',d.name,'other_charges');}
+cur_frm.cscript.rate=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.rate){alert("Please select Charge Type first");d.rate='';}
+validated=false;refresh_field('rate',d.name,'other_charges');}
+cur_frm.cscript.tax_amount=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.tax_amount){alert("Please select Charge Type first");d.tax_amount='';}
+else if(d.charge_type&&d.tax_amount){alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");d.tax_amount='';}
+validated=false;refresh_field('tax_amount',d.name,'other_charges');}
\ No newline at end of file
diff --git a/setup/doctype/other_charges/other_charges.js b/setup/doctype/other_charges/other_charges.js
new file mode 100644
index 0000000..913b75f
--- /dev/null
+++ b/setup/doctype/other_charges/other_charges.js
@@ -0,0 +1,139 @@
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  //cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+/*cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}*/
+
+// For customizing print
+
+cur_frm.pformat.other_charges= function(doc){
+  //function to make row of table
+  var make_row = function(title,val,bold){
+    var bstart = '<b>'; var bend = '</b>';
+    return '<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+     +'<td style="width:25%;text-align:right;">'+doc.currency+'</td>'
+     +'<td style="width:25%;text-align:right;">'+val+'</td>'
+     +'</tr>'
+  }
+
+  function convert_rate(val){
+    var new_val = flt(val)/flt(doc.conversion_rate);
+    return new_val;
+  }
+  out ='';
+  if (!doc.print_without_amount) {
+    var cl = getchildren('RV Tax Detail',doc.name,'other_charges');
+
+    // outer table  
+    var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
+    
+    // main table
+    out +='<table class="noborder" style="width:100%">'+make_row('Net Total',fmt_money(convert_rate(doc.net_total)),1);
+
+    // add rows
+    if(cl.length){
+      for(var i=0;i<cl.length;i++){
+        if(fmt_money(convert_rate(cl[i].tax_amount))!=0)
+          out += make_row(cl[i].description,fmt_money(convert_rate(cl[i].tax_amount)),0);
+      }
+    }
+  
+    // grand total
+    out +=make_row('Grand Total',fmt_money(doc.grand_total_export),1) +make_row('Rounded Total',fmt_money(doc.rounded_total_export),1)
+    if(doc.in_words_export){
+      out +='</table></td></tr>';
+      out += '<tr><td colspan = "2">';
+      out += '<table><tr><td style="width:25%;"><b>In Words</b></td>'
+      out+= '<td style="width:50%;">'+doc.in_words_export+'</td></tr>'
+    }
+    out +='</table></td></tr></table></div>';   
+  }
+  return out;
+}
+
+cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
+    alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
+    d.charge_type = '';
+  }
+  validated = false;
+  refresh_field('charge_type',d.name,'other_charges');
+  cur_frm.cscript.row_id(doc, cdt, cdn);
+  cur_frm.cscript.rate(doc, cdt, cdn);
+  cur_frm.cscript.tax_amount(doc, cdt, cdn);
+}
+
+cur_frm.cscript.row_id = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(!d.charge_type && d.row_id){
+    alert("Please select Charge Type first");
+    d.row_id = '';
+  }
+  else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
+    alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
+    d.row_id = '';
+  }
+  else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
+    if(d.row_id >= d.idx){
+      alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
+      d.row_id = '';
+    }
+  }
+  validated = false;
+  refresh_field('row_id',d.name,'other_charges');
+}
+
+/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
+
+cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
+  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND tabAccount.company = "'+doc.company+'" AND  tabAccount.name LIKE "%s"'
+}
+
+//--------------------filter other charges master company-wise-----------------------------------------
+/*
+cur_frm.fields_dict.charge.get_query = function(doc) {
+  return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.name LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
+}
+*/
+
+cur_frm.cscript.account_head = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(!d.charge_type && d.account_head){
+    alert("Please select Charge Type first");
+    validated = false;
+    d.account_head = '';
+  }
+  else if(d.account_head && d.charge_type) {
+    arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
+    get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
+  }
+  refresh_field('account_head',d.name,'other_charges');
+}
+
+cur_frm.cscript.rate = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(!d.charge_type && d.rate) {
+    alert("Please select Charge Type first");
+    d.rate = '';
+  }
+  validated = false;
+  refresh_field('rate',d.name,'other_charges');
+}
+
+cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(!d.charge_type && d.tax_amount){
+    alert("Please select Charge Type first");
+    d.tax_amount = '';
+  }
+  else if(d.charge_type && d.tax_amount) {
+    alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
+    d.tax_amount = '';
+  }
+  validated = false;
+  refresh_field('tax_amount',d.name,'other_charges');
+}
diff --git a/setup/doctype/other_charges/other_charges.py b/setup/doctype/other_charges/other_charges.py
new file mode 100644
index 0000000..b8b9189
--- /dev/null
+++ b/setup/doctype/other_charges/other_charges.py
@@ -0,0 +1,34 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+
+  # Get Tax Rate if account type is Tax
+  # ===================================================================
+  def get_rate(self, arg):
+    get_obj('Sales Common').get_rate(arg, self)
+
+  def update_other_default_charges(self):
+    sql("update `tabOther Charges` set is_default = 0 where ifnull(is_default,0) = 1 and name != '%s' and company = '%s'" % (self.doc.name, self.doc.company))
+
+  def on_update(self):
+    self.update_other_default_charges()
diff --git a/setup/doctype/other_charges/other_charges.txt b/setup/doctype/other_charges/other_charges.txt
new file mode 100644
index 0000000..17d3e4d
--- /dev/null
+++ b/setup/doctype/other_charges/other_charges.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2010-12-08 15:42:09', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': None, 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 68, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:title', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Other Charges', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2011-01-07 11:04:07', 'server_code_error': ' ', 'name_case': None, 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00264', 'parent': 'Other Charges', 'read': 1, 'create': 0, 'creation': '2010-12-08 15:42:09', 'modified': '2011-01-07 11:04:07', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00265', 'parent': 'Other Charges', 'read': 1, 'create': 0, 'creation': '2010-12-08 15:42:09', 'modified': '2011-01-07 11:04:07', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00266', 'parent': 'Other Charges', 'read': 1, 'create': 0, 'creation': '2010-12-08 15:42:09', 'modified': '2011-01-07 11:04:07', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00267', 'parent': 'Other Charges', 'read': 1, 'create': 1, 'creation': '2010-12-08 15:42:09', 'modified': '2011-01-07 11:04:07', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 4, 'parenttype': 'DocType', 'role': 'Accounts Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00268', 'parent': 'Other Charges', 'read': 1, 'create': 1, 'creation': '2010-12-08 15:42:09', 'modified': '2011-01-07 11:04:07', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 5, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00269', 'parent': 'Other Charges', 'read': 1, 'create': 1, 'creation': '2010-12-08 15:42:09', 'modified': '2011-01-07 11:04:07', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 6, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-12-08 15:42:09', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Other Charges', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01785', 'idx': 1, 'default': None, 'colour': None, 'modified': '2011-01-07 11:04:07', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Section Break', 'creation': '2010-12-08 15:42:09', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'ashwini@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Other Charges Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Other Charges', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01786', 'idx': 2, 'default': None, 'colour': None, 'modified': '2011-01-07 11:04:07', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-12-08 15:42:09', 'doctype': 'DocField', 'oldfieldname': 'title', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Title', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Other Charges', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01787', 'idx': 3, 'default': None, 'colour': None, 'modified': '2011-01-07 11:04:07', 'parenttype': 'DocType', 'fieldname': 'title', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-06 14:27:42', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Default', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Other Charges', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03934', 'idx': 4, 'default': None, 'colour': None, 'modified': '2011-01-07 11:04:07', 'parenttype': 'DocType', 'fieldname': 'is_default', 'fieldtype': 'Check', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Table', 'creation': '2010-12-08 15:42:09', 'doctype': 'DocField', 'oldfieldname': 'other_charges', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Other Charges', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Other Charges', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01789', 'idx': 5, 'default': None, 'colour': None, 'modified': '2011-01-07 11:04:07', 'parenttype': 'DocType', 'fieldname': 'other_charges', 'fieldtype': 'Table', 'options': 'RV Tax Detail', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-12-08 15:42:09', 'doctype': 'DocField', 'oldfieldname': 'company', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Company', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Other Charges', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01788', 'idx': 6, 'default': None, 'colour': None, 'modified': '2011-01-07 11:04:07', 'parenttype': 'DocType', 'fieldname': 'company', 'fieldtype': 'Link', 'options': 'Company', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/period/__init__.py b/setup/doctype/period/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/period/__init__.py
diff --git a/setup/doctype/period/period.js b/setup/doctype/period/period.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/period/period.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/period/period.txt b/setup/doctype/period/period.txt
new file mode 100644
index 0000000..c1ec071
--- /dev/null
+++ b/setup/doctype/period/period.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-27 12:39:33', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'nabin@webnotestech.com', 'in_dialog': None, 'in_create': 1, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 6, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:period_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Period', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM01015', 'parent': 'Period', 'read': 1, 'create': None, 'creation': '2010-05-27 12:39:33', 'modified': '2010-09-20 09:52:50', 'submit': None, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'nabin@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM01016', 'parent': 'Period', 'read': 1, 'create': None, 'creation': '2010-05-27 12:39:33', 'modified': '2010-09-20 09:52:50', 'submit': None, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'nabin@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-05-27 12:46:35', 'doctype': 'DocField', 'oldfieldname': 'period_name', 'owner': 'nabin@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Period Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Period', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05083', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:52:50', 'parenttype': 'DocType', 'fieldname': 'period_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Date', 'creation': '2010-05-27 12:46:35', 'doctype': 'DocField', 'oldfieldname': 'start_date', 'owner': 'nabin@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Start Date', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Period', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05084', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 09:52:50', 'parenttype': 'DocType', 'fieldname': 'start_date', 'fieldtype': 'Date', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Date', 'creation': '2010-05-27 12:46:35', 'doctype': 'DocField', 'oldfieldname': 'end_date', 'owner': 'nabin@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'End Date', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Period', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05085', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 09:52:50', 'parenttype': 'DocType', 'fieldname': 'end_date', 'fieldtype': 'Date', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-05-27 12:46:35', 'doctype': 'DocField', 'oldfieldname': 'period_type', 'owner': 'nabin@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Period Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Period', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05086', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-09-20 09:52:50', 'parenttype': 'DocType', 'fieldname': 'period_type', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-05-27 12:46:35', 'doctype': 'DocField', 'oldfieldname': 'fiscal_year', 'owner': 'nabin@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Fiscal Year', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Period', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05087', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-09-20 09:52:50', 'parenttype': 'DocType', 'fieldname': 'fiscal_year', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/period_control/__init__.py b/setup/doctype/period_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/period_control/__init__.py
diff --git a/setup/doctype/period_control/period_control.py b/setup/doctype/period_control/period_control.py
new file mode 100644
index 0000000..a14f133
--- /dev/null
+++ b/setup/doctype/period_control/period_control.py
@@ -0,0 +1,61 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,d,dl):
+    self.doc, self.doclist = d, dl
+    
+  # Generate Periods
+  #------------------		
+  def generate_periods(self, fy):
+    ml = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')    
+
+    import webnotes.utils
+    from dateutil.relativedelta import relativedelta
+    
+    
+    if not sql("select name from `tabPeriod` where fiscal_year = '%s'" % fy):
+      ysd = sql("select year_start_date from `tabFiscal Year` where name = '%s'"%fy)[0][0]
+      
+      #create period as fiscal year record name
+      #----------------------------------------------
+      arg = {'pn':fy,'sd':ysd,'ed':webnotes.utils.get_last_day(ysd + relativedelta(months=11)).strftime('%Y-%m-%d'),'pt':'Year','fy':fy}
+      self.create_period(arg)
+            
+      for i in range(12):    
+        msd = ysd + relativedelta(months=i)
+
+        arg = {'pn':ml[cint(msd.strftime('%m'))-1] + ' ' + msd.strftime('%Y'),'sd':msd.strftime('%Y-%m-%d'),'ed':webnotes.utils.get_last_day(msd).strftime('%Y-%m-%d'),'pt':'Month','fy':fy}
+        self.create_period(arg)
+          
+  #---------------------------------------------------------
+  #create period common function        
+  def create_period(self,arg):
+    p = Document('Period')
+    p.period_name = arg['pn']
+    p.start_date = arg['sd']
+    p.end_date = arg['ed']
+    p.period_type = arg['pt']
+    p.fiscal_year = arg['fy']
+
+    try:        
+      p.save(1)  
+    except NameError, e:
+      msgprint('Period %s already exists' % p.period_name)
+      raise Exception
\ No newline at end of file
diff --git a/setup/doctype/period_control/period_control.txt b/setup/doctype/period_control/period_control.txt
new file mode 100644
index 0000000..c4cf440
--- /dev/null
+++ b/setup/doctype/period_control/period_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-27 12:47:10', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'nabin@webnotestech.com', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 36, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': None, 'name': 'Period Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/setup/doctype/personalize/__init__.py b/setup/doctype/personalize/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/personalize/__init__.py
diff --git a/setup/doctype/personalize/personalize.py b/setup/doctype/personalize/personalize.py
new file mode 100644
index 0000000..6a15102
--- /dev/null
+++ b/setup/doctype/personalize/personalize.py
@@ -0,0 +1,31 @@
+import webnotes
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+	
+	#
+	# load current banner
+	#
+	def onload(self):
+		self.doc.header_html = webnotes.conn.get_value('Control Panel', None, 'client_name')
+	
+	#
+	# on update
+	#
+	def validate(self):
+		if self.doc.file_list and self.doc.set_from_attachment:
+			self.set_html_from_image()
+
+		# update control panel - so it loads new letter directly
+		webnotes.conn.set_value('Control Panel', None, 'client_name', self.doc.header_html)
+		 
+		# clear the cache so that the new letter head is uploaded
+		webnotes.conn.sql("delete from __SessionCache")
+
+	#
+	# set html for image
+	#
+	def set_html_from_image(self):
+		file_name = self.doc.file_list.split(',')[0]
+		self.doc.header_html = '<div><img src="cgi-bin/getfile.cgi?name=' + file_name + '"/></div>'
diff --git a/setup/doctype/personalize/personalize.txt b/setup/doctype/personalize/personalize.txt
new file mode 100644
index 0000000..4270c47
--- /dev/null
+++ b/setup/doctype/personalize/personalize.txt
@@ -0,0 +1,196 @@
+[
+	{
+		'_last_update': None,
+		'allow_attach': 1,
+		'allow_copy': 1,
+		'allow_email': 1,
+		'allow_print': 1,
+		'allow_rename': None,
+		'allow_trash': None,
+		'autoname': None,
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-09 10:50:47',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Other',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': 1,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': 1,
+		'istable': None,
+		'max_attachments': 1,
+		'menu_index': None,
+		'modified': '2011-03-17 12:20:29',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'Personalize',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': 1,
+		'read_only_onload': None,
+		'search_fields': None,
+		'section_style': 'Simple',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': None,
+		'show_in_menu': None,
+		'smallicon': None,
+		'use_template': None,
+		'version': 4
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 10:50:47',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Help HTML',
+		'modified': '2011-05-09 10:50:47',
+		'modified_by': 'Administrator',
+		'name': '000000158',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<div class="help_box">You can edit HTML for your banner or add an attachment and click on "Set from Attachment"</div>',
+		'owner': 'Administrator',
+		'parent': 'Personalize',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 10:50:47',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'header_html',
+		'fieldtype': 'Code',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Banner HTML',
+		'modified': '2011-05-09 10:50:47',
+		'modified_by': 'Administrator',
+		'name': '000000159',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Personalize',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 10:50:47',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'set_from_attachment',
+		'fieldtype': 'Check',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Set from attachment',
+		'modified': '2011-05-09 10:50:47',
+		'modified_by': 'Administrator',
+		'name': '000000160',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Personalize',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 10:50:47',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'file_list',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'File List',
+		'modified': '2011-05-09 10:50:47',
+		'modified_by': 'Administrator',
+		'name': '000000161',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Personalize',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/price_list/__init__.py b/setup/doctype/price_list/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/price_list/__init__.py
diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js
new file mode 100644
index 0000000..2eeab84
--- /dev/null
+++ b/setup/doctype/price_list/price_list.js
@@ -0,0 +1,21 @@
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+	if(doc.__islocal) {
+		set_field_options('Price Help', ''); return;
+	}
+	if(!doc.file_list) {
+		set_field_options('Price Help', '<div class="help_box">To upload a price list, please attach a (.csv) file with 3 columns - <b>Item Code, Price and Currency</b> (no headings necessary). See attachments box in the right column</div>')
+	} else {
+		set_field_options('Price Help', '<div class="help_box">To update prices from the attachment, please click on "Update Prices"</div>')
+	}
+}
+
+cur_frm.cscript['Clear Prices'] = function(doc, cdt, cdn) {
+	if(confirm("This action will clear all rates for '"+ doc.name +"' from the Item Master and cannot be un-done. Are you sure you want to continue?")) {
+		$c_obj([doc], 'clear_prices', '', function(r, rt) { });
+	}
+}
diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py
new file mode 100644
index 0000000..23a43e7
--- /dev/null
+++ b/setup/doctype/price_list/price_list.py
@@ -0,0 +1,92 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+		self.cl = []
+	
+	# validate currency
+	def is_currency_valid(self, currency):
+		if currency in self.cl:
+			return 1
+			
+		if sql("select name from tabCurrency where name=%s", currency):
+			self.cl.append(currency)
+			return 1
+		else:
+			return 0
+	
+	# update prices in Price List
+	def update_prices(self):
+		import csv 
+		data = csv.reader(self.get_csv_data().splitlines())
+				
+		updated = 0
+		
+		for line in data:
+			if len(line)==3:
+				# if item exists
+				if sql("select name from tabItem where name=%s", line[0]):
+					if self.is_currency_valid(line[2]):
+						# if price exists
+						ref_ret_detail = sql("select name from `tabRef Rate Detail` where parent=%s and price_list_name=%s and ref_currency=%s", \
+							(line[0], self.doc.name, line[2]))
+						if ref_ret_detail:
+							sql("update `tabRef Rate Detail` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
+						else:
+							d = Document('Ref Rate Detail')
+							d.parent = line[0]
+							d.parentfield = 'ref_rate_details'
+							d.parenttype = 'Item'
+							d.price_list_name = self.doc.name
+							d.ref_rate = line[1]
+							d.ref_currency = line[2]
+							d.save(1)
+						updated += 1
+					else:
+						msgprint("[Ignored] Unknown currency '%s' for Item '%s'" % (line[2], line[0]))
+				else:
+					msgprint("[Ignored] Did not find Item '%s'" % line[1])
+			else:
+				msgprint("[Ignored] Incorrect format: %s" % str(line))
+		
+		msgprint("<b>%s</b> items updated" % updated)
+
+	# clear prices
+	def clear_prices(self):
+		cnt = sql("select count(*) from `tabRef Rate Detail` where price_list_name = %s", self.doc.name)
+		sql("delete from `tabRef Rate Detail` where price_list_name = %s", self.doc.name)
+		msgprint("%s prices cleared" % cnt[0][0])
+
+	# Update CSV data
+	def get_csv_data(self):
+		if not self.doc.file_list:
+		  msgprint("File not attached!")
+		  raise Exception
+
+		fid = self.doc.file_list.split(',')[1]
+		  
+		from webnotes.utils import file_manager
+		fn, content = file_manager.get_file(fid)
+		
+		if not type(content) == str:
+		  content = content.tostring()
+
+		return content	
\ No newline at end of file
diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt
new file mode 100644
index 0000000..e303d51
--- /dev/null
+++ b/setup/doctype/price_list/price_list.txt
@@ -0,0 +1,380 @@
+[
+	{
+		'allow_attach': 1,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': 'field:price_list_name',
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:13',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': None,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-04-18 10:01:48',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'Price List',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': None,
+		'read_only_onload': None,
+		'search_fields': None,
+		'section_style': 'Simple',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'use_template': None,
+		'version': 6
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:13',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2010-08-08 17:09:13',
+		'modified_by': 'Administrator',
+		'name': 'PERM00392',
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:13',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-08-08 17:09:13',
+		'modified_by': 'Administrator',
+		'name': 'PERM00393',
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:13',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-08-08 17:09:13',
+		'modified_by': 'Administrator',
+		'name': 'PERM00394',
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:13',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-08-08 17:09:13',
+		'modified_by': 'Administrator',
+		'name': 'PERM00395',
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:13',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': '',
+		'modified': '2010-08-08 17:09:13',
+		'modified_by': 'Administrator',
+		'name': 'PERM00396',
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Master Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:13',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-04-18 13:55:33',
+		'modified_by': 'Administrator',
+		'name': 'FL02242',
+		'no_copy': None,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:13',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'price_list_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Price List Name',
+		'modified': '2011-04-18 13:55:33',
+		'modified_by': 'Administrator',
+		'name': 'FL02243',
+		'no_copy': None,
+		'oldfieldname': 'price_list_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-04-18 13:55:34',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Price Help',
+		'modified': '2011-04-18 13:55:34',
+		'modified_by': 'Administrator',
+		'name': '000000143',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-04-18 13:55:33',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': 'Click on this button to clear prices for this list in all items',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Clear Prices',
+		'modified': '2011-04-18 13:55:33',
+		'modified_by': 'Administrator',
+		'name': '000000140',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-04-18 13:55:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'file_list',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'File List',
+		'modified': '2011-04-18 13:55:34',
+		'modified_by': 'Administrator',
+		'name': '000000141',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-04-18 13:55:34',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': 'Update prices from the attachment',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Update Prices',
+		'modified': '2011-04-18 13:55:34',
+		'modified_by': 'Administrator',
+		'name': '000000142',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'update_prices',
+		'owner': 'Administrator',
+		'parent': 'Price List',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Server',
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/sales_browser_control/__init__.py b/setup/doctype/sales_browser_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/sales_browser_control/__init__.py
diff --git a/setup/doctype/sales_browser_control/sales_browser_control.py b/setup/doctype/sales_browser_control/sales_browser_control.py
new file mode 100644
index 0000000..d4c4a13
--- /dev/null
+++ b/setup/doctype/sales_browser_control/sales_browser_control.py
@@ -0,0 +1,215 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,doc,doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+ 
+  #=============================================================================================
+  def get_record_list(self,arg):
+
+    parent, type = arg.split(',')
+    pt_col = "parent_"+type.replace(' ','_').lower()
+   
+    cl = sql("select name,is_group from `tab%s` where docstatus != 2 and %s ='%s' order by is_group desc"%(type,pt_col,parent),as_dict=1)
+
+    return {'parent':parent, 'cl':cl}
+
+  #=============================================================================================  
+  # --------get root level records like all territories, all sales person etc---------  
+  def get_fl_node(self,arg):
+
+    pt_col = "parent_"+arg.replace(' ','_').lower()
+    cl = sql("select name,is_group from `tab%s` where docstatus !=2 and %s=''"%(arg,pt_col),as_dict=1)
+    return {'cl':cl}
+
+  #=============================================================================================
+  def add_node(self,arg):
+    arg = eval(arg)
+    node_title = arg['node_title']
+    n = Document(node_title)
+    for d in arg.keys():
+      if d != 'node_title':
+        n.fields[d]=arg[d]
+    n.old_parent = ''      
+    n_obj = get_obj(doc=n)
+
+    n_obj.validate()
+
+    n_obj.doc.save(1)
+
+    n_obj.on_update()
+
+    return n_obj.doc.name
+      
+  #=============================================================================================
+  def trash_record(self,arg):  
+    name,type = arg.split(',')
+    
+    #validation for trash of default record
+    if not type == 'Sales Person':
+      field = 'default_'+type.lower().replace(' ','_')
+      chk = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = '%s' and value = '%s'"%(field,name))
+      if chk:
+        msgprint("'%s' record is set as a default %s in Global Defaults. Please change default %s then try to trash '%s' record."%(name,type.lower(), type.lower(), name))
+        raise Exception
+    
+    
+    res = sql("select t1.name from `tab%s` t1, `tab%s` t2 where t1.lft > t2.lft and t1.rgt < t2.rgt and t1.docstatus != 2 and t2.name = '%s'"%(type,type,name))
+    if res:
+      msgprint("You can not trashed %s as it contains other nodes."%name)
+      raise Exception
+      
+
+    sql("update `tab%s` set docstatus = 2 where name = '%s'"%(type,name))
+
+  #=============================================================================================    
+  def get_parent_lst(self,type):
+    par_lst = [r[0] for r in sql("select name from `tab%s` where is_group = 'Yes' and docstatus != 2"%type)]
+    return par_lst
+ 
+  #=============================================================================================
+  def get_record(self,arg):
+
+    name, type = arg.split(',')
+
+    dict1 = {'Territory':'parent_territory','Customer Group':'parent_customer_group','Item Group':'parent_item_group','Sales Person':'parent_sales_person'}
+    
+    parent_name = dict1[type]
+    
+    query ="select name,"+dict1[type]+",is_group,rgt,lft from `tab"+cstr(type)+"` where name = '%s'"
+  
+    sv = sql(query%(cstr(name)))
+ 
+ 
+    par_lst = [r[0] for r in sql("select distinct name from `tab"+cstr(type)+"` where docstatus !=2 and (rgt > %s or lft < %s) and is_group='Yes'"%(sv[0][3],sv[0][4]))]
+ 
+    dict2 = {}
+    dict2['name']=sv[0][0]
+    dict2['parent']=cstr(sv[0][1])
+    dict2['parent_lst']=par_lst
+    dict2['is_group']=sv[0][2]
+
+    return dict2
+    
+  #=============================================================================================
+  def edit_node(self,arg):
+    arg = eval(arg)
+    nt = arg['node_title']
+
+    nm = nt == 'Territory' and arg['territory_name'] or nt == 'Sales Person' and arg['sales_person_name'] or nt=='Item Group' and arg['item_group_name'] or nt =='Customer Group' and arg['customer_group_name'] or ''
+    
+    n_obj = get_obj(nt,nm) 
+    for d in arg.keys():
+      if d != 'node_title':
+        n_obj.doc.fields[d]=arg[d]
+   
+    n_obj.doc.save()
+    n_obj.on_update()
+   
+  
+  #=============== validation ======================================================================================
+
+  def mvalidate(self,args):
+
+    r = eval(args)
+    
+    if r['lft'] == 0:
+      n = sql("select lft,rgt from `tab%s` where name = '%s'"%(r['node_title'],r['nm']))
+      r['lft'] = n[0][0]
+      r['rgt'] = n[0][1]
+    
+    if r['action'] == 'Update':
+      #-----------------validate if current node has child node----------------------------------
+      v1 = self.val_group(r) 
+      if v1 == 'true': return 'true' 
+
+      
+      #-------------------validation for parent sales person cannot be his child node------------
+      v1 = self.val_prt(r) 
+      if v1 == 'true': return 'true'     
+      
+      #--------if current record has set as default record in manage account then should not allow to change 'has child node' to 'yes'
+      v1 = self.group_changed(r) 
+      if v1 == 'true': return 'true'     
+      
+    elif r['action'] == 'Create':
+      #-------------------validation - record is already exist--------------------------------
+      v1 = self.duplicate_rcd(r)
+
+      if v1 == 'true': return 'true' 
+      
+      #-------------------------------------------------
+      v1 = self.trash_rcd(r)
+      if v1 == 'true': return 'true' 
+
+    return 'false'     
+  #-----------------validate if current node has child node----------------------------------
+  #------------------if yes then cannot change current node from group to leaf
+  #ON EDIT
+  def val_group(self,r):
+    if r['is_group'] == 'No':
+      ch = sql("select name from `tab%s` where lft>%s and rgt<%s and docstatus != 2"%(r['node_title'],r['lft'],r['rgt']))
+      if ch:
+        msgprint("You can not changed %s from group to leaf node as it contains other nodes."%r['nm'])    
+        return 'true'
+    return 'false'  
+    
+   #-------------------validation for parent sales person cannot be his child node-------------               
+   #ON EDIT
+  def val_prt(self,r):
+    res = sql("select name from `tab%s` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(r['node_title'],r['rgt'],r['lft'],r['parent_nm'],r['nm']))
+
+    if not res:
+      msgprint("Please enter parent %s."%(r['node_title'])) 
+      return 'true'
+    return 'false'
+      
+  #--------if current record has set as default record then not allowed to changed 'has child node' to 'yes'--------------------      
+  #--------------------------------------------------------
+  #ON EDIT
+  def group_changed(self,r):
+
+    if r['node_title']  != 'Sales Person' and r['is_group'] == 'Yes':
+      field = 'default_'+r['node_title'].lower().replace(' ','_')
+      res = sql("select value from `tabSingles` where field = '%s' and value = '%s'"%(field,r['nm']))
+      if res:
+        msgprint("'%s' record is set as default record in Global Defaults.'Has Child Node' field cannot be changed to 'Yes' as only leaf nodes are allowed in transaction."%(r['nm']))
+        return 'true'
+      
+    return 'false'
+  #-------------------validation - record is already exist--------------------------------
+  #ON CREATE
+  def trash_rcd(self,r):
+    res = sql("select name from `tab%s` where name = '%s' and docstatus = 2"%(r['node_title'],r['nm']))
+    if res:
+      msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(r['nm']))
+      return 'true'
+
+    return 'false'
+
+  #----------------------------------------------------------------  
+  #ON CREATE
+  def duplicate_rcd(self,r):
+    res = sql("select name from `tab%s` where name = '%s' and docstatus != 2"%(r['node_title'],r['nm']))
+    if res:
+      msgprint("'%s' record is already exist."%(r['nm']))
+      return 'true'
+    return 'false'      
\ No newline at end of file
diff --git a/setup/doctype/sales_browser_control/sales_browser_control.txt b/setup/doctype/sales_browser_control/sales_browser_control.txt
new file mode 100644
index 0000000..8ab44e1
--- /dev/null
+++ b/setup/doctype/sales_browser_control/sales_browser_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-17 15:07:09', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 157, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': None, 'name': 'Sales Browser Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/setup/doctype/sales_partner/__init__.py b/setup/doctype/sales_partner/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/sales_partner/__init__.py
diff --git a/setup/doctype/sales_partner/sales_partner.js b/setup/doctype/sales_partner/sales_partner.js
new file mode 100644
index 0000000..e829e29
--- /dev/null
+++ b/setup/doctype/sales_partner/sales_partner.js
@@ -0,0 +1,148 @@
+$import(Contact Control)
+
+cur_frm.cscript.onload = function(doc,dt,dn){
+	// history doctypes and scripts
+	cur_frm.history_dict = {
+		'Sales Order' : 'cur_frm.cscript.make_so_list(this.body, this.doc)',
+		'Delivery Note' : 'cur_frm.cscript.make_dn_list(this.body, this.doc)',
+		'Sales Invoice' : 'cur_frm.cscript.make_si_list(this.body, this.doc)'
+	}
+	
+	// make contact, history list body
+	//cur_frm.cscript.make_cl_body();
+	cur_frm.cscript.make_hl_body();
+}
+
+cur_frm.cscript.refresh = function(doc,dt,dn){  
+  
+	if(doc.__islocal){
+		hide_field(['Address HTML','Contact HTML']);
+		//cur_frm.cscript.set_cl_msg(doc);
+		//cur_frm.cscript.set_hl_msg(doc);		
+	}
+	else{
+		unhide_field(['Address HTML','Contact HTML']);
+		// make lists
+		cur_frm.cscript.make_address(doc,dt,dn);
+		cur_frm.cscript.make_contact(doc,dt,dn);
+		cur_frm.cscript.make_history(doc,dt,dn);
+	}
+}
+
+
+cur_frm.cscript.make_address = function() {
+	if(!cur_frm.address_list) {
+		cur_frm.address_list = new wn.widgets.Listing({
+			parent: cur_frm.fields_dict['Address HTML'].wrapper,
+			page_length: 2,
+			new_doctype: "Address",
+			new_doc_onload: function(dn) {
+				ndoc = locals["Address"][dn];
+				ndoc.sales_partner = cur_frm.doc.name;
+				ndoc.address_type = 'Office';				
+			},
+			new_doc_onsave: function(dn) {				
+				cur_frm.address_list.run()
+			},			
+			get_query: function() {
+				return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc"
+			},
+			as_dict: 1,
+			no_results_message: 'No addresses created',
+			render_row: function(wrapper, data) {
+				$(wrapper).css('padding','5px 0px');
+				var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'});
+				link.dn = data.name
+				
+				$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : ''));				
+				$a(wrapper,'div','',{marginTop:'5px', color:'#555'}, data.address_line1 + '<br />' + (data.address_line2 ? data.address_line2 + '<br />' : '') + data.city + '<br />' + (data.state ? data.state + ', ' : '') + data.country + '<br />' + (data.pincode ? 'Pincode: ' + data.pincode + '<br />' : '') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.fax ? 'Fax: ' + data.fax + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : ''));
+			}
+		});
+	}
+	cur_frm.address_list.run();
+}
+
+cur_frm.cscript.make_contact = function() {
+	if(!cur_frm.contact_list) {
+		cur_frm.contact_list = new wn.widgets.Listing({
+			parent: cur_frm.fields_dict['Contact HTML'].wrapper,
+			page_length: 2,
+			new_doctype: "Contact",
+			new_doc_onload: function(dn) {
+				ndoc = locals["Contact"][dn];
+				ndoc.sales_partner = cur_frm.doc.name;				
+			},
+			new_doc_onsave: function(dn) {				
+				cur_frm.contact_list.run()
+			},
+			get_query: function() {
+				return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
+			},
+			as_dict: 1,
+			no_results_message: 'No contacts created',
+			render_row: function(wrapper, data) {
+				$(wrapper).css('padding', '5px 0px');
+				var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'});
+				link.dn = data.name
+
+				$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : ''));
+				$a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '<br />' : '<br>') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : '') + (data.department ? 'Department: ' + data.department + '<br />' : '') + (data.designation ? 'Designation: ' + data.designation + '<br />' : ''));
+			}
+		});
+	}
+	cur_frm.contact_list.run();
+
+}
+
+// ******************** ITEM Group ******************************** 
+cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {
+  return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
+}
+
+// make sales order list
+cur_frm.cscript.make_so_list = function(parent, doc){
+	var lst = new Listing();
+	lst.colwidths = ['5%','20%','20%','15%','20%','20%'];
+	lst.colnames = ['Sr.','Id','Status','SO Date','Total Commission','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Currency','Currency'];
+	lst.coloptions = ['','Sales Order','','','','',''];
+
+	cur_frm.cscript.set_list_opts(lst);
+	
+	var q = repl("select name,status,transaction_date, total_commission,grand_total from `tabSales Order` where sales_partner='%(sp)s'", {'sp':doc.name});
+	var q_max = repl("select count(name) from `tabSales Order` where sales_partner='%(cust)s'", {'sp':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Sales Order','Sales Order');
+}
+
+// make delivery note list
+cur_frm.cscript.make_dn_list = function(parent,doc){
+	var lst = new Listing();
+	lst.colwidths = ['5%','20%','20%','15%','20%','20%'];
+	lst.colnames = ['Sr.','Id','Status','Date','Total Commission','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Currency','Currency'];
+	lst.coloptions = ['','Delivery Note','','','','',''];
+
+	cur_frm.cscript.set_list_opts(lst);
+
+	var q = repl("select name,status,transaction_date, total_commission,grand_total from `tabDelivery Note` where sales_partner='%(sp)s'", {'sp':doc.name});
+	var q_max = repl("select count(name) from `tabDelivery Note` where sales_partner='%(cust)s'", {'sp':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Delivery Note','Delivery Note');	
+}
+
+// make sales invoice list
+cur_frm.cscript.make_si_list = function(parent,doc){
+	var lst = new Listing();
+	lst.colwidths = ['5%','25%','20%','25%','25%'];
+	lst.colnames = ['Sr.','Id','Invoice Date','Total Commission','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Currency','Currency'];
+	lst.coloptions = ['','Receivable Voucher','','','',''];
+
+	cur_frm.cscript.set_list_opts(lst);
+
+	var q = repl("select name,posting_date, total_commission,grand_total from `tabReceivable Voucher` where sales_partner='%(sp)s'", {'sp':doc.name});
+	var q_max = repl("select count(name) from `tabReceivable Voucher` where sales_partner='%(cust)s'", {'sp':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Sales Invoice','Receivable Voucher');	
+}
diff --git a/setup/doctype/sales_partner/sales_partner.py b/setup/doctype/sales_partner/sales_partner.py
new file mode 100644
index 0000000..7258611
--- /dev/null
+++ b/setup/doctype/sales_partner/sales_partner.py
@@ -0,0 +1,48 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.prefix = is_testing and 'test' or 'tab'
+
+  def validate(self):
+    import string
+  
+    if not (self.doc.address_line1)  and not (self.doc.address_line2) and not (self.doc.city) and not (self.doc.state) and not (self.doc.country) and not (self.doc.pincode):
+      return "Please enter address"
+      
+    else:
+      address =["address_line1", "address_line2", "city", "state", "country", "pincode"]
+      comp_address=''
+      for d in address:
+        if self.doc.fields[d]:
+          comp_address += self.doc.fields[d] + "\n"
+      self.doc.address = comp_address
+
+  def check_state(self):
+    return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
+    
+  def get_contacts(self,nm):
+    if nm:
+      contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm))
+      return contact_details
+    else:
+      return ''
\ No newline at end of file
diff --git a/setup/doctype/sales_partner/sales_partner.txt b/setup/doctype/sales_partner/sales_partner.txt
new file mode 100644
index 0000000..f4c2857
--- /dev/null
+++ b/setup/doctype/sales_partner/sales_partner.txt
@@ -0,0 +1,927 @@
+[
+	{
+		'_last_update': '1305622930',
+		'_user_tags': None,
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': 'field:partner_name',
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': 0,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-05-17 14:32:10',
+		'modified_by': 'Guest',
+		'module': 'Setup',
+		'name': 'Sales Partner',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': 0,
+		'read_only_onload': None,
+		'search_fields': None,
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'subject': None,
+		'tag_fields': None,
+		'use_template': None,
+		'version': 72
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00504',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00505',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00506',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00507',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00508',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Master Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00509',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Master Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': None,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 7,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00510',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': 0,
+		'creation': '2010-08-08 17:09:22',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 8,
+		'match': None,
+		'modified': '2010-08-08 17:09:22',
+		'modified_by': 'Administrator',
+		'name': 'PERM00511',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': None,
+		'write': 0
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': 'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Basic Info',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05429',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'partner_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': 1,
+		'label': 'Sales Partner Name',
+		'modified': '2011-05-25 12:45:32',
+		'modified_by': 'Guest',
+		'name': 'FL03128',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'partner_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'partner_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Partner Type',
+		'modified': '2011-05-25 12:45:32',
+		'modified_by': 'Guest',
+		'name': 'FL03129',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'partner_type',
+		'oldfieldtype': 'Select',
+		'options': '\nChannel Partner\nDistributor\nDealer\nAgent\nRetailer\nImplementation Partner\nReseller',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05430',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'commission_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Commission Rate',
+		'modified': '2011-05-25 12:45:32',
+		'modified_by': 'Guest',
+		'name': 'FL03130',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'commission_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Territory',
+		'modified': '2011-05-25 12:45:32',
+		'modified_by': 'Guest',
+		'name': 'FL03143',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Address & Contacts',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05431',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': 'eval:doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Address Desc',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05432',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<em>Addresses will appear only when you save the customer</em>',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Address HTML',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05433',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05434',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': 'eval:doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Contact Desc',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05435',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '<em>Contact Details will appear only when you save the customer</em>',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': None,
+		'label': 'Contact HTML',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05436',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Partner Target Details',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05437',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'distribution_id',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'Distribution Id',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL03148',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'distribution_id',
+		'oldfieldtype': 'Link',
+		'options': 'Budget Distribution',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'partner_target_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Partner Target Detail',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL03149',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'partner_target_details',
+		'oldfieldtype': 'Table',
+		'options': 'Target Detail',
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': 1,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Manage HTML',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05438',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': 'Transaction History',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05439',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'yogesh@webnotestech.com',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': 'History HTML',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL05440',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': None,
+		'owner': 'yogesh@webnotestech.com',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-05-25 12:45:33',
+		'modified_by': 'Guest',
+		'name': 'FL03124',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Partner',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/sales_person/__init__.py b/setup/doctype/sales_person/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/sales_person/__init__.py
diff --git a/setup/doctype/sales_person/sales_person.js b/setup/doctype/sales_person/sales_person.js
new file mode 100644
index 0000000..aef79a3
--- /dev/null
+++ b/setup/doctype/sales_person/sales_person.js
@@ -0,0 +1,48 @@
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+}
+
+cur_frm.cscript.onload = function(){
+  if(doc.__islocal){
+    doc.parent_sales_person = 'Root';
+    refresh('parent_sales_person');
+  }
+}
+cur_frm.cscript.country = function(doc, cdt, cdn) {
+  var mydoc=doc;
+  $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
+    function(r,rt){
+      if(r.message) {
+        var doc = locals[mydoc.doctype][mydoc.name];
+        doc.state = '';
+        get_field(doc.doctype, 'state' , doc.name).options = r.message;
+        refresh_field('state');
+      }
+    }  
+  );
+}
+
+cur_frm.cscript.TreePage = function(nm){
+  var call_back = function(){
+    var sb_obj = new SalesBrowser();        
+    sb_obj.set_val(nm);
+
+  }
+  loadpage('Sales Browser',call_back);
+
+}
+
+//get query select sales person
+cur_frm.fields_dict['parent_sales_person'].get_query = function(doc,cdt,cdn) {
+  return 'SELECT `tabSales Person`.`name`,`tabSales Person`.`parent_sales_person` FROM `tabSales Person` WHERE `tabSales Person`.`is_group` = "Yes" AND `tabSales Person`.`docstatus`!= 2 AND (`tabSales Person`.`rgt` > '+doc.rgt+' or `tabSales Person`.`lft` < '+doc.lft+') AND `tabSales Person`.`name` !="'+doc.sales_person_name+'" AND `tabSales Person`.%(key)s LIKE "%s" ORDER BY  `tabSales Person`.`name` ASC LIMIT 50';
+}
+
+//get query select Territory
+cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
+  return 'SELECT `tabTerritory`.`name` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY  `tabTerritory`.`name` ASC LIMIT 50';
+}
+
+// ******************** ITEM Group ******************************** 
+cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabItem Group`.name FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
+}
diff --git a/setup/doctype/sales_person/sales_person.py b/setup/doctype/sales_person/sales_person.py
new file mode 100644
index 0000000..f085376
--- /dev/null
+++ b/setup/doctype/sales_person/sales_person.py
@@ -0,0 +1,67 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.model.doc import Document
+from webnotes.model.doclist import getlist
+from webnotes.model.code import get_obj
+from webnotes import session, form, is_testing, msgprint, errprint
+
+sql = webnotes.conn.sql
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.nsm_parent_field = 'parent_sales_person';
+
+  def check_state(self):
+    return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
+
+
+  # update Node Set Model
+  def update_nsm_model(self):
+    import webnotes
+    import webnotes.utils.nestedset
+    webnotes.utils.nestedset.update_nsm(self)
+
+  # ON UPDATE
+  #--------------------------------------
+  def on_update(self):
+    # update nsm
+    self.update_nsm_model()   
+
+
+  def validate(self): 
+
+    for d in getlist(self.doclist, 'target_details'):
+      if not flt(d.target_qty) and not flt(d.target_amount):
+        msgprint("Either target qty or target amount is mandatory.")
+        raise Exception
+        
+    #self.sync_with_contact()
+    
+  def sync_with_contact(self):
+    cid = sql("select name from tabContact where sales_person_id = %s and is_sales_person=1", self.doc.name)
+    if cid:
+      d = Document('Contact', cid[0][0])
+    else:
+      d = Document('Contact')
+    
+    name_split = self.doc.sales_person_name.split()
+    d.contact_name = self.doc.sales_person_name
+    d.first_name = name_split[0]
+    d.last_name = len(name_split) > 1 and name_split[1] or ''
+    d.email_id = self.doc.email_id
+    d.contact_no = d.mobile_no = self.doc.mobile_no
+    d.designation = self.doc.designation
+    d.department = self.doc.department
+    d.sales_person_id = self.doc.name
+    d.is_sales_person = 1
+    
+    d.save(new = (not d.name))
+    
+    
diff --git a/setup/doctype/sales_person/sales_person.txt b/setup/doctype/sales_person/sales_person.txt
new file mode 100644
index 0000000..f99653c
--- /dev/null
+++ b/setup/doctype/sales_person/sales_person.txt
@@ -0,0 +1,1420 @@
+[
+	{
+		'_last_update': '1300960454',
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': 'field:sales_person_name',
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-11-30 22:43:05',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': 1,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': None,
+		'last_update': '1294161036',
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2010-11-18 12:16:35',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'Sales Person',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': None,
+		'read_only_onload': None,
+		'search_fields': 'name,parent_sales_person',
+		'section_style': 'Simple',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'use_template': None,
+		'version': 133
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:25:37',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00443',
+		'no_copy': None,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03156',
+		'no_copy': None,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-24 15:58:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'General Info',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': '000006299',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'sales_person_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Sales Person Name',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL03158',
+		'no_copy': None,
+		'oldfieldname': 'sales_person_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select company name first.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'parent_sales_person',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Parent Sales Person',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL03159',
+		'no_copy': None,
+		'oldfieldname': 'parent_sales_person',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Person',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-24 15:58:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'SPHelp',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': '000006300',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Sales Person\');">To manage Sales Person, click here</a>',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'is_group',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Has Child Node',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL03042',
+		'no_copy': None,
+		'oldfieldname': 'is_group',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'is_group',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Has Child Node',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03161',
+		'no_copy': None,
+		'oldfieldname': 'is_group',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:41:52',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'department',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Department',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL02338',
+		'no_copy': None,
+		'oldfieldname': 'department',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'department',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Department',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03162',
+		'no_copy': None,
+		'oldfieldname': 'department',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:30:36',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'designation',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Designation',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00728',
+		'no_copy': None,
+		'oldfieldname': 'designation',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'designation',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Designation',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03163',
+		'no_copy': None,
+		'oldfieldname': 'designation',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:31:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'mobile_no',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Mobile No',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL01300',
+		'no_copy': None,
+		'oldfieldname': 'mobile_no',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'mobile_no',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Mobile No',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03164',
+		'no_copy': None,
+		'oldfieldname': 'mobile_no',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-24 15:58:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': '000006301',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:31:13',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'email_id',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Email Id',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL01157',
+		'no_copy': None,
+		'oldfieldname': 'email_id',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'email_id',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Email Id',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03166',
+		'no_copy': None,
+		'oldfieldname': 'email_id',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2009-05-12 11:19:12',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'country',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'Country',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00177',
+		'no_copy': None,
+		'oldfieldname': 'country',
+		'oldfieldtype': 'Select',
+		'options': 'link:Country',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'country',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'Country',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03167',
+		'no_copy': None,
+		'oldfieldname': 'country',
+		'oldfieldtype': 'Select',
+		'options': 'link:Country',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2009-05-12 11:19:12',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'state',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': 1,
+		'label': 'State',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00176',
+		'no_copy': None,
+		'oldfieldname': 'state',
+		'oldfieldtype': 'Select',
+		'options': 'link:State',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'state',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': 1,
+		'label': 'State',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03168',
+		'no_copy': None,
+		'oldfieldname': 'state',
+		'oldfieldtype': 'Select',
+		'options': 'link:State',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2009-05-12 11:19:12',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'city',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'City',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00174',
+		'no_copy': None,
+		'oldfieldname': 'city',
+		'oldfieldtype': 'Select',
+		'options': 'link:City',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'city',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'City',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03169',
+		'no_copy': None,
+		'oldfieldname': 'city',
+		'oldfieldtype': 'Select',
+		'options': 'link:City',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Territory',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL03170',
+		'no_copy': None,
+		'oldfieldname': 'territory',
+		'oldfieldtype': 'Link',
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-24 15:58:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Territory Help',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': '000006302',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Territory\');">To manage Territory, click here</a>',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:30:32',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lft',
+		'fieldtype': 'Int',
+		'hidden': 1,
+		'icon': None,
+		'idx': 17,
+		'in_filter': 1,
+		'label': 'lft',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00618',
+		'no_copy': 1,
+		'oldfieldname': 'lft',
+		'oldfieldtype': 'Int',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lft',
+		'fieldtype': 'Int',
+		'hidden': 1,
+		'icon': None,
+		'idx': 17,
+		'in_filter': 1,
+		'label': 'lft',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03172',
+		'no_copy': 1,
+		'oldfieldname': 'lft',
+		'oldfieldtype': 'Int',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:30:32',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rgt',
+		'fieldtype': 'Int',
+		'hidden': 1,
+		'icon': None,
+		'idx': 18,
+		'in_filter': 1,
+		'label': 'rgt',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00619',
+		'no_copy': 1,
+		'oldfieldname': 'rgt',
+		'oldfieldtype': 'Int',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rgt',
+		'fieldtype': 'Int',
+		'hidden': 1,
+		'icon': None,
+		'idx': 18,
+		'in_filter': 1,
+		'label': 'rgt',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03173',
+		'no_copy': 1,
+		'oldfieldname': 'rgt',
+		'oldfieldtype': 'Int',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:30:32',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'old_parent',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'old_parent',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00617',
+		'no_copy': 1,
+		'oldfieldname': 'old_parent',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'old_parent',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'old_parent',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03174',
+		'no_copy': 1,
+		'oldfieldname': 'old_parent',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 17:30:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'distribution_id',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Distribution Id',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL00673',
+		'no_copy': None,
+		'oldfieldname': 'distribution_id',
+		'oldfieldtype': 'Link',
+		'options': 'Budget Distribution',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:05',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'distribution_id',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Distribution Id',
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'FL03175',
+		'no_copy': None,
+		'oldfieldname': 'distribution_id',
+		'oldfieldtype': 'Link',
+		'options': 'Budget Distribution',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-24 15:58:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': None,
+		'label': 'Target Details',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': '000006303',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-11-30 22:43:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'target_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Target Details1',
+		'modified': '2011-03-24 15:58:01',
+		'modified_by': 'Administrator',
+		'name': 'FL03177',
+		'no_copy': None,
+		'oldfieldname': 'target_details',
+		'oldfieldtype': 'Table',
+		'options': 'Target Detail',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-11-30 22:43:05',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'PERM00558',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-11-30 22:43:05',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'PERM00559',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-11-30 22:43:05',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'PERM00560',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-11-30 22:43:05',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'PERM00561',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-11-30 22:43:05',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'PERM00562',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Master Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-11-30 22:43:05',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2010-11-30 22:43:05',
+		'modified_by': 'Administrator',
+		'name': 'PERM00563',
+		'owner': 'Administrator',
+		'parent': 'Sales Person',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Master Manager',
+		'submit': 0,
+		'write': 0
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/setup_control/__init__.py b/setup/doctype/setup_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/setup_control/__init__.py
diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py
new file mode 100644
index 0000000..9712860
--- /dev/null
+++ b/setup/doctype/setup_control/setup_control.py
@@ -0,0 +1,177 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, d, dl):
+    self.doc, self.doclist = d, dl
+  
+  #Default Naming Series
+  #---------------------------------------------------
+  def naming_series(self):
+    ns = [['TDS Payment', 'TDSP'], ['Payable Voucher', 'BILL'], ['Journal Voucher', 'JV'], ['Receivable Voucher', 'INV'], ['Lead', 'Lead'], ['Indent', 'IDT'], ['Enquiry', 'Enquiry'], ['Purchase Order', 'PO'], ['Quotation', 'QTN'], ['Purchase Receipt', 'GRN'], ['Stock Entry', 'STE'], ['Sales Order', 'SO'], ['Delivery Note', 'DN'], ['Employee', 'EMP/']]
+    for r in ns: 
+      rec = Document('Naming Series')
+      rec.select_doc_for_series = r[0]
+      rec.new_series = r[1]
+      rec_obj = get_obj(doc=rec)
+      rec_obj.add_series()
+
+  # set account details
+  #-----------------------
+  def set_account_details(self, args):
+    args = eval(args)
+    
+    self.set_cp_defaults(args['company_name'], args['industry'], args['time_zone'], args['country'], args['account_name'])
+    self.create_profile(args['user'], args['first_name'], args['last_name'])  
+    self.update_client_control()
+    
+  
+  # Account Setup
+  # ---------------
+  def setup_account(self, args):
+    company_name, comp_abbr, fy_start, currency = eval(args)
+    curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
+    self.currency = currency
+    
+    # Fiscal Year
+    master_dict = {'Fiscal Year':{'year':curr_fiscal_year,
+                                  'year_start_date':fy_start_date}}
+    self.create_records(master_dict)
+    
+    # Company
+    master_dict = {'Company':{'company_name':company_name,
+                              'abbr':comp_abbr                              
+                              }}
+    self.create_records(master_dict)
+    
+    def_args = {'current_fiscal_year':curr_fiscal_year,
+                'default_currency': currency,
+                'default_company':company_name,
+                'default_valuation_method':'FIFO',
+                'date_format':'dd-mm-yyyy',
+                'default_currency_format':'Lacs',
+                'so_required':'No',
+                'dn_required':'No',
+                'po_required':'No',
+                'pr_required':'No',
+                'emp_created_by':'Naming Series',
+                'cust_master_name':'Customer Name', 
+                'supp_master_name':'Supplier Name'}
+
+    # Set 
+    self.set_defaults(def_args)
+
+    # Set Registration Complete
+    set_default('registration_complete','1')
+
+    import webnotes.utils
+    return webnotes.utils.get_defaults()
+
+    
+  # Get Fiscal year Details
+  # ------------------------
+  def get_fy_details(self, fy_start):
+    st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
+    curr_year = getdate(nowdate()).year
+    if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
+      curr_year = getdate(nowdate()).year - 1
+    stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
+    #eddt = sql("select DATE_FORMAT(DATE_SUB(DATE_ADD('%s', INTERVAL 1 YEAR), INTERVAL 1 DAY),'%%d-%%m-%%Y')" % (stdt.split('-')[2]+ '-' + stdt.split('-')[1] + '-' + stdt.split('-')[0]))
+    if(fy_start == '1st Jan'):
+      fy = cstr(getdate(nowdate()).year)
+    else:
+      fy = cstr(curr_year) + '-' + cstr(curr_year+1)
+    return fy,stdt
+
+
+  # Create Company and Fiscal Year
+  # ------------------------------- 
+  def create_records(self, master_dict):
+    for d in master_dict.keys():
+      rec = Document(d)
+      for fn in master_dict[d].keys():
+        rec.fields[fn] = master_dict[d][fn]
+      # add blank fields
+      for fn in rec.fields:
+        if fn not in master_dict[d].keys()+['name','owner','doctype']:
+          rec.fields[fn] = ''
+      rec_obj = get_obj(doc=rec)
+      rec_obj.doc.save(1)
+      if hasattr(rec_obj, 'on_update'):
+        rec_obj.on_update()
+
+
+  # Set System Defaults
+  # --------------------
+  def set_defaults(self, def_args):
+    ma_obj = get_obj('Manage Account','Manage Account')
+    for d in def_args.keys():
+      ma_obj.doc.fields[d] = def_args[d]
+    ma_obj.doc.save()
+    ma_obj.update_cp()
+
+
+  # Set Control Panel Defaults
+  # --------------------------
+  def set_cp_defaults(self, cname, industry, timezone, country, acc_name):
+    cp = Document('Control Panel','Control Panel')
+    cp.account_id = acc_name
+    cp.company_name = cname
+    cp.industry = industry
+    cp.time_zone = timezone
+    cp.country = country
+    cp.client_name = '<div style="padding:4px; font-size:20px;">'+cname+'</div>'
+    cp.save()
+      
+  # Create Profile
+  # --------------
+  def create_profile(self, user_email, user_fname, user_lname):
+    roles_list = ['System Manager','Sales Manager','Sales User','Purchase Manager','Purchase User','Material Manager','Material User','Accounts Manager','Accounts User','HR Manager','HR User','Production Manager','Production User','Sales Master Manager','Purchase Master Manager','Material Master Manager','Quality Manager','Maintenance User','Maintenance Manager']
+    pr = Document('Profile')
+    pr.first_name = user_fname
+    pr.last_name = user_lname
+    pr.email = user_email
+    pr.enabled = 1
+    pr.save(1)
+    for r in roles_list:
+      d = addchild(pr, 'userroles', 'UserRole', 1)
+      d.role = r
+      d.save()
+    # Add roles to Administrator profile
+    pr_obj = get_obj('Profile','Administrator')
+    for r in roles_list:
+      d = addchild(pr_obj.doc,'userroles', 'UserRole', 1)
+      d.role = r
+      d.save()
+  
+  # Update WN ERP Client Control
+  # -----------------------------
+  def update_client_control(self):
+    cl = Document('WN ERP Client Control','WN ERP Client Control')
+    cl.account_start_date = nowdate()
+    cl.total_users = 1
+    cl.is_trial_account = 1
+    cl.save()
+
+  # Sync DB
+  # -------
+  def sync_db(arg=''):
+    import webnotes.model.db_schema
+    sql("delete from `tabDocType Update Register`")
+    webnotes.model.db_schema.sync_all()
\ No newline at end of file
diff --git a/setup/doctype/setup_control/setup_control.txt b/setup/doctype/setup_control/setup_control.txt
new file mode 100644
index 0000000..85d27f4
--- /dev/null
+++ b/setup/doctype/setup_control/setup_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-03 13:32:18', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 87, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 0, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': None, 'name': 'Setup Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/setup/doctype/state/__init__.py b/setup/doctype/state/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/state/__init__.py
diff --git a/setup/doctype/state/state.js b/setup/doctype/state/state.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/state/state.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/state/state.txt b/setup/doctype/state/state.txt
new file mode 100644
index 0000000..72384ea
--- /dev/null
+++ b/setup/doctype/state/state.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-31 16:47:00', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 0, 'read_only': 0, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 15, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:state_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'State', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00533', 'parent': 'State', 'read': 1, 'create': 1, 'creation': '2009-12-15 16:10:15', 'modified': '2010-09-20 11:03:36', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'dhanalekshmi@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00582', 'parent': 'State', 'read': 1, 'create': 1, 'creation': '2010-01-12 16:42:57', 'modified': '2010-09-20 11:03:36', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00759', 'parent': 'State', 'read': 1, 'create': 1, 'creation': '2010-04-08 13:47:15', 'modified': '2010-09-20 11:03:36', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 3, 'parenttype': 'DocType', 'role': 'Purchase Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-31 16:47:00', 'doctype': 'DocField', 'oldfieldname': 'state_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'State Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'State', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01598', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 11:03:36', 'parenttype': 'DocType', 'fieldname': 'state_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2009-03-31 16:47:00', 'doctype': 'DocField', 'oldfieldname': 'country', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Country', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'State', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01599', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 11:03:36', 'parenttype': 'DocType', 'fieldname': 'country', 'fieldtype': 'Select', 'options': 'link:Country', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/supplier_type/__init__.py b/setup/doctype/supplier_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/supplier_type/__init__.py
diff --git a/setup/doctype/supplier_type/supplier_type.js b/setup/doctype/supplier_type/supplier_type.js
new file mode 100644
index 0000000..c7c01af
--- /dev/null
+++ b/setup/doctype/supplier_type/supplier_type.js
@@ -0,0 +1,11 @@
+$import(Tips Common)
+
+// ONLOAD
+// ===================================================================================
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/supplier_type/supplier_type.txt b/setup/doctype/supplier_type/supplier_type.txt
new file mode 100644
index 0000000..0190faf
--- /dev/null
+++ b/setup/doctype/supplier_type/supplier_type.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:10:22', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:supplier_type', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Supplier Type', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00917', 'parent': 'Supplier Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:54:46', 'modified': '2010-09-17 14:57:24', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Purchase Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00918', 'parent': 'Supplier Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:54:46', 'modified': '2010-09-17 14:57:24', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Purchase Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00919', 'parent': 'Supplier Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:00:26', 'modified': '2010-09-17 14:57:24', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Purchase User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00920', 'parent': 'Supplier Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:00:26', 'modified': '2010-09-17 14:57:24', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Purchase User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00224', 'parent': 'Supplier Type', 'read': 1, 'create': 1, 'creation': '2009-03-12 16:40:23', 'modified': '2010-09-17 14:57:24', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 5, 'parenttype': 'DocType', 'role': 'Purchase Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': '', 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Supplier Type', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04863', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:24', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:10:22', 'doctype': 'DocField', 'oldfieldname': 'supplier_type', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Supplier Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Supplier Type', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01322', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-17 14:57:24', 'parenttype': 'DocType', 'fieldname': 'supplier_type', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/support_email_settings/__init__.py b/setup/doctype/support_email_settings/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/support_email_settings/__init__.py
diff --git a/setup/doctype/support_email_settings/support_email_settings.py b/setup/doctype/support_email_settings/support_email_settings.py
new file mode 100644
index 0000000..98d680e
--- /dev/null
+++ b/setup/doctype/support_email_settings/support_email_settings.py
@@ -0,0 +1,18 @@
+import webnotes
+from webnotes.utils import cint
+
+class DocType:
+	def __init__(self,dt,dn):
+		self.doc, self.doctype = dt,dn
+		
+	def on_update(self):
+		"""
+			Sets or cancels the event in the scheduler
+		"""
+		if cint(self.doc.integrate_incoming):
+			from webnotes.utils.scheduler import set_event
+			set_event('maintenance.doctype.support_ticket.get_support_mails', 60*5, 1)
+		else:
+			from webnotes.utils.scheduler import cancel_event
+			cancel_event('maintenance.doctype.support_ticket.get_support_mails')
+			
\ No newline at end of file
diff --git a/setup/doctype/support_email_settings/support_email_settings.txt b/setup/doctype/support_email_settings/support_email_settings.txt
new file mode 100644
index 0000000..46a3d0f
--- /dev/null
+++ b/setup/doctype/support_email_settings/support_email_settings.txt
@@ -0,0 +1,369 @@
+[
+	{
+		'_last_update': '1306554355',
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': None,
+		'autoname': None,
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-17 14:04:30',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': None,
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': None,
+		'in_dialog': 1,
+		'is_transaction_doc': None,
+		'issingle': 1,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'Support Email Settings',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': 1,
+		'read_only_onload': None,
+		'search_fields': None,
+		'section_style': 'Simple',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': None,
+		'show_in_menu': 1,
+		'smallicon': None,
+		'subject': None,
+		'tag_fields': None,
+		'use_template': None,
+		'version': 8
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': 1,
+		'creation': '2011-05-17 14:04:30',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000798',
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-19 12:41:15',
+		'default': None,
+		'depends_on': None,
+		'description': 'The full email id of your incoming support emails',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'email',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Email',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000811',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Email',
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-20 11:34:49',
+		'default': None,
+		'depends_on': None,
+		'description': 'By checking this, your incoming mails will automatically be integrated with the Support Ticket',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'integrate_incoming',
+		'fieldtype': 'Check',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Integrate Incoming',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000824',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-28 09:15:55',
+		'default': None,
+		'depends_on': None,
+		'description': 'Signature appended to the outgoing email (Text / HTML)',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'signature',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Signature',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': 'FL05195',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-20 11:34:49',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000823',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-17 14:04:30',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'use_ssl',
+		'fieldtype': 'Check',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Use SSL',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000799',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-17 14:04:30',
+		'default': None,
+		'depends_on': None,
+		'description': 'eg. pop.gmail.com',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'host',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Host',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000800',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-17 14:04:30',
+		'default': None,
+		'depends_on': None,
+		'description': 'Support Email Id',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'username',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Username',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000801',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-17 14:04:30',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'password',
+		'fieldtype': 'Password',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Password',
+		'modified': '2011-05-28 09:25:53',
+		'modified_by': 'Administrator',
+		'name': '000000802',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Support Email Settings',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/setup/doctype/target_detail/__init__.py b/setup/doctype/target_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/target_detail/__init__.py
diff --git a/setup/doctype/target_detail/target_detail.txt b/setup/doctype/target_detail/target_detail.txt
new file mode 100644
index 0000000..f3bbc58
--- /dev/null
+++ b/setup/doctype/target_detail/target_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-16 18:17:59', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 15, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Target Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-05-22 13:08:10', 'doctype': 'DocField', 'oldfieldname': 'item_group', 'owner': 'Administrator', 'reqd': 0, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Item Group', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Target Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL02123', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-06-30 13:03:15', 'parenttype': 'DocType', 'fieldname': 'item_group', 'fieldtype': 'Link', 'options': 'Item Group', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2009-03-16 18:17:59', 'doctype': 'DocField', 'oldfieldname': 'fiscal_year', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Fiscal Year', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Target Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01419', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-06-30 13:03:15', 'parenttype': 'DocType', 'fieldname': 'fiscal_year', 'fieldtype': 'Select', 'options': 'link:Fiscal Year', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2010-06-22 12:03:16', 'doctype': 'DocField', 'oldfieldname': 'target_qty', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Target Qty', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Target Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05403', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-06-30 13:03:15', 'parenttype': 'DocType', 'fieldname': 'target_qty', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-16 18:17:59', 'doctype': 'DocField', 'oldfieldname': 'target_amount', 'owner': 'Administrator', 'reqd': 0, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Target  Amount', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Target Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01420', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-06-30 13:03:15', 'parenttype': 'DocType', 'fieldname': 'target_amount', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/term/__init__.py b/setup/doctype/term/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/term/__init__.py
diff --git a/setup/doctype/term/term.js b/setup/doctype/term/term.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/term/term.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/term/term.txt b/setup/doctype/term/term.txt
new file mode 100644
index 0000000..d8bdb54
--- /dev/null
+++ b/setup/doctype/term/term.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-19 13:38:59', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 11, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:title', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Term', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00953', 'parent': 'Term', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:10:54', 'modified': '2010-09-20 11:05:27', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00954', 'parent': 'Term', 'read': 1, 'create': 1, 'creation': '2010-04-26 17:10:54', 'modified': '2010-09-20 11:05:27', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00966', 'parent': 'Term', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:13:26', 'modified': '2010-09-20 11:05:27', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00834', 'parent': 'Term', 'read': 1, 'create': 0, 'creation': '2010-04-19 13:38:59', 'modified': '2010-09-20 11:05:27', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00835', 'parent': 'Term', 'read': 1, 'create': None, 'creation': '2010-04-19 13:38:59', 'modified': '2010-09-20 11:05:27', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 5, 'parenttype': 'DocType', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00837', 'parent': 'Term', 'read': 1, 'create': 1, 'creation': '2010-04-20 09:39:56', 'modified': '2010-09-20 11:05:27', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 6, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00838', 'parent': 'Term', 'read': 1, 'create': 1, 'creation': '2010-04-20 09:39:56', 'modified': '2010-09-20 11:05:27', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 7, 'parenttype': 'DocType', 'role': 'Accounts User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Term', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04864', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 11:05:27', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-04-19 13:38:59', 'doctype': 'DocField', 'oldfieldname': 'title', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Title', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Term', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL04672', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 11:05:27', 'parenttype': 'DocType', 'fieldname': 'title', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text Editor', 'creation': '2010-04-19 13:38:59', 'doctype': 'DocField', 'oldfieldname': 'terms', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Terms', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Term', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04673', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 11:05:27', 'parenttype': 'DocType', 'fieldname': 'terms', 'fieldtype': 'Text Editor', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/territory/__init__.py b/setup/doctype/territory/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/territory/__init__.py
diff --git a/setup/doctype/territory/territory.js b/setup/doctype/territory/territory.js
new file mode 100644
index 0000000..7692b83
--- /dev/null
+++ b/setup/doctype/territory/territory.js
@@ -0,0 +1,35 @@
+$import(Tips Common)
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.onload = function(){
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+  if(doc.__islocal){
+    doc.parent_territory = 'All Territories';
+    refresh('parent_territory');
+  }
+}
+
+
+//get query select territory
+cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) {
+  return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "Yes" AND `tabTerritory`.`docstatus`!= 2 AND (`tabTerritory`.`rgt` > '+doc.rgt+' or `tabTerritory`.`lft` < '+doc.lft+') AND `tabTerritory`.`name` !="'+doc.territory_name+'" AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY  `tabTerritory`.`name` ASC LIMIT 50';
+}
+
+
+// ******************** ITEM Group ******************************** 
+cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
+}
+
+cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
+  var call_back = function(){
+    var sb_obj = new SalesBrowser();        
+    sb_obj.set_val('Territory');
+
+  }
+  loadpage('Sales Browser',call_back);
+  
+}
\ No newline at end of file
diff --git a/setup/doctype/territory/territory.py b/setup/doctype/territory/territory.py
new file mode 100644
index 0000000..26805be
--- /dev/null
+++ b/setup/doctype/territory/territory.py
@@ -0,0 +1,61 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.nsm_parent_field = 'parent_territory'
+
+  def check_state(self):
+    return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
+
+       
+
+  # update Node Set Model
+  def update_nsm_model(self):
+    import webnotes
+    import webnotes.utils.nestedset
+    webnotes.utils.nestedset.update_nsm(self)
+
+  # ON UPDATE
+  #--------------------------------------
+  def on_update(self):
+  
+    # update nsm
+    self.update_nsm_model()  
+    
+
+
+  def validate(self): 
+    if self.doc.lft and self.doc.rgt:
+      res = sql("select name from `tabTerritory` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_territory,self.doc.territory_name))
+      if not res:
+        msgprint("Please enter proper parent territory.") 
+        raise Exception
+
+    r = sql("select name from `tabTerritory` where name = '%s' and docstatus = 2"%(self.doc.territory_name))
+    if r:
+      msgprint("%s record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.territory_name))
+      raise Exception
+
+    for d in getlist(self.doclist, 'target_details'):
+      if not flt(d.target_qty) and not flt(d.target_amount):
+        msgprint("Either target qty or target amount is mandatory.")
+        raise Exception
\ No newline at end of file
diff --git a/setup/doctype/territory/territory.txt b/setup/doctype/territory/territory.txt
new file mode 100644
index 0000000..52ca9c4
--- /dev/null
+++ b/setup/doctype/territory/territory.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:10:06', 'search_fields': 'name,parent_territory,territory_manager', 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': 1, 'in_create': 1, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 91, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:territory_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': 'Master', 'name': 'Territory', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-22 16:00:26', 'server_code_error': ' ', 'name_case': 'Title Case', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00930', 'parent': 'Territory', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:08:32', 'modified': '2010-09-22 16:00:26', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00931', 'parent': 'Territory', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:08:32', 'modified': '2010-09-22 16:00:26', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00952', 'parent': 'Territory', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:10:54', 'modified': '2010-09-22 16:00:26', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00962', 'parent': 'Territory', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:13:26', 'modified': '2010-09-22 16:00:26', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00963', 'parent': 'Territory', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:13:26', 'modified': '2010-09-22 16:00:26', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 5, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00658', 'parent': 'Territory', 'read': 1, 'create': 1, 'creation': '2010-02-01 10:10:16', 'modified': '2010-09-22 16:00:26', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 6, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04865', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:10:06', 'doctype': 'DocField', 'oldfieldname': 'territory_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Territory Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01154', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'territory_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-03-12 12:10:06', 'doctype': 'DocField', 'oldfieldname': 'territory_manager', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Territory Manager', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01161', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'territory_manager', 'fieldtype': 'Link', 'options': 'Sales Person', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': 'parent_territory', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Parent Territory', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05445', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'parent_territory', 'fieldtype': 'Link', 'options': 'Territory', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2010-07-19 13:05:00', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'harshada@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'TerritoryHelp', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05643', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To manage Territory, click here</a>', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': 'is_group', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Has Child Node', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': 'Only leaf nodes are allowed in transaction', 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05446', 'idx': 6, 'default': None, 'colour': 'White:FFF', 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'is_group', 'fieldtype': 'Select', 'options': '\nYes\nNo', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Int', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': 'lft', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'lft', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05447', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'lft', 'fieldtype': 'Int', 'options': None, 'report_hide': 0, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Int', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': 'rgt', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'rgt', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05448', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'rgt', 'fieldtype': 'Int', 'options': None, 'report_hide': 0, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': 'old_parent', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'old_parent', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05449', 'idx': 9, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'old_parent', 'fieldtype': 'Data', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-06-28 12:46:46', 'doctype': 'DocField', 'oldfieldname': 'distribution_id', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Distribution Id', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05457', 'idx': 10, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'distribution_id', 'fieldtype': 'Link', 'options': 'Budget Distribution', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Section Break', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Target Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05450', 'idx': 11, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Table', 'creation': '2010-06-28 09:18:58', 'doctype': 'DocField', 'oldfieldname': 'target_details', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Target Details1', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Territory', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05451', 'idx': 12, 'default': None, 'colour': None, 'modified': '2010-09-22 16:00:26', 'parenttype': 'DocType', 'fieldname': 'target_details', 'fieldtype': 'Table', 'options': 'Target Detail', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/uom/__init__.py b/setup/doctype/uom/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/uom/__init__.py
diff --git a/setup/doctype/uom/uom.js b/setup/doctype/uom/uom.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/uom/uom.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/uom/uom.txt b/setup/doctype/uom/uom.txt
new file mode 100644
index 0000000..51423b9
--- /dev/null
+++ b/setup/doctype/uom/uom.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-12 12:09:44', 'search_fields': None, 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 6, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:uom_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'UOM', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00872', 'parent': 'UOM', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-20 11:07:40', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00873', 'parent': 'UOM', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-20 11:07:40', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00897', 'parent': 'UOM', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-20 11:07:40', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00898', 'parent': 'UOM', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-20 11:07:40', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00223', 'parent': 'UOM', 'read': 1, 'create': 1, 'creation': '2009-03-12 15:59:30', 'modified': '2010-09-20 11:07:40', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 5, 'parenttype': 'DocType', 'role': 'Material Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': '', 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'UOM', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04866', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 11:07:40', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Section Break', 'creation': '2010-03-17 15:16:18', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'ashwini@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'UOM Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'UOM', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04114', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 11:07:40', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:09:44', 'doctype': 'DocField', 'oldfieldname': 'uom_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'UOM Name', 'width': '', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'UOM', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00659', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 11:07:40', 'parenttype': 'DocType', 'fieldname': 'uom_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/doctype/warehouse_type/__init__.py b/setup/doctype/warehouse_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/doctype/warehouse_type/__init__.py
diff --git a/setup/doctype/warehouse_type/warehouse_type.js b/setup/doctype/warehouse_type/warehouse_type.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/setup/doctype/warehouse_type/warehouse_type.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/setup/doctype/warehouse_type/warehouse_type.txt b/setup/doctype/warehouse_type/warehouse_type.txt
new file mode 100644
index 0000000..9a05c2b
--- /dev/null
+++ b/setup/doctype/warehouse_type/warehouse_type.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:09:44', 'search_fields': '', 'module': 'Setup', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 8, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 0, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': 1, 'allow_print': None, 'autoname': 'field:warehouse_type', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': '', 'name': 'Warehouse Type', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-22 10:52:43', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00878', 'parent': 'Warehouse Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-22 10:52:43', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00879', 'parent': 'Warehouse Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:48:34', 'modified': '2010-09-22 10:52:43', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 2, 'parenttype': 'DocType', 'role': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00903', 'parent': 'Warehouse Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-22 10:52:43', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 3, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 1, 'match': None, 'parentfield': 'permissions'}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00904', 'parent': 'Warehouse Type', 'read': 1, 'create': 0, 'creation': '2010-04-26 16:52:07', 'modified': '2010-09-22 10:52:43', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 4, 'parenttype': 'DocType', 'role': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': 1, 'amend': 0, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00212', 'parent': 'Warehouse Type', 'read': 1, 'create': 1, 'creation': '2009-03-12 15:13:34', 'modified': '2010-09-22 10:52:43', 'submit': 0, 'doctype': 'DocPerm', 'write': 1, 'idx': 5, 'parenttype': 'DocType', 'role': 'Material Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': '', 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-04-20 14:06:44', 'doctype': 'DocField', 'oldfieldname': 'trash_reason', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Trash Reason', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Warehouse Type', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04868', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-22 10:52:43', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:09:44', 'doctype': 'DocField', 'oldfieldname': 'warehouse_type', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Warehouse Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Warehouse Type', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL00676', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-22 10:52:43', 'parenttype': 'DocType', 'fieldname': 'warehouse_type', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/setup/page/__init__.py b/setup/page/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/__init__.py
diff --git a/setup/page/import_data/__init__.py b/setup/page/import_data/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/import_data/__init__.py
diff --git a/setup/page/import_data/import_data.html b/setup/page/import_data/import_data.html
new file mode 100644
index 0000000..a4b30f4
--- /dev/null
+++ b/setup/page/import_data/import_data.html
@@ -0,0 +1,55 @@
+<div class="layout_wrapper">
+<div id="di_header"></div>
+<div style="margin: 8px">
+<table style="border-collapse: collapse;" border="0">
+<tbody>
+<tr>
+<td style="border: 1px solid #aaaaaa; padding: 4px; width: 60%;">
+	
+<form action="index.cgi" enctype="multipart/form-data" method="POST" target="ImportIFrame"> <input name="cmd" type="hidden" value="import_csv" /> 
+<h3 style="background-color: #EEF; padding: 2px;">Step 1. Download Template</h3>
+<select id="import_template" style="margin: 10px;"> <option>Select Master...</option> </select>
+
+<div style="margin: 10px; margin-top: 0px;"><input name="overwrite" type="checkbox"/> Over-write records with same name?</div>
+<div id="child_tab_lst"></div>
+<h3 style="background-color: #EEF; padding: 2px;">Step 2. Upload and Import</h3>
+<table style="width: 480px;" border="0" cellspacing="10px">
+<tbody>
+<tr>
+<td width="200px">Select CSV File to be imported</td>
+<td><input name="csv_file" type="file" /></td>
+</tr>
+<tr>
+<td width="200px">Date format in source CSV</td>
+<td><select name="dateformat"> <option value="yyyy-mm-dd">yyyy-mm-dd</option> <option value="mm/dd/yyyy">mm/dd/yyyy</option> <option value="mm/dd/yy">mm/dd/yy</option> <option value="dd-mm-yyyy">dd-mm-yyyy</option> <option value="dd/mm/yyyy">dd/mm/yyyy</option> </select></td>
+</tr>
+<tr>
+<td>&nbsp;</td>
+<td>
+<div id="import_btn"><input type="submit" value="Import" /></div>
+</td>
+</tr>
+</tbody>
+</table>
+</form>
+<div style="background-color: #FFE; padding: 10px; margin: 10px;">
+<h3>Data Import Guide</h3>
+<ol>
+<li>Get the template of the DocType for which you want to import in CSV (Comma seperated values) format.</li>
+<li>Fill in the data in the template. You can remove columns that are not relevant</li>
+<li>Save the template in CSV format</li>
+<li>Select the saved CSV file, identify the date format if any</li>
+<li>Click on "Import"</li>
+</ol></div>
+</td>
+<td style="border: 1px solid #AAA; padding: 4px;">
+<h3>Import Log:</h3>
+<div id="import_result_area">
+<iframe src="blank1.html" name="ImportIFrame" style="border: 0px; height: 500px; width: 100%"></iframe>
+</div>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
\ No newline at end of file
diff --git a/setup/page/import_data/import_data.js b/setup/page/import_data/import_data.js
new file mode 100644
index 0000000..aa0bdbd
--- /dev/null
+++ b/setup/page/import_data/import_data.js
@@ -0,0 +1,45 @@
+pscript['onload_Import Data'] = function() {
+  
+  //alert(profile.can_get_report);
+
+  callback = function(r,rt) {
+    var h = new PageHeader('di_header','Import Data','Tool to download template and upload data');
+    var sel = $i('import_template');
+    if(r.message){
+      add_sel_options(sel, r.message);
+      sel.onchange=function(){
+        $i('child_tab_lst').innerHTML ='';
+        if(sel.value != 'Select Master...'){
+          $c_obj('Import Data Control','get_child_lst',sel.value,
+            function(r,rt){
+              var me = this;
+              $y($i('child_tab_lst'),{backgroundColor:'#EEEEEE'})
+              var desc = $a($i('child_tab_lst'), 'div', '', {padding:'8px'});
+              
+              desc.innerHTML = "<h4>Please click on following link(s) to download template.</h4>";
+ 
+              
+              var parent = $a($i('child_tab_lst'), 'div');
+              var tab = make_table(parent,r.message.length,1,'100%',[],{padding:'8px',fontSize:'15px',borderCollapse: 'collapse'});
+              
+              for(var i=0;i<r.message.length;i++){
+                var dt= $a($td(tab,i,0), 'span', 'link_type');
+                dt.innerHTML = r.message[i];
+                dt.nm = r.message[i];
+                
+
+                dt.onclick = function(){ 
+					var ovr = $('input[name="overwrite"]:checked').length;
+                    window.location = outUrl + '?cmd=get_template&dt=' + this.nm + (ovr ? '&overwrite=1' : '');
+                }
+              }
+            }  
+          );
+        }
+      }
+    }
+  }
+  $c_obj('Import Data Control','get_master_lst','',callback);
+  
+
+}
diff --git a/setup/page/import_data/import_data.txt b/setup/page/import_data/import_data.txt
new file mode 100644
index 0000000..b422f12
--- /dev/null
+++ b/setup/page/import_data/import_data.txt
@@ -0,0 +1,106 @@
+[
+	{
+		'author': None,
+		'category': 'Standard',
+		'content': None,
+		'creation': '2010-12-14 10:33:09',
+		'docstatus': 0,
+		'doctype': 'Page',
+		'file_list': None,
+		'icon': None,
+		'idx': None,
+		'keywords': None,
+		'menu_index': None,
+		'modified': '2011-05-02 16:28:00',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'Import Data',
+		'owner': 'Administrator',
+		'page_name': 'Import Data',
+		'page_title': None,
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'publish': None,
+		'script': None,
+		'show_in_menu': 0,
+		'site_description': None,
+		'standard': 'Yes',
+		'static_content': None,
+		'style': None,
+		'stylesheet': None,
+		'template': None,
+		'write_content': None
+	},
+	{
+		'creation': '2010-12-14 10:33:09',
+		'docstatus': 0,
+		'doctype': 'Page Role',
+		'idx': 1,
+		'modified': '2011-05-02 16:28:00',
+		'modified_by': 'Administrator',
+		'name': 'PR000224',
+		'owner': 'Administrator',
+		'parent': 'Import Data',
+		'parentfield': 'roles',
+		'parenttype': 'Page',
+		'role': 'Administrator'
+	},
+	{
+		'creation': '2010-12-14 10:33:09',
+		'docstatus': 0,
+		'doctype': 'Page Role',
+		'idx': 2,
+		'modified': '2011-05-02 16:28:00',
+		'modified_by': 'Administrator',
+		'name': 'PR000225',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Import Data',
+		'parentfield': 'roles',
+		'parenttype': 'Page',
+		'role': 'System Manager'
+	},
+	{
+		'creation': '2010-12-14 10:33:09',
+		'docstatus': 0,
+		'doctype': 'Page Role',
+		'idx': 3,
+		'modified': '2011-05-02 16:28:00',
+		'modified_by': 'Administrator',
+		'name': 'PR000226',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Import Data',
+		'parentfield': 'roles',
+		'parenttype': 'Page',
+		'role': 'Sales Master Manager'
+	},
+	{
+		'creation': '2010-12-14 10:33:09',
+		'docstatus': 0,
+		'doctype': 'Page Role',
+		'idx': 4,
+		'modified': '2011-05-02 16:28:00',
+		'modified_by': 'Administrator',
+		'name': 'PR000227',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Import Data',
+		'parentfield': 'roles',
+		'parenttype': 'Page',
+		'role': 'Purchase Master Manager'
+	},
+	{
+		'creation': '2010-12-14 10:33:09',
+		'docstatus': 0,
+		'doctype': 'Page Role',
+		'idx': 5,
+		'modified': '2011-05-02 16:28:00',
+		'modified_by': 'Administrator',
+		'name': 'PR000228',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Import Data',
+		'parentfield': 'roles',
+		'parenttype': 'Page',
+		'role': 'Material Master Manager'
+	}
+]
\ No newline at end of file
diff --git a/setup/page/people/__init__.py b/setup/page/people/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/people/__init__.py
diff --git a/setup/page/people/people.comp.js b/setup/page/people/people.comp.js
new file mode 100644
index 0000000..8938b6a
--- /dev/null
+++ b/setup/page/people/people.comp.js
@@ -0,0 +1,50 @@
+
+pscript.onload_people=function(){make_customer_tab($i('crm_home'));}
+function make_customer_tab(parent){new DocColumnView('Customers',parent,['Customer Group','Customer','Contact'],{'Customer Group':{show_fields:['name'],create_fields:['name'],search_fields:['name'],next_col:'Customer'},'Customer':{show_fields:['name','customer_name'],create_fields:['name','customer_name'],search_fields:['customer_name'],filter_by:['Customer Group','customer_group'],next_col:'Contact'},'Contact':{show_fields:['name','first_name','last_name'],create_fields:['name','first_name','last_name'],search_fields:['first_name','last_name'],conditions:['is_customer=1'],filter_by:['Customer','customer']},})}
+function DocColumnView(title,parent,items,opts){this.columns={};this.items=items;this.page_head=new PageHeader(parent,title);this.make_columns(items.length,parent);for(var i=0;i<items.length;i++){var c=opts[items[i]];this.columns[items[i]]=new List2(this,$td(this.tab,0,i),items[i],c);}
+this.columns[items[0]].run();}
+DocColumnView.prototype.make_columns=function(n,parent){var cl=[];for(var i=0;i<n;i++){cl.push(cint(100/n)+'%')}
+this.tab=make_table(parent,1,n,'100%',cl)
+this.tab.className='dcv-tab';}
+DocColumnView.prototype.refresh=function(){this.columns[this.items[0]].run();}
+function List2(dcv,parent,doctype,opts){this.dcv=dcv;this.doctype=doctype;this.opts=opts;this.dtl=get_doctype_label(doctype);this.make_body(parent);this.selected_item=null;}
+List2.prototype.make_body=function(parent){this.make_toolbar(parent);this.make_search(parent);this.make_message(parent);this.make_list(parent);this.clear();}
+List2.prototype.make_toolbar=function(parent){var me=this;this.head=$a(parent,'div','list2-head');$gr(this.head,'#EEE','#CCC');var t=make_table(this.head,1,2,'100%',['60%','40%'],{verticalAlign:'middle'});var span=$a($td(t,0,0),'span','',{cssFloat:'left'},this.dtl);var refresh_icon=$a($td(t,0,0),'div','wn-icon ic-playback_reload',{marginLeft:'7px',cssFloat:'left'});refresh_icon.onclick=function(){me.run();}
+this.btn=$btn($td(t,0,1),'+ New',function(){me.make_new();},{fontWeight:'bold',cssFloat:'right'},'green');}
+List2.prototype.make_search=function(parent){var me=this;this.searchbar=$a(parent,'div','list2-search');this.search_inp=$a_input(this.searchbar,'text');this.search_btn=$a(this.searchbar,'img','',{cursor:'pointer',marginLeft:'8px',marginBottom:'-3px'});this.search_btn.src='images/icons/magnifier.png';this.search_btn.onclick=function(){me.run();}}
+List2.prototype.make_message=function(parent){this.clear_message=$a(parent,'div','help_box',{margin:'4px',display:'none'},(this.opts.filter_by?('Select '+get_doctype_label(this.opts.filter_by[0])+' to see list'):''));this.no_result_message=$a(parent,'div','help_box',{margin:'4px',display:'none'},'No '+this.dtl+' created yet!');}
+List2.prototype.make_new=function(){var me=this;newdoc(this.doctype,function(dn){if(me.opts.filter_by){var val=me.dcv.columns[me.opts.filter_by[0]].get_selected();if(val)
+locals[me.doctype][dn][me.opts.filter_by[1]]=val;}});}
+List2.prototype.clear=function(){$dh(this.lst_area);$ds(this.clear_message)
+$dh(this.no_result_message);this.clear_next();}
+List2.prototype.show_list=function(){$ds(this.lst_area);$dh(this.clear_message)
+$dh(this.no_result_message);}
+List2.prototype.show_no_result=function(){if(!this.search_inp.value){$dh(this.lst_area);$dh(this.clear_message);$ds(this.no_result_message);}}
+List2.prototype.clear_next=function(){if(this.opts.next_col&&this.dcv.columns[this.opts.next_col])this.dcv.columns[this.opts.next_col].clear();}
+List2.prototype.make_list=function(parent){var me=this;this.lst_area=$a(parent,'div','list2-list-area');this.lst=new Listing('Profiles',1);this.lst.opts.hide_refresh=1;this.lst.opts.cell_style={padding:'0px'};this.lst.colwidths=['100%'];this.lst.get_query=function(){var q=me.build_query();this.query=q[0];this.query_max=q[1];}
+this.lst.make(this.lst_area);this.lst.show_cell=function(cell,ri,ci,d){new List2Item(cell,d[ri],me);}
+this.lst.onrun=function(){me.show_list();me.clear_next();if(!me.lst.has_data())me.show_no_result();}}
+List2.prototype.run=function(){$dh(this.lst.results);this.lst.run();}
+List2.prototype.build_query=function(){var args={fields:this.opts.show_fields.join(', '),doctype:this.doctype,cond:''}
+var cl=this.build_search_conditions();cl=this.add_filter_condition(cl);if(cl.length)args.cond=' AND '+cl.join(' AND ');var query=repl('SELECT %(fields)s FROM `tab%(doctype)s` WHERE docstatus < 2 %(cond)s',args)
+var query_max=repl('SELECT COUNT(*) FROM `tab%(doctype)s` WHERE docstatus < 2 %(cond)s',args)
+return[query,query_max]}
+List2.prototype.build_search_conditions=function(){var cl=new Array();if(this.opts.conditions){for(var i=0;i<this.opts.conditions.length;i++)cl.push(this.opts.conditions);}
+if(this.search_inp.value&&this.search_inp.value!='Search'){for(var i=0;i<this.opts.search_fields.length;i++){cl.push(repl('`%(field)s` LIKE "%(txt)s"',{field:this.opts.search_fields[i],txt:'%'+this.search_inp.value+'%'}));}}
+return cl;}
+List2.prototype.add_filter_condition=function(cl){if(this.opts.filter_by){cl.push(repl('`%(filter)s` = "%(val)s"',{filter:this.opts.filter_by[1],val:this.dcv.columns[this.opts.filter_by[0]].get_selected()}));}
+return cl;}
+List2.prototype.get_selected=function(){if(this.selected_item)return this.selected_item.det[0];else return'';}
+List2Item=function(cell,det,list2){this.det=det;this.list2=list2;this.make_body(cell);this.show_text();this.show_more_info();}
+List2Item.prototype.make_body=function(cell){var me=this;this.body=$a(cell,'div','list2-item-div')
+if(me.list2.opts.next_col){this.make_with_icon();}else{this.content=this.body;}
+this.body.onclick=function(){me.select();if(me.list2.opts.next_col)me.list2.dcv.columns[me.list2.opts.next_col].run();}}
+List2Item.prototype.make_with_icon=function(){var t=make_table(this.body,1,2,'100%',['','18px'])
+$y($td(t,0,1),{verticalAlign:'middle'})
+var img=$a($td(t,0,1),'img');img.src='images/icons/control_play.png';this.content=$td(t,0,0);}
+List2Item.prototype.show_text=function(){var me=this;this.label=$a(this.content,'div','list2-item-title','',this.det[0]);var span=$a(this.label,'span','link_type list2-edit-link','','[Edit]');span.onclick=function(){loaddoc(me.list2.doctype,me.det[0]);}}
+List2Item.prototype.show_more_info=function(){var det=this.det;if(det.length>1){var l=[];for(var i=1;i<det.length;i++){if(det[i]&&det[i]!=det[0])l.push(det[i]);}
+if(l.length)
+this.more_info=$a(this.content,'div','list2-item-more-info','',l.join(', '))}}
+List2Item.prototype.select=function(){if(this.list2.selected_item)this.list2.selected_item.deselect();this.body.className='list2-item-div list2-item-selected';this.list2.selected_item=this;}
+List2Item.prototype.deselect=function(){this.body.className='list2-item-div';}
\ No newline at end of file
diff --git a/setup/page/people/people.html b/setup/page/people/people.html
new file mode 100644
index 0000000..ad31e38
--- /dev/null
+++ b/setup/page/people/people.html
@@ -0,0 +1 @@
+<div id="crm_home"></div>
\ No newline at end of file
diff --git a/setup/page/people/people.js b/setup/page/people/people.js
new file mode 100644
index 0000000..fd316bf
--- /dev/null
+++ b/setup/page/people/people.js
@@ -0,0 +1,32 @@
+//make tabs
+
+pscript.onload_people = function() {
+	make_customer_tab($i('crm_home'));
+}
+
+function make_customer_tab(parent) {	
+	new wn.widgets.DocColumnView('Customers', parent, ['Customer Group', 'Customer', 'Contact'], {
+		'Customer Group': { 
+			show_fields : ['name'],
+			create_fields : ['name'],
+			search_fields : ['name'],
+			next_col: 'Customer'
+		},
+		'Customer': { 
+			show_fields : ['name', 'customer_name'],
+			create_fields : ['name', 'customer_name'],
+			search_fields : ['customer_name'],
+			filter_by : ['Customer Group', 'customer_group'],
+			next_col: 'Contact'
+		},
+		'Contact': { 
+			show_fields : ['name', 'first_name', 'last_name'],
+			create_fields : ['name','first_name', 'last_name'],
+			search_fields : ['first_name', 'last_name'],
+			conditions: ['is_customer=1'],
+			filter_by : ['Customer', 'customer']
+		},
+	})
+}
+
+
diff --git a/setup/page/people/people.txt b/setup/page/people/people.txt
new file mode 100644
index 0000000..3e7bba2
--- /dev/null
+++ b/setup/page/people/people.txt
@@ -0,0 +1,26 @@
+[
+	{
+		'content': None,
+		'creation': '2011-03-21 12:12:32',
+		'docstatus': 0,
+		'doctype': 'Page',
+		'icon': None,
+		'idx': None,
+		'menu_index': None,
+		'modified': '2011-03-21 12:13:39',
+		'modified_by': 'Administrator',
+		'module': 'Setup',
+		'name': 'people',
+		'owner': 'Administrator',
+		'page_name': 'People',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'script': None,
+		'show_in_menu': None,
+		'standard': 'Yes',
+		'static_content': None,
+		'style': None
+	}
+]
\ No newline at end of file
diff --git a/setup/page/permission_engine/__init__.py b/setup/page/permission_engine/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/permission_engine/__init__.py
diff --git a/setup/page/permission_engine/permission_engine.comp.js b/setup/page/permission_engine/permission_engine.comp.js
new file mode 100644
index 0000000..f0c9b1c
--- /dev/null
+++ b/setup/page/permission_engine/permission_engine.comp.js
@@ -0,0 +1,75 @@
+
+pscript['onload_Permission Engine']=function(){var h=new PageHeader('pe_header','Permissions Manager','Set specific permissions for Roles')
+if(!pscript.perm_engine)pscript.perm_engine=new pscript.PermEngine();}
+pscript.PermEngine=function(){this.wrapper=$i('perm_engine_div');this.head=$a(this.wrapper,'div');this.body=$a(this.wrapper,'div');this.footer=$a(this.wrapper,'div');var lab=$a(this.body,'div','',{backgroundColor:'#FFD',padding:'8px',margin:'16px 0px'});lab.innerHTML='Please select the item for which you want to set permissions';this.make_head();this.load_options();}
+pscript.PermEngine.prototype.make_head=function(){var me=this;var make_select=function(label){var w=$a(me.head,'div','',{margin:'8px 0px'});var t=make_table(w,1,2,'300px',['50%','50%']);$td(t,0,0).innerHTML=label;var s=$a($td(t,0,1),'select','',{width:'140px'});s.wrapper=w;return s;}
+var make_button=function(label,parent,green){return $btn(parent,label,null,{margin:'8px 0px',display:'none'},(green?'green':null));}
+this.type_select=make_select('Set Permissions For');this.type_select.onchange=function(){me.get_permissions();}
+this.add_button=make_button('+ Add A New Rule',this.head,0);this.add_button.onclick=function(){me.add_permission();}
+this.update_button=make_button('Update',this.footer,1);this.update_button.onclick=function(){me.update_permissions();}}
+pscript.PermEngine.prototype.add_permission=function(){var me=this;if(!this.add_permission_dialog){var d=new Dialog(400,400,'Add Permission');d.make_body([['Select','Role'],['Select','Level'],['Button','Add']])
+add_sel_options(d.widgets['Role'],this.roles,'');add_sel_options(d.widgets['Level'],[0,1,2,3,4,5,6,7,8,9],0);d.widgets['Add'].onclick=function(){if(!sel_val(d.widgets['Role'])){msgprint('Please select Role');return;}
+var callback=function(r,rt){me.get_permissions();d.hide();}
+$c_obj('Permission Control','add_permission',JSON.stringify([sel_val(me.type_select),sel_val(d.widgets['Role']),sel_val(d.widgets['Level'])]),callback);}
+this.add_permission_dialog=d;}
+this.add_permission_dialog.show();}
+pscript.PermEngine.prototype.hide_fields=function(){$dh(this.role_select.wrapper);this.type_select.disabled=false;this.body.innerHTML='';}
+pscript.PermEngine.prototype.load_options=function(){var me=this;$dh(me.update_button);$dh(me.add_button);$c_obj('Permission Control','get_doctype_list','',function(r,rt){me.roles=r.message.roles;empty_select(me.type_select);add_sel_options(me.type_select,add_lists([''],r.message.doctypes));});}
+pscript.PermEngine.prototype.get_permissions=function(){var me=this;if(!sel_val(me.type_select)){msgprint('Please select a type first!');return;}
+$c_obj('Permission Control','get_permissions',sel_val(me.type_select),function(r,rt){if(r.message.perms.length)me.get_results(r.message);else me.body.innerHTML='<div style = "color : red; margin:8px 0px;">No Records Found</div>'});}
+pscript.PermEngine.prototype.get_results=function(r){var perms=r.perms;var me=this;var doctype=sel_val(me.type_select);$ds(me.update_button);$ds(me.add_button);this.body.innerHTML=''
+pscript.all_checkboxes=[];pscript.all_matches=[];var head=$a(this.body,'h3');head.innerHTML='Rules for '+doctype;var permt=make_table(me.body,perms.length+1,9,'80%',[],{border:'1px solid #AAA',padding:'3px',verticalAlign:'middle',height:'30px'});var col_labels=['Role','Level','Read','Write','Create','Submit','Cancel','Amend','Restrict By']
+for(var n=0;n<col_labels.length;n++){$y($td(permt,0,n),{backgroundColor:'#DDD',width:(n==0?'30%':(n==8?'21%':'7%'))})
+$td(permt,0,n).innerHTML=col_labels[n];$td(permt,0,n).fieldname=col_labels[n].toLowerCase();}
+for(var j=0;j<perms.length;j++){var plevel=$a($td(permt,j+1,1),'span','link_type');plevel.innerHTML=perms[j].permlevel;plevel.doctype=doctype;plevel.value=perms[j].permlevel;plevel.onclick=function(){me.get_fields(this.doctype,this.value)}
+$td(permt,j+1,0).innerHTML=perms[j].role;}
+for(var l=0;l<perms.length;l++){for(var m=0;m<6;m++){var chk=$a_input($td(permt,l+1,m+2),'checkbox');var val=perms[l][$td(permt,0,m+2).fieldname];if(val==1)chk.checked=1;else chk.checked=0;chk.doctype=doctype;chk.permlevel=perms[l].permlevel;chk.perm_type=col_labels[m+2].toLowerCase();chk.role=perms[l].role;pscript.all_checkboxes.push(chk);}}
+me.add_match_select(r,perms,permt,doctype);}
+pscript.PermEngine.prototype.add_match_select=function(r,perms,permt,doctype){var me=this;for(var i=0;i<perms.length;i++){if(perms[i].permlevel==0){var sel=$a($td(permt,i+1,8),'select','',{width:'100%'});add_sel_options(sel,r.fields);sel.details=perms[i];sel.details.parent=doctype;sel.onchange=function(){if(sel_val(this)&&sel_val(this)!='owner')$ds(this.div);else $dh(this.div);}
+var div=$a($td(permt,i+1,8),'div','link_type',{marginTop:'2px',fontSize:'10px',display:'none'});div.onclick=function(){this.details.match=sel_val(this.sel);me.show_match_dialog(this.details);}
+div.innerHTML='Set Users / Roles';div.details=perms[i];sel.div=div;div.sel=sel;if(perms[i].match){sel.value=perms[i].match;$ds(div);}
+pscript.all_matches.push(sel);}}}
+pscript.PermEngine.prototype.show_match_dialog=function(details){if(!this.match_defaults_dialog){var d=new Dialog(750,500,'Permission Applies To');d.make_body([['HTML','Body']]);var w=d.widgets['Body'];$y(w,{height:'350px',overflow:'auto'});this.match_defaults_dialog=d;}
+this.match_defaults_dialog.show();var me=this;var callback=function(r,rt){me.render_match_dialog(r,details);}
+$c_obj('Permission Control','get_defaults',details.match+'~~~'+(this.profiles?'No':'Yes'),callback);}
+pscript.PermEngine.prototype.render_match_dialog=function(r,details){var d=this.match_defaults_dialog;var w=d.widgets['Body'];w.innerHTML='<div style="background-color:#FFD; padding: 4px; color: #440; margin-bottom:16px">Please Note: Any action will also affect other permissions with similar rules!</div>'
+var t=make_table($a(w,'div','',{borderBottom:'1px solid #AAA'}),1,3,'90%',['40%','40%','20%'],{fontWeight:'bold',padding:'3px',fontSize:'14px'});$td(t,0,0).innerHTML='Who?';$td(t,0,1).innerHTML='Is allowed if '+details.match+' equals';var dl=r.message.dl;this.options=r.message.ol;if(!this.profiles){this.profiles=r.message.pl;}
+for(var i=0;i<dl.length;i++){new MatchDefaultValue(this,w,dl[i],details.match);}
+this.add_new_match_row(details.match);}
+pscript.PermEngine.prototype.add_new_match_row=function(fieldname){new MatchDefaultValue(this,this.match_defaults_dialog.widgets['Body'],null,fieldname,1);}
+MatchDefaultValue=function(pe,parent,details,fieldname,editable){this.pe=pe;this.wrapper=$a(parent,'div','',{margin:'4px'});this.clear();this.details=details;this.fieldname=fieldname;this.render(editable);}
+MatchDefaultValue.prototype.clear=function(){this.wrapper.innerHTML='';this.tab=make_table(this.wrapper,1,3,'90%',['40%','40%','20%'],{verticalAlign:'middle',padding:'3px'});}
+MatchDefaultValue.prototype.render=function(editable){if(editable){this.render_editable();}else{this.render_static();}}
+MatchDefaultValue.prototype.render_editable=function(){var me=this;this.profile_or_role=$a($td(this.tab,0,0),'select','',{width:'60px',marginRight:'8px'});add_sel_options(this.profile_or_role,['Profile','Role'],'Profile');this.profile_or_role.onchange=function(){if(sel_val(this)=='Profile'){$di(me.profile_sel);$dh(me.role_sel);}
+else{$dh(me.profile_sel);$di(me.role_sel);}}
+this.role_sel=$a($td(this.tab,0,0),'select','',{width:'100px',display:'none'});add_sel_options(this.role_sel,this.pe.roles);this.profile_sel=$a($td(this.tab,0,0),'select','',{width:'100px'});add_sel_options(this.profile_sel,this.pe.profiles);this.options_sel=$a($td(this.tab,0,1),'select','',{width:'120px'});add_sel_options(this.options_sel,this.pe.options);var span=$a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});span.innerHTML='Add'
+span.onclick=function(){me.save();}}
+MatchDefaultValue.prototype.render_static=function(){var me=this;$td(this.tab,0,0).innerHTML=this.details.parenttype;$td(this.tab,0,0).innerHTML+='&nbsp;'+this.details.parent;$td(this.tab,0,1).innerHTML=this.details.defvalue;var span=$a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});span.innerHTML='Cancel'
+span.onclick=function(){me.delete_def();}}
+MatchDefaultValue.prototype.delete_def=function(){var me=this;this.wrapper.innerHTML='<div style="color: #888; padding: 3px;">Deleting...</div>';var callback=function(r,rt){$dh(me.wrapper);if(r.exc)msgprint('There were errors!')}
+$c_obj('Permission Control','delete_default',[this.details.parent,this.fieldname,this.details.defvalue].join('~~~'),callback)}
+MatchDefaultValue.prototype.save=function(){var me=this;var callback=function(r,rt){me.details=r.message;me.clear();me.render();me.pe.add_new_match_row(me.fieldname);}
+if(sel_val(this.profile_or_role)=='Profile'){var parent=sel_val(this.profile_sel);var parenttype='Profile';}
+else{var parent=sel_val(this.role_sel);var parenttype='Role';}
+if(!sel_val(this.options_sel)||!parent){msgprint("Please select all values");return;}
+$c_obj('Permission Control','add_default',[parent,parenttype,this.fieldname,sel_val(this.options_sel)].join('~~~'),callback);this.wrapper.innerHTML='<div style="color: #888; padding: 3px;">Adding...</div>';}
+pscript.PermEngine.prototype.make_fields_dialog=function(){if(!pscript.get_field_dialog){pscript.get_field_dialog=new Dialog(750,500,'Fields');pscript.get_field_dialog.make_body([['HTML','Fields','<div id="perm_engine_get_fields"></div>'],['Button','OK']]);}
+else $i('perm_engine_get_fields').innerHTML='';}
+pscript.PermEngine.prototype.get_fields=function(dt,permlevel){var me=this;var callback=function(r,rt){var parent_fields_dict=r.message.parent_fields_dict;var table_fields_dict=r.message.table_fields_dict;me.make_fields_dialog();me.make_fields_table(dt,parent_fields_dict,table_fields_dict,permlevel);pscript.get_field_dialog.show();pscript.get_field_dialog.widgets['OK'].onclick=function(){pscript.get_field_dialog.hide();}}
+var args="{'dt':'"+dt+"','permlevel':"+permlevel+"}"
+$c_obj('Permission Control','get_fields',args,callback);}
+pscript.PermEngine.prototype.make_fields_table=function(dt,parent_fields_dict,table_fields_dict,permlevel){var make_grid=function(table,fields_dict){var col_labels=['Label','Fieldtype','Fieldname','Options'];for(var n=0;n<col_labels.length;n++){$a_input(($td(table,0,n)),'data');$td(table,0,n).innerHTML='<b>'+col_labels[n]+'</b>';$td(table,0,n).fieldname=col_labels[n].toLowerCase();}
+for(var i=0;i<keys(fields_dict).length;i++){for(var j=0;j<4;j++){$a_input(($td(table,i+1,j)),'data');$td(table,i+1,j).innerHTML=cstr(fields_dict[i][$td(table,0,j).fieldname])}}}
+$i('perm_engine_get_fields').innerHTML='<b>'+dt+' Fields at Level '+permlevel+':</b><br><br>';var parent_field_table=make_table('perm_engine_get_fields',keys(parent_fields_dict).length+1,4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});make_grid(parent_field_table,parent_fields_dict);child_tables=keys(table_fields_dict)
+if(child_tables.length>0){for(var k=0;k<child_tables.length;k++){var tab_fields_det=table_fields_dict[child_tables[k]];if(keys(tab_fields_det).length>0){$i('perm_engine_get_fields').innerHTML+='<br><b>'+child_tables[k]+' Fields at Level '+permlevel+':</b><br><br>'
+var child_field_table=make_table('perm_engine_get_fields',keys(tab_fields_det).length+1,4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});make_grid(child_field_table,tab_fields_det);}}}}
+pscript.PermEngine.prototype.update_permissions=function(){var me=this;var out={};var add_to_out=function(doctype,permlevel,role,key,value){if(!out[doctype])out[doctype]={};if(!out[doctype][permlevel])out[doctype][permlevel]={};if(!out[doctype][permlevel][role])out[doctype][permlevel][role]={};out[doctype][permlevel][role][key]=value;}
+for(i in pscript.all_checkboxes){c=pscript.all_checkboxes[i];add_to_out(c.doctype,c.permlevel,c.role,c.perm_type,c.checked?1:0);}
+for(var i=0;i<pscript.all_matches.length;i++){var s=pscript.all_matches[i];if(sel_val(s))
+add_to_out(s.details.parent,s.details.permlevel,s.details.role,'match',sel_val(s));}
+var args="{'perm_dict': "+JSON.stringify(out)+"}"
+$c_obj('Permission Control','update_permissions',args,function(r,rt){});}
+pscript.PermEngine.prototype.update_page_roles=function(){var me=this;var out={};for(i in pscript.all_pg_checkboxes){c=pscript.all_pg_checkboxes[i];out[c.page_name]=c.checked?1:0}
+var args="{'page_role_dict': "+JSON.stringify(out)+", 'role': '"+sel_val(me.role_select)+"'}"
+$c_obj('Permission Control','update_page_role',args,function(r,rt){});}
+pscript.PermEngine.prototype.reset_perm_engine=function(){this.type_select.selectedIndex=0;this.load_options();}
\ No newline at end of file
diff --git a/setup/page/permission_engine/permission_engine.html b/setup/page/permission_engine/permission_engine.html
new file mode 100644
index 0000000..1b9cab2
--- /dev/null
+++ b/setup/page/permission_engine/permission_engine.html
@@ -0,0 +1,4 @@
+<div class="layout_wrapper">
+<div id="pe_header"></div>
+<div id="perm_engine_div" style="margin: 16px;"></div>
+</div>
\ No newline at end of file
diff --git a/setup/page/permission_engine/permission_engine.js b/setup/page/permission_engine/permission_engine.js
new file mode 100644
index 0000000..378ad0c
--- /dev/null
+++ b/setup/page/permission_engine/permission_engine.js
@@ -0,0 +1,525 @@
+pscript['onload_Permission Engine'] = function() {
+  // header and toolbar
+  var h = new PageHeader('pe_header','Permissions Manager','Set specific permissions for Roles')
+  
+  if(!pscript.perm_engine) pscript.perm_engine = new pscript.PermEngine();
+}
+
+
+pscript.PermEngine = function() {
+  // create UI elements
+  this.wrapper = $i('perm_engine_div');
+  
+  this.head = $a(this.wrapper, 'div');
+  this.body = $a(this.wrapper, 'div');
+  this.footer = $a(this.wrapper, 'div');
+
+  var lab = $a(this.body,'div', '', {backgroundColor:'#FFD', padding:'8px', margin:'16px 0px'});
+  lab.innerHTML = 'Please select the item for which you want to set permissions';
+  
+  this.make_head();
+  this.load_options();
+}
+
+
+// Make Head
+// -------------
+pscript.PermEngine.prototype.make_head = function() {
+  var me = this;
+  
+  var make_select = function(label) {
+    var w = $a(me.head, 'div', '', {margin:'8px 0px'});
+    var t = make_table(w,1,2,'300px',['50%','50%']);
+    $td(t,0,0).innerHTML = label;
+    var s = $a($td(t,0,1),'select','',{width:'140px'});
+    s.wrapper = w;
+    return s;
+  }
+  
+  var make_button = function(label, parent, green) {
+  	return $btn(parent, label, null, {margin:'8px 0px', display:'none'}, (green ? 'green' : null));
+  }
+  
+  
+  // Set Permissions for
+  this.type_select = make_select('Set Permissions For');
+  this.type_select.onchange = function() {
+  	me.get_permissions();
+  }
+    
+  // Update Button
+  this.add_button = make_button('+ Add A New Rule', this.head, 0);
+  this.add_button.onclick = function() {
+    me.add_permission();
+  }
+
+  // Update Button
+  this.update_button = make_button('Update', this.footer, 1);
+  this.update_button.onclick = function() {
+    me.update_permissions();
+  }
+}
+
+// Add Permissions
+// -----------------
+pscript.PermEngine.prototype.add_permission = function() {
+  var me = this;
+  if(!this.add_permission_dialog) {
+  	
+  	// dialog
+    var d = new Dialog(400,400,'Add Permission');
+    d.make_body([['Select','Role'],['Select','Level'],['Button','Add']])
+
+    add_sel_options(d.widgets['Role'], this.roles, '');
+    add_sel_options(d.widgets['Level'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
+
+    // add
+    d.widgets['Add'].onclick = function() {
+      if(!sel_val(d.widgets['Role'])) {
+        msgprint('Please select Role'); return;
+      }
+      var callback = function(r, rt) {
+      	// reload
+        me.get_permissions();
+        d.hide();
+      }
+      $c_obj('Permission Control','add_permission',JSON.stringify([sel_val(me.type_select), sel_val(d.widgets['Role']), sel_val(d.widgets['Level'])]), callback);
+    }
+
+    this.add_permission_dialog = d;
+  }
+  this.add_permission_dialog.show();
+}
+
+
+// Hide Fields
+// -----------------
+pscript.PermEngine.prototype.hide_fields = function() {
+  $dh(this.role_select.wrapper);
+  this.type_select.disabled = false;
+  this.body.innerHTML = '';
+}
+
+
+// Load Roles And Modules
+// -----------------------
+pscript.PermEngine.prototype.load_options = function() {
+  var me = this;
+  $dh(me.update_button);
+  $dh(me.add_button);
+
+  $c_obj('Permission Control','get_doctype_list','', function(r,rt) {    
+    me.roles = r.message.roles;
+    
+    // Type
+    empty_select(me.type_select);
+    add_sel_options(me.type_select,add_lists([''], r.message.doctypes));
+    
+  });
+}
+
+
+// Get DocType and Permissions related to module
+// --------------------------------------------------
+pscript.PermEngine.prototype.get_permissions = function() {
+  var me = this;
+  
+  if(!sel_val(me.type_select)) {
+  	msgprint('Please select a type first!'); return;
+  }
+  
+  $c_obj('Permission Control','get_permissions',sel_val(me.type_select), function(r,rt) {    
+     // Get permissions
+    if(r.message.perms.length)me.get_results(r.message);
+    else me.body.innerHTML = '<div style = "color : red; margin:8px 0px;">No Records Found</div>'
+  });
+}
+
+// Get Results
+// ------------------
+pscript.PermEngine.prototype.get_results = function(r){
+  var perms = r.perms;
+  var me = this;
+  var doctype = sel_val(me.type_select);
+  
+  // show update button
+  $ds(me.update_button);
+  $ds(me.add_button);
+
+  this.body.innerHTML = ''
+  pscript.all_checkboxes = [];
+  pscript.all_matches = [];
+  
+  var head = $a(this.body, 'h3'); head.innerHTML = 'Rules for ' + doctype;        
+  var permt = make_table(me.body, perms.length+1,9,'80%',[],{border:'1px solid #AAA', padding:'3px', verticalAlign:'middle', height:'30px'});
+    
+  // Create Grid for particular DocType
+  // ------------------------------------
+    
+  // Columns
+  var col_labels = ['Role','Level','Read','Write','Create','Submit','Cancel','Amend','Restrict By']
+  for(var n = 0; n < col_labels.length; n++){
+  	$y($td(permt,0,n), {backgroundColor:'#DDD', width:(n==0?'30%':(n==8?'21%':'7%'))})
+    $td(permt,0,n).innerHTML = col_labels[n];
+    $td(permt,0,n).fieldname = col_labels[n].toLowerCase();
+  }
+    
+  // Rows for Column Level / Role
+  for(var j = 0; j < perms.length; j++){
+    var plevel = $a($td(permt,j+1,1), 'span', 'link_type');
+    plevel.innerHTML = perms[j].permlevel;
+    plevel.doctype = doctype;
+    plevel.value = perms[j].permlevel;
+    plevel.onclick = function() {me.get_fields(this.doctype, this.value)}
+
+    // role
+    $td(permt,j+1,0).innerHTML = perms[j].role;
+
+  }  
+    
+  // Get values
+  for(var l = 0; l < perms.length; l++){
+    for(var m = 0; m < 6; m++){                             // (read,write,create,submit,cancel,amend) 
+      var chk = $a_input($td(permt,l+1,m+2), 'checkbox');
+      var val = perms[l][$td(permt,0,m+2).fieldname];
+      if(val == 1) chk.checked = 1;
+      else chk.checked = 0;
+      chk.doctype = doctype;
+      chk.permlevel = perms[l].permlevel; chk.perm_type = col_labels[m+2].toLowerCase(); chk.role = perms[l].role;
+      pscript.all_checkboxes.push(chk);
+    }
+  }
+  
+  // add selects for match
+  me.add_match_select(r, perms, permt, doctype);
+}
+
+// render selects for match
+// --------------------------------------------
+
+pscript.PermEngine.prototype.add_match_select = function(r, perms, permt, doctype) {
+  var me = this;
+  
+  // add select for match
+  for(var i=0; i<perms.length; i++) {
+    if(perms[i].permlevel==0) {
+      // select
+      var sel = $a($td(permt,i+1,8),'select','',{width:'100%'});
+      add_sel_options(sel, r.fields);
+      sel.details = perms[i]; sel.details.parent = doctype;
+      sel.onchange = function() { 
+      	if(sel_val(this) && sel_val(this)!='owner') $ds(this.div); 
+      	else $dh(this.div); }
+      
+      // link
+      var div = $a($td(permt,i+1,8),'div','link_type',{marginTop: '2px', fontSize:'10px', display:'none'});
+      div.onclick = function() { this.details.match = sel_val(this.sel); me.show_match_dialog(this.details); }
+      div.innerHTML = 'Set Users / Roles';
+      div.details = perms[i];
+      sel.div = div; div.sel = sel;
+
+      // set the value
+      if(perms[i].match) { sel.value = perms[i].match; $ds(div); }
+      
+      pscript.all_matches.push(sel);
+    }
+  }
+}
+
+// match users Dialog
+// =======================================================
+
+pscript.PermEngine.prototype.show_match_dialog=function(details) {
+  if(!this.match_defaults_dialog) {
+    var d = new Dialog(750, 500, 'Permission Applies To');
+    d.make_body([['HTML','Body']]);
+    var w = d.widgets['Body'];
+    $y(w,{height:'350px', overflow:'auto'});
+    this.match_defaults_dialog = d;
+  }
+  
+  // dialog
+  this.match_defaults_dialog.show();
+  
+  // render the rules
+  var me = this;
+  var callback = function(r,rt) {
+  	me.render_match_dialog(r, details);
+  }
+  // load the rules
+  $c_obj('Permission Control','get_defaults', details.match + '~~~' + (this.profiles ? 'No' : 'Yes'), callback); 
+}
+
+// --------------------------------------------
+
+pscript.PermEngine.prototype.render_match_dialog=function(r, details) {
+  var d = this.match_defaults_dialog;
+  var w = d.widgets['Body'];
+  w.innerHTML = '<div style="background-color:#FFD; padding: 4px; color: #440; margin-bottom:16px">Please Note: Any action will also affect other permissions with similar rules!</div>'
+  
+  // header
+  var t=make_table($a(w,'div','',{borderBottom:'1px solid #AAA'}),1,3,'90%',['40%','40%','20%'],{fontWeight:'bold', padding:'3px', fontSize:'14px'});
+  $td(t,0,0).innerHTML = 'Who?'; $td(t,0,1).innerHTML = 'Is allowed if '+details.match+' equals';
+  
+  // existing defaults
+  var dl = r.message.dl; this.options = r.message.ol;
+  if(!this.profiles) {
+    this.profiles = r.message.pl;
+  }
+  
+  for(var i=0; i<dl.length; i++) {
+    new MatchDefaultValue(this, w, dl[i], details.match);
+  }
+  
+  this.add_new_match_row(details.match);
+}
+
+pscript.PermEngine.prototype.add_new_match_row = function(fieldname) {
+  // add new default
+  new MatchDefaultValue(this, this.match_defaults_dialog.widgets['Body'], null, fieldname, 1);
+}  
+  
+// --------------------------------------------
+
+MatchDefaultValue = function(pe, parent, details, fieldname, editable) {
+  this.pe = pe;
+  this.wrapper = $a(parent, 'div', '', {margin:'4px'});
+  this.clear();
+  this.details = details;
+  this.fieldname = fieldname;
+  this.render(editable);
+}
+
+
+// --------------------------------------------
+
+MatchDefaultValue.prototype.clear = function() {
+  this.wrapper.innerHTML = '';
+  this.tab = make_table(this.wrapper, 1, 3, '90%', ['40%','40%','20%'], {verticalAlign:'middle', padding:'3px'});
+}
+
+// --------------------------------------------
+
+MatchDefaultValue.prototype.render = function(editable) {
+
+  if(editable) {
+  	this.render_editable();
+  } else {
+    this.render_static();
+  }
+}
+
+// --------------------------------------------
+
+MatchDefaultValue.prototype.render_editable = function() {
+  var me = this;
+
+  // profile or role
+  this.profile_or_role = $a($td(this.tab,0,0), 'select', '', {width:'60px', marginRight:'8px'});
+  add_sel_options(this.profile_or_role,['Profile', 'Role'], 'Profile');
+  this.profile_or_role.onchange = function() {
+    if(sel_val(this)=='Profile') { $di(me.profile_sel); $dh(me.role_sel); }
+    else { $dh(me.profile_sel); $di(me.role_sel); }
+  }
+
+  // role sel
+  this.role_sel = $a($td(this.tab,0,0), 'select', '', {width:'100px',display:'none'});
+  add_sel_options(this.role_sel,this.pe.roles);
+  
+  // profile sel
+  this.profile_sel = $a($td(this.tab,0,0), 'select', '', {width:'100px'});
+  add_sel_options(this.profile_sel,this.pe.profiles);
+
+  // options sel
+  this.options_sel = $a($td(this.tab,0,1), 'select', '', {width:'120px'});
+  add_sel_options(this.options_sel,this.pe.options);
+
+   // add
+  var span = $a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});
+  span.innerHTML = 'Add'
+  span.onclick = function() { me.save(); }
+}
+
+// --------------------------------------------
+
+MatchDefaultValue.prototype.render_static = function() {
+  var me = this;
+  
+  $td(this.tab,0,0).innerHTML = this.details.parenttype;
+  $td(this.tab,0,0).innerHTML += '&nbsp;' + this.details.parent;
+  $td(this.tab,0,1).innerHTML = this.details.defvalue;
+
+   // delete
+  var span = $a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});
+  span.innerHTML = 'Cancel'
+  span.onclick = function() { me.delete_def(); }
+}
+
+// --------------------------------------------
+
+MatchDefaultValue.prototype.delete_def = function() {	
+  var me = this;
+  this.wrapper.innerHTML = '<div style="color: #888; padding: 3px;">Deleting...</div>';
+  var callback = function(r,rt) {
+  	$dh(me.wrapper);
+    if(r.exc) msgprint('There were errors!')
+  }
+  $c_obj('Permission Control','delete_default'
+    ,[this.details.parent, this.fieldname, this.details.defvalue].join('~~~')
+    ,callback)
+}
+
+// --------------------------------------------
+
+MatchDefaultValue.prototype.save = function() {
+  var me= this;
+  
+  var callback = function(r,rt) {
+    me.details = r.message;
+    me.clear();
+    me.render();
+    me.pe.add_new_match_row(me.fieldname);
+  }
+  	
+  // values
+  if(sel_val(this.profile_or_role)=='Profile') { var parent = sel_val(this.profile_sel); var parenttype = 'Profile'; }
+  else { var parent = sel_val(this.role_sel); var parenttype = 'Role'; }
+
+  if(!sel_val(this.options_sel) || !parent) { msgprint("Please select all values"); return; }
+  	
+  $c_obj('Permission Control','add_default'
+    ,[parent, parenttype, this.fieldname, sel_val(this.options_sel)].join('~~~')
+    ,callback);
+      
+  this.wrapper.innerHTML = '<div style="color: #888; padding: 3px;">Adding...</div>';
+}
+
+
+// Make Dialog Box To Get Fields fro PermLevel
+// =======================================================
+
+pscript.PermEngine.prototype.make_fields_dialog=function(){
+  if(!pscript.get_field_dialog) {
+    pscript.get_field_dialog = new Dialog(750,500,'Fields');
+    pscript.get_field_dialog.make_body([['HTML','Fields','<div id="perm_engine_get_fields"></div>'],['Button','OK']]);
+  }
+  else $i('perm_engine_get_fields').innerHTML = '';
+}
+
+// Get Fields
+// --------------------
+pscript.PermEngine.prototype.get_fields = function(dt, permlevel) {
+  var me = this;
+  var callback = function(r,rt){
+    // Get Parent DocType Fields
+    var parent_fields_dict = r.message.parent_fields_dict;
+    
+    // Get Child Table Fields if any
+    var table_fields_dict = r.message.table_fields_dict;
+    
+    // Make Fields Dialog Box
+    me.make_fields_dialog();
+    
+    me.make_fields_table(dt, parent_fields_dict, table_fields_dict, permlevel);
+    
+    pscript.get_field_dialog.show();
+    pscript.get_field_dialog.widgets['OK'].onclick=function(){
+      pscript.get_field_dialog.hide();
+    }
+  }
+  var args = "{'dt':'"+dt+"','permlevel':"+permlevel+"}"
+  $c_obj('Permission Control','get_fields', args, callback);
+}
+
+
+
+// Make Table of Fields for Dialog Box
+// --------------------------------------
+pscript.PermEngine.prototype.make_fields_table = function(dt, parent_fields_dict, table_fields_dict, permlevel) {
+  
+  var make_grid = function(table, fields_dict) {
+    var col_labels = ['Label','Fieldtype','Fieldname','Options'];
+    for(var n = 0; n < col_labels.length; n++){
+      $a_input(($td(table,0,n)), 'data');
+      $td(table,0,n).innerHTML = '<b>'+col_labels[n]+'</b>';
+      $td(table,0,n).fieldname = col_labels[n].toLowerCase();
+    }
+    
+    // Add values
+    for(var i = 0; i < keys(fields_dict).length; i++){
+      for(var j = 0; j < 4; j++){
+        $a_input(($td(table,i+1,j)), 'data');
+        $td(table,i+1,j).innerHTML = cstr(fields_dict[i][$td(table,0,j).fieldname])
+      }
+    }
+  }
+
+  
+  $i('perm_engine_get_fields').innerHTML = '<b>'+ dt + ' Fields at Level '+ permlevel +':</b><br><br>';
+  var parent_field_table = make_table('perm_engine_get_fields',keys(parent_fields_dict).length+1, 4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});
+  make_grid(parent_field_table, parent_fields_dict);
+  
+  child_tables = keys(table_fields_dict)
+  if(child_tables.length > 0){
+    for(var k = 0; k < child_tables.length; k++){
+      var tab_fields_det = table_fields_dict[child_tables[k]];
+      if(keys(tab_fields_det).length > 0){
+        $i('perm_engine_get_fields').innerHTML += '<br><b>'+ child_tables[k] + ' Fields at Level '+ permlevel +':</b><br><br>'
+        var child_field_table = make_table('perm_engine_get_fields',keys(tab_fields_det).length+1, 4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});
+        make_grid(child_field_table, tab_fields_det);
+      }
+    }
+  }
+}
+
+
+// Update Permissions
+// -----------------------
+pscript.PermEngine.prototype.update_permissions = function() {
+  var me = this;
+  var out = {};
+
+  var add_to_out = function(doctype, permlevel, role, key, value) {
+    if(!out[doctype]) out[doctype] = {};
+    if(!out[doctype][permlevel]) out[doctype][permlevel] = {};
+    if(!out[doctype][permlevel][role]) out[doctype][permlevel][role] = {};
+    out[doctype][permlevel][role][key] = value; 
+  }
+
+  // check boxes
+  for(i in pscript.all_checkboxes) {
+    c = pscript.all_checkboxes[i];
+    add_to_out(c.doctype, c.permlevel, c.role, c.perm_type, c.checked ? 1 : 0);
+  }
+
+  // matches
+  for(var i=0; i<pscript.all_matches.length; i++) {
+  	var s = pscript.all_matches[i];
+    if(sel_val(s))
+      add_to_out(s.details.parent, s.details.permlevel, s.details.role, 'match', sel_val(s));
+  }
+  
+  var args = "{'perm_dict': "+JSON.stringify(out)+"}"
+  $c_obj('Permission Control','update_permissions', args, function(r,rt) {});
+}
+
+
+// Update Page Roles
+// ----------------------
+pscript.PermEngine.prototype.update_page_roles = function() {
+  var me = this;
+  var out = {};
+  for(i in pscript.all_pg_checkboxes) {
+    c = pscript.all_pg_checkboxes[i];
+    out[c.page_name] = c.checked ? 1 : 0
+  }
+  var args = "{'page_role_dict': "+JSON.stringify(out)+", 'role': '"+sel_val(me.role_select)+"'}"
+  $c_obj('Permission Control','update_page_role', args, function(r,rt) {});
+}
+
+// Reset Permission Engine
+// -------------------------
+pscript.PermEngine.prototype.reset_perm_engine = function(){
+  this.type_select.selectedIndex = 0;
+  this.load_options();
+}
diff --git a/setup/page/permission_engine/permission_engine.txt b/setup/page/permission_engine/permission_engine.txt
new file mode 100644
index 0000000..72ef01c
--- /dev/null
+++ b/setup/page/permission_engine/permission_engine.txt
@@ -0,0 +1 @@
+[{'creation': '2010-01-07 10:44:43', 'module': 'Setup', 'doctype': 'Page', 'owner': 'saumil@webnotestech.com', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 1, 'content': None, 'page_name': 'Permission Engine', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Permission Engine', 'idx': None, 'static_content': None, 'modified': '2010-11-18 20:24:21', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000107', 'parent': 'Permission Engine', 'creation': '2010-01-07 11:10:21', 'modified': '2010-11-18 20:24:21', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'System Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/setup/page/setup/__init__.py b/setup/page/setup/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/setup/__init__.py
diff --git a/setup/page/setup/setup.comp.js b/setup/page/setup/setup.comp.js
new file mode 100644
index 0000000..59d31b4
--- /dev/null
+++ b/setup/page/setup/setup.comp.js
@@ -0,0 +1,32 @@
+
+pscript.onload_Setup=function(){var parent=$i('setup_div');add_space_holder(parent);var callback=function(r,rt){parent.page_head=new PageHeader(parent,'Setup');var setup_data=new SetupData(r.message);pscript.setup_make_sections(setup_data);remove_space_holder();}
+$c_obj('Setup Wizard Control','get_country','',callback);}
+pscript.setup_set_height=function(){var parent=$i('setup_div');$y(parent.tray.body,{height:get_window_height()-parent.page_head.wrapper.offsetHeight+'px',overflow:'auto'})}
+pscript.setup_make_sections=function(setup_data){var parent=$i('setup_div');parent.tray=new TrayPage(parent)
+var lst=[setup_data.system,setup_data.general,setup_data.accounts,setup_data.selling,setup_data.buying,setup_data.stock,setup_data.hr,setup_data.maintenance,setup_data.production];for(var s=0;s<lst.length;s++){var lbl=keys(lst[s])[0];var ti=parent.tray.add_item(lbl,null,null,1)
+new SetupItem(ti.body,lbl,lst[s][lbl]);if(s==0)ti.expand();}
+setTimeout(pscript.setup_set_height,100);resize_observers.push(pscript.setup_set_height);}
+SetupItem=function(parent,lbl,link_list){this.icons={'System':'back_img Setup','General':'back_img Home','Accounts':'back_img Accounts','Selling':'back_img Selling','Stock':'back_img Stock','Buying':'back_img Buying','Maintenance':'back_img Maintenance','Production':'back_img Production','HR':'back_img HR'};this.make_item_body(parent,lbl,link_list);}
+SetupItem.prototype.make_item_body=function(parent,lbl,link_list){this.link_area=parent;this.render_item_body(lbl,link_list);}
+SetupItem.prototype.render_item_body=function(lbl,link_list){var me=this;link_list.sort(function(a,b){return a[0]>b[0];});for(var i=0;i<link_list.length;i++){var wrapper=$a(this.link_area,'div','',{marginBottom:'4px',padding:'2px'});$(wrapper).hover(function(){$y(this,{backgroundColor:'#EEF'})},function(){$y(this,{backgroundColor:''})})
+var tab=make_table($a(wrapper,'div'),1,2,'100%',[200/7+'%',500/7+'%'])
+var dt=$a($td(tab,0,0),'span','link_type');dt.innerHTML=link_list[i][0];dt.label=link_list[i][0];dt.arg=link_list[i][1];dt.nm=link_list[i][2];if(dt.arg==1)dt.cn=link_list[i][3];else if(dt.arg==2)dt.cb=link_list[i][3];dt.onclick=function(){me.link_action(this)}
+$y($td(tab,0,1),{color:'#777'});$td(tab,0,1).innerHTML=link_list[i][4];}}
+SetupItem.prototype.link_action=function(obj){var me=this;var obj=obj;if(obj.arg==1){if(in_list(profile.can_read,obj.nm)){if(obj.cn!='')
+loaddocbrowser(obj.nm,obj.nm,obj.cn);else
+loaddocbrowser(obj.nm);}
+else
+msgprint('No read permission',1);}
+else if(obj.arg==2){me.show_page(obj);}
+else if(obj.arg==3){newdoc(obj.nm);}}
+SetupItem.prototype.show_page=function(obj){var me=obj;var callback=function(r,rt)
+{if(r.message){if(me.cb=='')
+loadpage(me.nm);else
+show_chart_browser(me.nm,me.cb);}
+else
+msgprint('No read permission',1);}
+$c_obj('Setup Wizard Control','get_page_lst',me.nm,callback);}
+SetupData=function(cnty){this.system={'System':[['Global Defaults',3,'Manage Account','','Set global default values'],['Manage Series',3,'Naming Series','','Manage numbering series for transactions'],['Custom Field',1,'Custom Field','dt'+NEWLINE+'label'+NEWLINE+'fieldtype'+NEWLINE+'options','Add and manage custom fields on forms'],['Email Settings',3,'Email Settings','','Outgoing email server and address'],['Notification Settings',3,'Notification Control','','Automatic emails set at selected events'],['Company',1,'Company','id'+NEWLINE+'is_active'+NEWLINE+'email','Manage list of companies'],['Fiscal Year',1,'Fiscal Year','id'+NEWLINE+'company'+NEWLINE+'is_active'+NEWLINE+'year','Manage list of fiscal years'],['Personalize',3,'Personalize','','Set your banner'],['Manage Trash',2,'Trash','','Restore trashed items'],['Import Data',2,'Import Data','','Import data from CSV files'],['Manage Users',2,'My Company','','Add / remove users and manage their roles'],['Web Forms',2,'Webforms','','Code to embed forms in yor website'],['Permissions Manager',2,'Permission Engine','','Manage all permissions from one tool (beta)'],['Property Setter',1,'Property Setter','','Customize properties of a Form (DocType) or Field'],['Letter Head',1,'Letter Head','','Manage different letter heads for Prints'],['SMS Settings',3,'SMS Settings','','Integrate your personalized SMS gateway which support http web service'],['SMS Center',3,'SMS Center','','Send mass sms to your leads, contacts and partners']]};this.general={'General':[['Authorization Rule',1,'Authorization Rule','','Set rules based on amounts'],['Print Heading',1,'Print Heading','','Manage headings for printing transactions'],['Term',1,'Term','','Manage template of standard Terms for order / invoices etc'],['Currency',1,'Currency','','Manage list of currencies'],['Country',1,'Country','','Country master'],['State',1,'State','','State master'],['Activty Type',1,'Activity Type','','Types of activities that you can select in your Timesheet'],['City',1,'City','','City master']]};this.selling={'Selling':[['Customer Group',2,'Sales Browser','Customer Group','Manage customer categories'],['Territory',2,'Sales Browser','Territory','Manage sales territories'],['Customer',1,'Customer','customer_group'+NEWLINE+'country','Customer master'],['Sales Person',2,'Sales Browser','Sales Person','Manage sales persons'],['Sales Partner',1,'Sales Partner','','Manage sales partners'],['Campaign',1,'Campaign','id'+NEWLINE+'campaign_name'+NEWLINE+'description','Manage sales / marketing campaigns'],['Sales BOM',1,'Sales BOM','id'+NEWLINE+'is_active'+NEWLINE+'new_item_name'+NEWLINE+'description'+NEWLINE+'item_group','Manage Sales Bill of Material (Main item + accessories)'],['Price List',1,'Price List','','Price list master']]};this.accounts={'Accounts':[['Chart of Accounts',2,'Accounts Browser','Account','Manage chart of accounts'],['Chart of Cost Centers',2,'Accounts Browser','Cost Center','Manage chart of cost centers'],['POS Setting',1,'POS Setting','','Manage Point of Sales default Settings.']]};if(cnty=='India'){var lst1=[['TDS Rate Chart',1,'TDS Rate Chart','','TDS rate master'],['TDS Category',1,'TDS Category','id'+NEWLINE+'module','TDS categories']];for(var i=0;i<lst1.length;i++)
+this.accounts['Accounts'].push(lst1[i]);}
+var lst=[['Monthly Distribution',1,'Budget Distribution','id'+NEWLINE+'fiscal_year'+NEWLINE+'distribution_id','Manage budget distributions (seasonalities)'],['Sales Other Charges',1,'Other Charges','','Manage your charge structures (taxes + charges) for sales'],['Purchase Other Charges',1,'Purchase Other Charges','','Manage your charge structures (taxes + charges) for purchase'],['Mode of Payment',1,'Mode of Payment','','Mode of payment master']];for(var i=0;i<lst.length;i++)
+this.accounts['Accounts'].push(lst[i]);this.stock={'Stock':[['Item Group',2,'Sales Browser','Item Group','Manage item classifications'],['Item',1,'Item','name'+NEWLINE+'item_group'+NEWLINE+'description','Item master'],['Brand',1,'Brand','id'+NEWLINE+'description','Brand master'],['Batch',1,'Batch','name'+NEWLINE+'start_date'+NEWLINE+'item'+NEWLINE+'expiry_date','Manage batches'],['Price List',1,'Price List','','Price list master'],['UOM',1,'UOM','','Unit of measure (UOM) master'],['Warehouse Type',1,'Warehouse Type','','Warehouse classifications'],['Warehouse',1,'Warehouse','','Warehouse master']]};this.buying={'Buying':[['Supplier Type',1,'Supplier Type','','Manage supplier classifications'],['Supplier',1,'Supplier','id'+NEWLINE+'supplier_type'+NEWLINE+'supplier_status'+NEWLINE+'company','Supplier master']]};this.maintenance={'Maintenance':[['Serial No',1,'Serial No','item_code'+NEWLINE+'status'+NEWLINE+'pr_no'+NEWLINE+'delivery_note_no'+NEWLINE+'customer_name','Manage unique serial numbers for items'],['Purpose of Service',1,'Purpose of Service','','Purpose of service master']]};this.production={'Production':[['Bill of Materials',1,'Bill Of Materials','id'+NEWLINE+'item'+NEWLINE+'description'+NEWLINE+'operating_cost'+NEWLINE+'maintained_by','Muti-level bill of materials and operations'],['Workstation',1,'Workstation','id'+NEWLINE+'workstation_name'+NEWLINE+'warehouse'+NEWLINE+'description','Workstation master']]};this.hr={'HR':[['Department',1,'Department','','Company department master'],['Designation',1,'Designation','','Company designation master'],['Branch',1,'Branch','','Manage branches for your company'],['Grade',1,'Grade','','Manage employee grades'],['Employment Type',1,'Employment Type','','Manage types of employment'],['Employee',1,'Employee','employee_name'+NEWLINE+'employment_type'+NEWLINE+'status'+NEWLINE+'branch'+NEWLINE+'designation'+NEWLINE+'department'+NEWLINE+'grade'+NEWLINE+'reports_to','Employee master'],['Earning Type',1,'Earning Type','taxable'+NEWLINE+'exemption_limit','Types of salary earning master'],['Deduction Type',1,'Deduction Type','','Types of salary deduction master'],['Expense Type',1,'Expense Type','','Types of expense master'],['Salary Structure',1,'Salary Structure','employee'+NEWLINE+'is_active'+NEWLINE+'fiscal_year'+NEWLINE+'from_date'+NEWLINE+'ctc'+NEWLINE+'total_earning'+NEWLINE+'total_deduction'+NEWLINE+'total','Salary structure template'],['Holiday List',1,'Holiday List','fiscal_year','List of holidays'],['Leave Type',1,'Leave Type','max_days_allowed'+NEWLINE+'is_carry_forward'+NEWLINE+'is_encash','Leave type master'],['KRA Template',1,'KRA Template','','Template of Key Result Areas (KRAs)']]};}
\ No newline at end of file
diff --git a/setup/page/setup/setup.html b/setup/page/setup/setup.html
new file mode 100644
index 0000000..e60d00b
--- /dev/null
+++ b/setup/page/setup/setup.html
@@ -0,0 +1 @@
+<div id="setup_div" class="layout_wrapper"></div>
\ No newline at end of file
diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js
new file mode 100644
index 0000000..645fbd1
--- /dev/null
+++ b/setup/page/setup/setup.js
@@ -0,0 +1,253 @@
+pscript.onload_Setup = function() {
+  var parent = $i('setup_div');
+  add_space_holder(parent);
+
+  var callback = function(r,rt){
+
+    // header
+    parent.page_head = new PageHeader(parent,'Setup');
+    
+    // sections
+    var setup_data = new SetupData(r.message);
+    pscript.setup_make_sections(setup_data);
+    
+    remove_space_holder();
+  }
+  $c_obj('Setup Wizard Control','get_country','',callback);  
+}
+
+pscript.setup_set_height = function() {
+  var parent = $i('setup_div');
+  $y(parent.tray.body, {height: get_window_height() - parent.page_head.wrapper.offsetHeight + 'px', overflow:'auto'})
+}
+
+// Make sections
+// ===================================================
+
+pscript.setup_make_sections = function(setup_data) {
+  var parent = $i('setup_div');
+  parent.tray = new TrayPage(parent)
+
+  // list of setup data
+  var lst = [setup_data.system, setup_data.general, setup_data.accounts, setup_data.selling, setup_data.buying, setup_data.stock, setup_data.hr, setup_data.maintenance, setup_data.production];
+
+  for(var s=0; s<lst.length; s++){
+    var lbl = keys(lst[s])[0];
+
+    var ti = parent.tray.add_item(lbl, null, null, 1)
+    new SetupItem(ti.body, lbl, lst[s][lbl]);
+
+    if(s==0) ti.expand();
+  }
+  
+  setTimeout(pscript.setup_set_height, 100);
+  resize_observers.push(pscript.setup_set_height);
+}
+
+// Setup Item
+// ===================================================
+SetupItem = function(parent, lbl, link_list) {
+  this.icons = {'System':'back_img Setup', 'General':'back_img Home', 'Accounts':'back_img Accounts', 'Selling':'back_img Selling', 'Stock':'back_img Stock', 'Buying':'back_img Buying', 'Maintenance':'back_img Maintenance', 'Production':'back_img Production', 'HR':'back_img HR'};
+  this.make_item_body(parent, lbl, link_list);
+}
+
+
+// Make body for item in setup wizard
+// ===================================================
+SetupItem.prototype.make_item_body = function(parent, lbl, link_list){
+  // item link area
+  this.link_area = parent;
+  this.render_item_body(lbl, link_list);
+}
+
+
+// Render item body
+// ===================================================
+SetupItem.prototype.render_item_body = function(lbl, link_list) {
+  var me = this;
+  // set item header
+
+  link_list.sort(function(a, b) { return a[0] > b[0]; });
+
+  // show links for item
+  for(var i=0; i<link_list.length; i++){
+    var wrapper = $a(this.link_area, 'div','',{marginBottom:'4px', padding:'2px'});
+    $(wrapper).hover(
+      function() { $y(this,{backgroundColor:'#EEF'}) }
+      ,function() { $y(this,{backgroundColor:''}) }
+    )
+    var tab = make_table($a(wrapper,'div'), 1, 2, '100%', [200/7+'%', 500/7+'%'])
+
+    var dt= $a($td(tab,0,0), 'span', 'link_type');
+    dt.innerHTML = link_list[i][0]; 
+    dt.label = link_list[i][0];
+    dt.arg = link_list[i][1]; 
+    dt.nm = link_list[i][2];
+    
+    if(dt.arg == 1) dt.cn = link_list[i][3]; 
+    else if(dt.arg == 2) dt.cb=link_list[i][3];
+ 
+    // execute when link is clicked
+    dt.onclick = function(){
+      me.link_action(this)
+    }
+    
+    // description
+    $y($td(tab,0,1), {color:'#777'});
+    $td(tab,0,1).innerHTML = link_list[i][4];
+  }
+}
+
+
+// Execute when link is clicked
+// ----------------------------
+SetupItem.prototype.link_action = function(obj) {
+  var me = this;
+  var obj = obj;
+  
+  // if object links to a doc browser
+  if(obj.arg == 1){
+    if(in_list(profile.can_read, obj.nm)){
+      if(obj.cn !='')
+        loaddocbrowser(obj.nm, obj.nm, obj.cn);
+      else
+        loaddocbrowser(obj.nm);
+    }
+    else
+      msgprint('No read permission',1);
+  }
+  
+  // if obj links to a page
+  else if(obj.arg == 2){
+    me.show_page(obj);
+  }
+  
+  // if object links to a single doctype
+  else if(obj.arg == 3){
+    newdoc(obj.nm);
+  }
+}
+
+
+// Show page for corresponding link
+// --------------------------------
+SetupItem.prototype.show_page = function(obj) {
+  var me = obj;
+  var callback = function(r,rt)
+  {
+    if(r.message){
+      if(me.cb == '')
+        loadpage(me.nm);
+      else
+        show_chart_browser(me.nm,me.cb);    
+    }
+    else
+      msgprint('No read permission',1);
+  }
+  $c_obj('Setup Wizard Control','get_page_lst',me.nm,callback);  
+}
+
+
+// Setup Data
+// ======================================================================================================================================================= 
+SetupData = function(cnty){
+
+  // arg : 1 - Docbrowser, 2 - Page, 3 - DocType
+  
+  //[label, arg, name, callback/col_name, description]
+
+  this.system = {'System':[['Global Defaults',3,'Manage Account','','Set global default values'],
+    ['Manage Series',3,'Naming Series','','Manage numbering series for transactions'],
+    ['Custom Field',1,'Custom Field','dt'+NEWLINE+'label'+NEWLINE+'fieldtype'+NEWLINE+'options','Add and manage custom fields on forms'],
+    ['Email Settings',3,'Email Settings','','Outgoing email server and address'],
+    ['Notification Settings',3,'Notification Control','','Automatic emails set at selected events'],
+    ['Company',1,'Company','id'+NEWLINE+'is_active'+NEWLINE+'email','Manage list of companies'],
+    ['Fiscal Year',1,'Fiscal Year','id'+NEWLINE+'company'+NEWLINE+'is_active'+NEWLINE+'year','Manage list of fiscal years'],
+    ['Personalize',3,'Personalize','','Set your banner'],
+    ['Manage Trash',2,'Trash','','Restore trashed items'],
+    ['Import Data',2,'Import Data','','Import data from CSV files'],
+    ['Manage Users',2,'My Company','','Add / remove users and manage their roles'],
+    ['Web Forms',2,'Webforms','', 'Code to embed forms in yor website'],
+    ['Permissions Manager',2,'Permission Engine','', 'Manage all permissions from one tool (beta)'],
+    ['Property Setter',1,'Property Setter','', 'Customize properties of a Form (DocType) or Field'],
+    //['Badge Settings',3,'Badge Settings','','Define rules for assigning badges to users'],
+    //['Social Badge',1,'Social Badge','id'+NEWLINE+'badge_image'+NEWLINE+'badge_description'+NEWLINE+'badge_points','Social badge master'],
+    ['Letter Head',1,'Letter Head','','Manage different letter heads for Prints'],
+    ['SMS Settings',3,'SMS Settings','','Integrate your personalized SMS gateway which support http web service'],
+    ['SMS Center',3,'SMS Center','','Send mass sms to your leads, contacts and partners']
+  ]};
+
+  
+  this.general = {'General':[['Authorization Rule',1,'Authorization Rule','','Set rules based on amounts'],
+    ['Print Heading',1,'Print Heading','','Manage headings for printing transactions'],
+    ['Term',1,'Term','','Manage template of standard Terms for order / invoices etc'],
+    ['Currency',1,'Currency','','Manage list of currencies'],
+    ['Country',1,'Country','','Country master'],
+    ['State',1,'State','','State master'],
+    ['Activty Type',1,'Activity Type','','Types of activities that you can select in your Timesheet'],
+    ['City',1,'City','','City master']]};
+  
+  this.selling = {'Selling':[['Customer Group',2,'Sales Browser','Customer Group','Manage customer categories'],
+    ['Territory',2,'Sales Browser','Territory','Manage sales territories'],
+    ['Customer',1,'Customer','customer_group'+NEWLINE+'country','Customer master'],
+    ['Sales Person',2,'Sales Browser','Sales Person','Manage sales persons'],
+    ['Sales Partner',1,'Sales Partner','', 'Manage sales partners'],
+    ['Campaign',1,'Campaign','id'+NEWLINE+'campaign_name'+NEWLINE+'description','Manage sales / marketing campaigns'],
+    ['Sales BOM',1,'Sales BOM','id'+NEWLINE+'is_active'+NEWLINE+'new_item_name'+NEWLINE+'description'+NEWLINE+'item_group','Manage Sales Bill of Material (Main item + accessories)'],
+    ['Price List',1,'Price List','','Price list master']]};
+
+  this.accounts = {'Accounts':[['Chart of Accounts',2,'Accounts Browser','Account','Manage chart of accounts'],
+    ['Chart of Cost Centers',2,'Accounts Browser','Cost Center','Manage chart of cost centers'],
+    ['POS Setting',1,'POS Setting','','Manage Point of Sales default Settings.']]};
+    
+  // if country = india; show india related doctypes
+  //-------------------------------------------------
+    
+  if(cnty == 'India'){  
+    var lst1 = [['TDS Rate Chart',1,'TDS Rate Chart','', 'TDS rate master'],['TDS Category',1,'TDS Category','id'+NEWLINE+'module','TDS categories']];
+    for(var i =0; i<lst1.length;i++)      
+      this.accounts['Accounts'].push(lst1[i]);
+  }
+  //--------------------------------------------------    
+  
+  var lst = [['Monthly Distribution',1,'Budget Distribution','id'+NEWLINE+'fiscal_year'+NEWLINE+'distribution_id','Manage budget distributions (seasonalities)'],
+    ['Sales Other Charges',1,'Other Charges','','Manage your charge structures (taxes + charges) for sales'],
+    ['Purchase Other Charges',1,'Purchase Other Charges','','Manage your charge structures (taxes + charges) for purchase'],
+    ['Mode of Payment',1,'Mode of Payment','','Mode of payment master']];
+             
+  for(var i =0; i<lst.length;i++)
+      this.accounts['Accounts'].push(lst[i]);
+  
+  this.stock = {'Stock':[['Item Group',2,'Sales Browser','Item Group','Manage item classifications'],
+    ['Item',1,'Item','name'+NEWLINE+'item_group'+NEWLINE+'description','Item master'],
+    ['Brand',1,'Brand','id'+NEWLINE+'description','Brand master'],
+    ['Batch',1,'Batch','name'+NEWLINE+'start_date'+NEWLINE+'item'+NEWLINE+'expiry_date','Manage batches'],
+    ['Price List',1,'Price List','','Price list master'],
+    ['UOM',1,'UOM','','Unit of measure (UOM) master'],
+    ['Warehouse Type',1,'Warehouse Type','','Warehouse classifications'],
+    ['Warehouse',1,'Warehouse','','Warehouse master']]};
+  
+  this.buying = {'Buying':[['Supplier Type',1,'Supplier Type','','Manage supplier classifications'],
+    ['Supplier',1,'Supplier','id'+NEWLINE+'supplier_type'+NEWLINE+'supplier_status'+NEWLINE+'company','Supplier master']]};
+  
+  this.maintenance = {'Maintenance':[['Serial No',1,'Serial No','item_code'+NEWLINE+'status'+NEWLINE+'pr_no'+NEWLINE+'delivery_note_no'+NEWLINE+'customer_name','Manage unique serial numbers for items'],
+    ['Purpose of Service',1,'Purpose of Service','','Purpose of service master']]};
+  
+  this.production = {'Production':[['Bill of Materials',1,'Bill Of Materials','id'+NEWLINE+'item'+NEWLINE+'description'+NEWLINE+'operating_cost'+NEWLINE+'maintained_by','Muti-level bill of materials and operations'],
+    ['Workstation',1,'Workstation','id'+NEWLINE+'workstation_name'+NEWLINE+'warehouse'+NEWLINE+'description','Workstation master']]};
+  
+  this.hr = {'HR':[['Department',1,'Department','','Company department master'],
+    ['Designation',1,'Designation','','Company designation master'],
+    ['Branch',1,'Branch','','Manage branches for your company'],
+    ['Grade',1,'Grade','','Manage employee grades'],
+    ['Employment Type',1,'Employment Type','','Manage types of employment'],
+    ['Employee',1,'Employee','employee_name'+NEWLINE+'employment_type'+NEWLINE+'status'+NEWLINE+'branch'+NEWLINE+'designation'+NEWLINE+'department'+NEWLINE+'grade'+NEWLINE+'reports_to','Employee master'],
+    ['Earning Type',1,'Earning Type','taxable'+NEWLINE+'exemption_limit','Types of salary earning master'],
+    ['Deduction Type',1,'Deduction Type','','Types of salary deduction master'],
+    ['Expense Type',1,'Expense Type','', 'Types of expense master'],
+      
+    ['Salary Structure',1,'Salary Structure','employee'+NEWLINE+'is_active'+NEWLINE+'fiscal_year'+NEWLINE+'from_date'+NEWLINE+'ctc'+NEWLINE+'total_earning'+NEWLINE+'total_deduction'+NEWLINE+'total','Salary structure template'],
+    ['Holiday List',1,'Holiday List','fiscal_year','List of holidays'],
+    ['Leave Type',1,'Leave Type','max_days_allowed'+NEWLINE+'is_carry_forward'+NEWLINE+'is_encash','Leave type master'],
+    ['KRA Template',1,'KRA Template','','Template of Key Result Areas (KRAs)']]};
+}
diff --git a/setup/page/setup/setup.txt b/setup/page/setup/setup.txt
new file mode 100644
index 0000000..f2a7a70
--- /dev/null
+++ b/setup/page/setup/setup.txt
@@ -0,0 +1 @@
+[{'creation': '2010-07-13 13:42:28', 'module': 'Setup', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'harshada@webnotestech.com', 'script': None, 'show_in_menu': None, 'content': None, 'page_name': 'Setup', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Setup', 'idx': None, 'static_content': None, 'modified': '2010-11-24 16:25:07', 'parenttype': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/setup/page/setup/setup_static.html b/setup/page/setup/setup_static.html
new file mode 100644
index 0000000..54fee71
--- /dev/null
+++ b/setup/page/setup/setup_static.html
@@ -0,0 +1 @@
+Setup
\ No newline at end of file
diff --git a/setup/page/setup_wizard/__init__.py b/setup/page/setup_wizard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/setup_wizard/__init__.py
diff --git a/setup/page/setup_wizard/setup_wizard.html b/setup/page/setup_wizard/setup_wizard.html
new file mode 100644
index 0000000..1f5547e
--- /dev/null
+++ b/setup/page/setup_wizard/setup_wizard.html
@@ -0,0 +1 @@
+<div id="setup_wizard_wrapper" class="layout_wrapper"></div>
\ No newline at end of file
diff --git a/setup/page/setup_wizard/setup_wizard.js b/setup/page/setup_wizard/setup_wizard.js
new file mode 100644
index 0000000..59308f1
--- /dev/null
+++ b/setup/page/setup_wizard/setup_wizard.js
@@ -0,0 +1,167 @@
+pscript['onload_Setup Wizard'] = function()
+{   
+
+  // header and toolbar
+  var h = new PageHeader('setup_wizard_wrapper','Setup Wizard','All important setup items in one place');
+
+  pscript.setup_wizard_callback();
+}
+
+// ==================================================================================================
+
+pscript.setup_wizard_callback = function(){
+    var items = {};
+    items['Customer'] = new pscript.Setup_Wizard_Obj('Customer', 'customer_name', 0, '', 'Customer', 'Manage your customers',1);
+    items['Supplier'] = new pscript.Setup_Wizard_Obj('Supplier', 'supplier_name', 0, '', 'Supplier', 'Manage your supplier',1);
+    items['Item'] = new pscript.Setup_Wizard_Obj('Item', 'item_name', 0, '', 'Item', 'Create your items',1);
+    //items['Customer Group'] = new pscript.Setup_Wizard_Obj('Customer Group', 'group_name', 0, '', 'Customer Group', 'Organizes your customers for better analysis');
+    items['Price List'] = new pscript.Setup_Wizard_Obj('Price List', 'price_list_name', 0, '', 'Price List', 'Helps you maintain different prices for different customers, currencies etc.');
+    items['Supplier Type'] = new pscript.Setup_Wizard_Obj('Supplier Type', 'supplier_type', 0, '', 'Supplier Type', 'Organizes your suppliers for better analysis');
+    //items['Item Group'] = new pscript.Setup_Wizard_Obj('Item Group', 'group_name', 0, '', 'Item Group', 'Organizes your items for better analysis');
+    items['UoM'] = new pscript.Setup_Wizard_Obj('UOM', 'uom_name', 0, '', 'UOM', 'Maintain multiple Units of Measure (UOM)');
+    items['Warehouse Type'] = new pscript.Setup_Wizard_Obj('Warehouse Type', 'warehouse_type', 0, '', 'Warehouse Type', 'Define types of warehouses');
+    items['Warehouse'] = new pscript.Setup_Wizard_Obj('Warehouse', 'warehouse_name', 'warehouse_type', 'Warehouse Type', 'Warehouse', 'Manage stock across different warehouses');
+    items['Print Heading'] = new pscript.Setup_Wizard_Obj('Print Heading', 'print_heading', 'transaction', 'Transaction', 'Print Heading', 'Define print heading for various transaction.');
+    items['Warehouse Type'].onmake = function(){
+       items['Warehouse'].refresh_select('warehouse_type', 'Warehouse Type', 'Warehouse');
+    }
+    items['Print Heading'].onmake = function(){
+       items['Print Heading'].refresh_select('transaction', 'Transaction', 'Print Heading');
+    }
+}
+
+// ==================================================================================================
+pscript.Setup_Wizard_Obj = function(lbl, name_field, opt_fieldname, opt_field_tbl, dt, desc, important) 
+{
+    this.lbl = lbl;
+    this.make_body(lbl, important);
+    if(lbl != 'Item')
+      this.make_input(name_field);
+    if(opt_fieldname){
+      this.make_select(opt_fieldname, opt_field_tbl, dt);
+    }
+   
+    this.show_description(desc);
+    this.make_button();
+    this.create_doc_link(dt);
+
+}
+
+pscript.Setup_Wizard_Obj.prototype.make_body = function(lbl, important) {
+    var wrapper = $a($i('setup_wizard_wrapper'), 'div', '', {padding:'8px', borderBottom: '1px solid #AAA'});
+    if(important)$y(wrapper, {backgroundColor:'#FFD'});
+    this.tab = make_table(wrapper,1,3,'90%',['20%','50%','30%'], {padding:'2px 0px', verticalAlign:'middle'});
+    this.desc_area = $a(wrapper,'div','comment');
+    
+    $td(this.tab,0,0).innerHTML = lbl.bold();
+}
+
+pscript.Setup_Wizard_Obj.prototype.make_input = function(name_field){
+    this.input = $a_input($td(this.tab,0,1), 'text');
+    this.name_field = name_field;
+}
+
+pscript.Setup_Wizard_Obj.prototype.make_select = function(fn, ft, dt){
+    this.select = $a($td(this.tab,0,1), 'select', '', {width:'120px', marginLeft:'8px'});
+    this.opt_field = fn;
+    this.sel_field = 'Select ' + ft + '...';
+    this.refresh_select(fn, ft, dt);
+}                
+
+pscript.Setup_Wizard_Obj.prototype.refresh_select = function(fn, ft, dt){
+  var me = this;
+  if(ft == 'Transaction'){
+    empty_select(me.select);
+    add_sel_options(me.select, ['Select Transaction ...','Purchase Order','Sales Order','Service Order','Purchase Receipt','Delivery Note','Receivable Voucher','Payable Voucher','Journal Voucher']);
+  }
+  else{
+    $c_obj('Setup Wizard Control', 'get_master_lists','', function(r,rt){
+      var ft_lst = [];
+      if(r.message) ft_lst = r.message;
+      ft_lst.push('Select Warehouse Type ...');
+      empty_select(me.select);
+      add_sel_options(me.select, ft_lst.reverse(), 'Warehouse Type');
+    });
+  }
+}  
+ 
+pscript.Setup_Wizard_Obj.prototype.make_button = function(){   
+    var me = this;
+
+    var create = $a($td(this.tab,0,1), 'button', '', {marginLeft:'8px'});
+    create.innerHTML = 'Create';
+    
+    create.onclick = function(){
+        me.create_record(this);
+    }
+}
+
+// show description
+pscript.Setup_Wizard_Obj.prototype.show_description=function(desc){ 
+    this.desc_area.innerHTML = desc;
+}
+
+// create link to show listing of all records
+pscript.Setup_Wizard_Obj.prototype.create_doc_link = function(doc_link){  
+    this.obj_link = $a($td(this.tab,0,2), 'span', 'link_type',{marginLeft:'8px'});
+    this.obj_link.innerHTML = 'View ' + doc_link + ' list';
+    this.dt = doc_link;
+
+    this.obj_link.onclick = function(){
+      if(doc_link == 'Customer') doc_lst = 'customer_group'+NEWLINE+'country';
+      else if(doc_link == 'Supplier') doc_lst = 'supplier_type'+NEWLINE+'supplier_status'+NEWLINE+'company';
+      else if(doc_link == 'Item') doc_lst = 'item_group'+NEWLINE+'description';
+        
+      if(doc_link == 'Customer' || doc_link == 'Supplier' || doc_link == 'Item')
+        loaddocbrowser(doc_link,doc_link, doc_lst);
+      else
+        loaddocbrowser(doc_link);
+    }
+}    
+pscript.Setup_Wizard_Obj.prototype.create_record = function(cur_obj)
+{   
+    var me = this;
+    if(me.lbl == 'Item'){ me.create_master_rec(); }
+    else{
+      if(this.input.value) { //check for input value
+        
+        if (this.select && (this.sel_field == this.select.value)){ //check for value is selected or not
+          alert('Please select '+this.select.value);  
+          this.input.value = '';
+        }
+        else{
+          args = {};
+          args['Doctype'] = this.dt;
+          if(strip(this.input.value) == ''){ alert("Please enter proper name."); me.input.value = '';}
+          else{
+            if(me.lbl == 'Customer' || me.lbl == 'Supplier'){ this.create_master_rec(); }
+            else{
+              args[this.name_field] = this.input.value;
+              args[this.opt_field] = this.opt_field ? this.select.value : '';
+              
+              $c_obj('Setup Wizard Control', 'create_record', JSON.stringify(args), function(r,rt){        
+                alert(r.message);
+                me.input.value = '';
+                if(me.onmake) me.onmake();  
+              });
+            }
+          }
+        }
+      }
+      else
+        alert("Please enter " +this.dt);
+    }
+}
+
+pscript.Setup_Wizard_Obj.prototype.create_master_rec = function(){
+  var me = this;
+  var fn = function(new_docname) {
+    var new_doc = locals[me.lbl][new_docname];
+    if(me.lbl == 'Customer')
+      new_doc.customer_name = me.input.value;
+    else if(me.lbl == 'Supplier')
+      new_doc.supplier_name = me.input.value;
+  }
+  new_doc(me.lbl, fn);
+  
+}
\ No newline at end of file
diff --git a/setup/page/setup_wizard/setup_wizard.txt b/setup/page/setup_wizard/setup_wizard.txt
new file mode 100644
index 0000000..e79cc54
--- /dev/null
+++ b/setup/page/setup_wizard/setup_wizard.txt
@@ -0,0 +1 @@
+[{'creation': '2010-04-26 11:03:08', 'module': 'Setup', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Setup Wizard', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Setup Wizard', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000127', 'parent': 'Setup Wizard', 'creation': '2010-04-26 13:35:08', 'modified': '2010-07-13 13:36:23', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'System Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/setup/page/setup_wizard/setup_wizard_static.html b/setup/page/setup_wizard/setup_wizard_static.html
new file mode 100644
index 0000000..281c686
--- /dev/null
+++ b/setup/page/setup_wizard/setup_wizard_static.html
@@ -0,0 +1 @@
+<div></div>
\ No newline at end of file
diff --git a/setup/page/webforms/__init__.py b/setup/page/webforms/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setup/page/webforms/__init__.py
diff --git a/setup/page/webforms/webforms.html b/setup/page/webforms/webforms.html
new file mode 100644
index 0000000..e1717dc
--- /dev/null
+++ b/setup/page/webforms/webforms.html
@@ -0,0 +1,13 @@
+<div class="layout_wrapper">
+<div id="webform_div"></div>
+<p><strong>Note : </strong>Copy and paste code provided below in your website wherever you want to show the form to capture details</p>
+<p>&nbsp;</p>
+<p><span style="font-size: medium;"><strong>Lead</strong></span></p>
+<div id="lead_div"></div>
+<p><span style="font-size: medium;"><strong>Customer Issue</strong></span></p>
+<div id="cust_issue_div"></div>
+<p><span style="font-size: medium;"><strong>Job Application</strong></span></p>
+<div id="job_div"></div>
+<p><span style="font-size: medium;"><strong>Ticket</strong></span></p>
+<div id="ticket_div"></div>
+</div>
\ No newline at end of file
diff --git a/setup/page/webforms/webforms.js b/setup/page/webforms/webforms.js
new file mode 100644
index 0000000..d429ce0
--- /dev/null
+++ b/setup/page/webforms/webforms.js
@@ -0,0 +1,26 @@
+pscript.onload_Webforms = function(){
+
+  $c_obj('Home Control','get_acc_id','', function(r,rt) {
+    if(r.message) {
+      var acc_id = r.message; 
+  var parent = $i('webform_div');
+  new PageHeader(parent,'Web Forms','');
+      
+      var lead_dv = $a('lead_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'90%'});
+      var cust_issue_dv = $a('cust_issue_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'95%'});
+      var job_dv = $a('job_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'95%'});
+      var ticket_dv = $a('ticket_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'95%'});
+
+      // url
+      if(window.location.href.indexOf('?')!=-1)
+        var url = window.location.href.split('?')[0];
+      else
+        var url = window.location.href.split('#')[0];
+
+      lead_dv.innerHTML = '&lt;iframe src ="'+url+'?ac_name='+acc_id+'&embed=Lead" width ="400" height="800" frameborder="0"&gt;&lt;/iframe&gt;';
+      cust_issue_dv.innerHTML = '&lt;iframe src ="'+url+'?ac_name='+acc_id+'&embed=Customer Issue" width ="400" height="500" frameborder="0"&gt;&lt;/iframe&gt;';
+      job_dv.innerHTML = '&lt;iframe src ="'+url+'?ac_name='+acc_id+'&embed=Job Application"  width ="400" height="800" frameborder="0""&gt;&lt;/iframe&gt;';
+      ticket_dv.innerHTML = '&lt;iframe src ="'+url+'?ac_name='+acc_id+'&embed=Support Ticket"  width ="400" height="800" frameborder="0""&gt;&lt;/iframe&gt;';
+    }
+  }); 
+}
diff --git a/setup/page/webforms/webforms.txt b/setup/page/webforms/webforms.txt
new file mode 100644
index 0000000..63a8289
--- /dev/null
+++ b/setup/page/webforms/webforms.txt
@@ -0,0 +1 @@
+[{'creation': '2010-12-18 17:10:03', 'module': 'Setup', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': None, 'content': None, 'page_name': 'Webforms', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Webforms', 'idx': None, 'static_content': None, 'modified': '2010-12-18 17:14:25', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000075', 'parent': 'Webforms', 'creation': '2010-12-18 17:11:12', 'modified': '2010-12-18 17:14:25', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/setup/page/webforms/webforms_static.html b/setup/page/webforms/webforms_static.html
new file mode 100644
index 0000000..3488a17
--- /dev/null
+++ b/setup/page/webforms/webforms_static.html
@@ -0,0 +1 @@
+webforms
\ No newline at end of file