Sourced wnframework-modules from Google Code as erpnext
diff --git a/crm/Module Def/CRM/CRM.txt b/crm/Module Def/CRM/CRM.txt
new file mode 100644
index 0000000..815a95c
--- /dev/null
+++ b/crm/Module Def/CRM/CRM.txt
@@ -0,0 +1,694 @@
+[
+	{
+		'_last_update': None,
+		'creation': '2010-11-30 17:31:24',
+		'disabled': 'No',
+		'docstatus': 0,
+		'doctype': 'Module Def',
+		'doctype_list': 'Print Format, Sales Order\nPrint Format, Quotation Format\nPrint Format, Delivery Note Format',
+		'file_list': 'crm.gif,FileData/00208',
+		'idx': None,
+		'is_hidden': 'No',
+		'last_updated_date': '2010-12-09 17:04:58',
+		'modified': '2011-02-24 17:36:51',
+		'modified_by': 'Administrator',
+		'module_desc': 'Manage you sales team, with your leads, customers, quotes, orders etc.',
+		'module_icon': 'Selling.gif',
+		'module_label': 'Selling',
+		'module_name': 'CRM',
+		'module_page': None,
+		'module_seq': 4,
+		'name': 'CRM',
+		'owner': 'Administrator',
+		'parent': None,
+		'parentfield': None,
+		'parenttype': None,
+		'trash_reason': None,
+		'widget_code': None
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 17:31:24',
+		'description': 'Database of potential customers you need to keep in touch with',
+		'display_name': 'Lead',
+		'doc_name': 'Lead',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'status\nlead_owner\nlead_name\ncontact_no\ncontact_by\ncontact_date\nexpected_month',
+		'hide': None,
+		'icon': None,
+		'idx': 1,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00067',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 17:31:24',
+		'description': 'Your Customer Database',
+		'display_name': 'Customer',
+		'doc_name': 'Customer',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'customer_group\ncountry',
+		'hide': None,
+		'icon': None,
+		'idx': 2,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00068',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 17:31:24',
+		'description': 'Specific requirements from a Lead / Customer',
+		'display_name': 'Enquiry',
+		'doc_name': 'Enquiry',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ncompany',
+		'hide': None,
+		'icon': None,
+		'idx': 3,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00069',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 17:31:24',
+		'description': 'Offers you have made to your customers',
+		'display_name': 'Quotation',
+		'doc_name': 'Quotation',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ngrand_total\ncompany',
+		'hide': None,
+		'icon': None,
+		'idx': 4,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00070',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 17:31:24',
+		'description': 'Database of confirmed Sale Orders from your Customers',
+		'display_name': 'Sales Order',
+		'doc_name': 'Sales Order',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'status\ntransaction_date\ncustomer\ncost_center\ngrand_total\nper_delivered\nper_billed\ncompany',
+		'hide': None,
+		'icon': None,
+		'idx': 5,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00071',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2010-11-30 17:31:24',
+		'description': None,
+		'display_name': 'Sales Dashboard',
+		'doc_name': 'Sales Dashboard',
+		'doc_type': 'Pages',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 6,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00072',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': None,
+		'doc_name': 'Reports',
+		'doc_type': 'Separator',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 7,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00309',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Territory, Item Group wise GP',
+		'doc_name': 'Delivery Note',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 9,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00311',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Itemwise Delivery Details',
+		'doc_name': 'Delivery Note Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 11,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00313',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Personwise Transaction Summary',
+		'doc_name': 'Sales Person',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 12,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00314',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Persons Target Variance (Item Group wise)',
+		'doc_name': 'Target Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 14,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00316',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Territories Target Variance (Item Group wise)',
+		'doc_name': 'Target Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 15,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00315',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Territories Target Variance (Item Group wise)',
+		'doc_name': 'Target Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 15,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00317',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Order Pending Items',
+		'doc_name': 'Sales Order Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 16,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00318',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Orderwise Booking & Delivery Summary',
+		'doc_name': 'Sales Order Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 17,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00319',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Orderwise Pending Qty To Deliver',
+		'doc_name': 'Sales Order Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 18,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00320',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Orderwise Pending Packing Item Summary',
+		'doc_name': 'Delivery Note Packing Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 19,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00321',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Orderwise Pending Amount To Bill',
+		'doc_name': 'Sales Order Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 20,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00312',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Sales Orderwise Pending Amount To Bill',
+		'doc_name': 'Sales Order Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 20,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00322',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Delivered Items to be Install',
+		'doc_name': 'Delivery Note Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 21,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00310',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Delivered Items to be Install',
+		'doc_name': 'Delivery Note Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 21,
+		'modified': '2011-03-01 13:53:34',
+		'modified_by': 'Administrator',
+		'name': 'MDI00323',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Itemwise Price List',
+		'doc_name': 'Ref Rate Detail',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 22,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00324',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': None,
+		'display_name': 'Follow-up Report',
+		'doc_name': 'Follow up',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 23,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00325',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': 'Ledger details of your debtors',
+		'display_name': "Debtor's Ledger",
+		'doc_name': 'GL Entry',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 24,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00326',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': 'Customer Category',
+		'display_name': 'Customer Group',
+		'doc_name': 'Customer Group',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'id\ndescription',
+		'hide': None,
+		'icon': None,
+		'idx': 25,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00327',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': 'Sales person details',
+		'display_name': 'Sales Person',
+		'doc_name': 'Sales Person',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'id\nterritory\ndepartment\nmobile_no\nemail_id',
+		'hide': None,
+		'icon': None,
+		'idx': 26,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00328',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': 'Item master',
+		'display_name': 'Item',
+		'doc_name': 'Item',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'name\nitem_group\ndescription',
+		'hide': None,
+		'icon': None,
+		'idx': 27,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00329',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': 'Sales partner details',
+		'display_name': 'Sales Partner',
+		'doc_name': 'Sales Partner',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'id\npartner_type\nmobile\nemail\nterritory',
+		'hide': None,
+		'icon': None,
+		'idx': 28,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00330',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-03-01 13:53:34',
+		'description': 'Business campaigns',
+		'display_name': 'Campaign',
+		'doc_name': 'Campaign',
+		'doc_type': 'Setup Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'id\ncampaign_name\ndescription',
+		'hide': None,
+		'icon': None,
+		'idx': 29,
+		'modified': '2011-03-24 15:04:46',
+		'modified_by': 'Administrator',
+		'name': 'MDI00331',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'creation': '2010-11-30 17:31:24',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 1,
+		'modified': '2010-11-30 17:31:24',
+		'modified_by': 'Administrator',
+		'name': 'MDR00008',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Administrator'
+	},
+	{
+		'creation': '2010-11-30 17:31:24',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 2,
+		'modified': '2010-11-30 17:31:24',
+		'modified_by': 'Administrator',
+		'name': 'MDR00009',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Sales Manager'
+	},
+	{
+		'creation': '2010-11-30 17:31:24',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 3,
+		'modified': '2010-11-30 17:31:24',
+		'modified_by': 'Administrator',
+		'name': 'MDR00010',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Sales User'
+	},
+	{
+		'creation': '2010-11-30 17:31:24',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 4,
+		'modified': '2010-11-30 17:31:24',
+		'modified_by': 'Administrator',
+		'name': 'MDR00011',
+		'owner': 'Administrator',
+		'parent': 'CRM',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Sales Master Manager'
+	}
+]
\ No newline at end of file
diff --git a/crm/__init__.py b/crm/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/__init__.py
diff --git a/crm/doctype/__init__.py b/crm/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/__init__.py
diff --git a/crm/doctype/campaign/__init__.py b/crm/doctype/campaign/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/campaign/__init__.py
diff --git a/crm/doctype/campaign/campaign.js b/crm/doctype/campaign/campaign.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/crm/doctype/campaign/campaign.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/crm/doctype/campaign/campaign.txt b/crm/doctype/campaign/campaign.txt
new file mode 100644
index 0000000..7d2817d
--- /dev/null
+++ b/crm/doctype/campaign/campaign.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-11-24 14:43:37', 'search_fields': None, 'module': 'CRM', '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': 7, '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:campaign_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Campaign', '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': 0, 'amend': 0, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00944', 'parent': 'Campaign', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:09:28', 'modified': '2010-09-20 09:04:15', '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': 'PERM00945', 'parent': 'Campaign', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:09:28', 'modified': '2010-09-20 09:04:15', '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': 'PERM00957', 'parent': 'Campaign', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:11:41', 'modified': '2010-09-20 09:04:15', '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': 'PERM00977', 'parent': 'Campaign', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:14:01', 'modified': '2010-09-20 09:04:15', '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': 'PERM00978', 'parent': 'Campaign', 'read': 1, 'create': 0, 'creation': '2010-04-26 17:14:01', 'modified': '2010-09-20 09:04:15', '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': 'PERM00522', 'parent': 'Campaign', 'read': 1, 'create': 1, 'creation': '2009-11-24 14:43:37', 'modified': '2010-09-20 09:04:15', '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-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': 'Campaign', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04830', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:04:15', 'parenttype': 'DocType', 'fieldname': 'trash_reason', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Section Break', 'creation': '2009-11-24 14:43:37', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Campaign', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Campaign', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03402', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 09:04:15', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-24 14:43:37', 'doctype': 'DocField', 'oldfieldname': 'campaign_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Campaign Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Campaign', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03403', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 09:04:15', 'parenttype': 'DocType', 'fieldname': 'campaign_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-11-24 14:43:37', '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': 'Campaign', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03404', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-09-20 09:04:15', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/customer/__init__.py b/crm/doctype/customer/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/customer/__init__.py
diff --git a/crm/doctype/customer/customer.js b/crm/doctype/customer/customer.js
new file mode 100644
index 0000000..23d007b
--- /dev/null
+++ b/crm/doctype/customer/customer.js
@@ -0,0 +1,211 @@
+$import(Contact Control)
+
+/* ********************************* onload ********************************************* */
+
+cur_frm.cscript.onload = function(doc,dt,dn){
+	// history doctypes and scripts
+	cur_frm.history_dict = {
+		'Quotation' : 'cur_frm.cscript.make_qtn_list(this.body, this.doc)',
+		'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 address, contact, shipping, history list body
+	cur_frm.cscript.make_hl_body();
+  	//cur_frm.cscript.make_sl_body();  	
+}
+
+cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
+cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
+
+/* ********************************* refresh ********************************************* */
+
+cur_frm.cscript.refresh = function(doc,dt,dn) {
+	if(sys_defaults.cust_master_name == 'Customer Name')
+		hide_field('naming_series');
+	else
+		unhide_field('naming_series');
+
+	if(doc.__islocal){		
+		hide_field(['Address HTML','Contact HTML']);
+		//cur_frm.cscript.set_hl_msg(doc);
+ 		//cur_frm.cscript.set_sl_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_shipping_address(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.customer = cur_frm.doc.name;
+				ndoc.customer_name = cur_frm.doc.customer_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 customer='"+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 ? data.address_line1 + '<br />' : '') + 
+					(data.address_line2 ? data.address_line2 + '<br />' : '') + 
+					(data.city ? data.city + '<br />' : '') + 
+					(data.state ? data.state + ', ' : '') + 
+					(data.country ? data.country  + '<br />' : '') + 
+					(data.pincode ? 'Pincode: ' + data.pincode + '<br />' : '') + 
+					(data.phone ? 'Phone: ' + 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.customer = cur_frm.doc.name;
+				ndoc.customer_name = cur_frm.doc.customer_name;
+				if(cur_frm.doc.customer_type == 'Individual') {
+					ndoc.first_name = cur_frm.doc.customer_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 customer='"+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();
+
+}
+
+/* ********************************* client triggers ************************************** */
+
+// ---------------
+// customer group
+// ---------------
+cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
+	return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY	`tabCustomer Group`.`name` ASC LIMIT 50';
+}
+
+cur_frm.cscript.CGHelp = function(doc,dt,dn){
+	var call_back = function(){
+		var sb_obj = new SalesBrowser();				
+		sb_obj.set_val('Customer Group');
+	}
+	loadpage('Sales Browser',call_back);
+}
+
+// -----
+// lead
+// -----
+cur_frm.fields_dict['lead_name'].get_query = function(doc,dt,dn){
+	return 'SELECT `tabLead`.`name` FROM `tabLead` WHERE `tabLead`.`status`!="Converted" AND `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';	
+}
+
+/* ********************************* transaction history ************************************** */
+
+// --------------------
+// make quotation list
+// --------------------
+cur_frm.cscript.make_qtn_list = function(parent,doc){
+
+	var lst = new Listing();
+	lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
+	lst.colnames = ['Sr.','Id','Status','Quotation Date','Contact Person','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Data','Currency'];
+	lst.coloptions = ['','Quotation','','','',''];
+
+	var q = repl("select name,status,transaction_date, contact_person, grand_total from tabQuotation where customer='%(cust)s' order by transaction_date desc", {'cust':doc.name});
+	var q_max = repl("select count(name) from tabQuotation where customer='%(cust)s'", {'cust':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Quotation','Quotation');
+}
+
+// -------------
+// make so list
+// -------------
+cur_frm.cscript.make_so_list = function(parent,doc){
+	var lst = new Listing();
+	lst.colwidths = ['5%','20%','20%','30%','25%'];
+	lst.colnames = ['Sr.','Id','Status','Sales Order Date','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Currency'];
+	lst.coloptions = ['','Sales Order','','',''];
+
+	var q = repl("select name,status,transaction_date, grand_total from `tabSales Order` where customer='%(cust)s' order by transaction_date desc", {'cust':doc.name});
+	var q_max = repl("select count(name) from `tabSales Order` where customer='%(cust)s'", {'cust':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Sales Order','Sales Order');
+}
+
+// -------------
+// make dn list
+// -------------
+cur_frm.cscript.make_dn_list = function(parent,doc){
+	var lst = new Listing();
+	lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
+	lst.colnames = ['Sr.','Id','Status','Delivery Note Date','Territory','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Link','Currency'];
+	lst.coloptions = ['','Delivery Note','','','Territory',''];
+
+	var q = repl("select name,status,transaction_date,territory,grand_total from `tabDelivery Note` where customer='%(cust)s' order by transaction_date desc", {'cust':doc.name});
+	var q_max = repl("select count(name) from `tabDelivery Note` where customer='%(cust)s'", {'cust':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Delivery Note','Delivery Note');
+}
+
+// -------------
+// make si list
+// -------------
+cur_frm.cscript.make_si_list = function(parent,doc){
+	var lst = new Listing();
+	lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
+	lst.colnames = ['Sr.','Id','Posting Date','Due Date','Debit To','Grand Total'];
+	lst.coltypes = ['Data','Link','Data','Data','Link','Currency'];
+	lst.coloptions = ['','Receivable Voucher','','','Account',''];
+
+
+	var q = repl("select name,posting_date,due_date,debit_to,grand_total from `tabReceivable Voucher` where customer='%(cust)s' order by posting_date desc", {'cust':doc.name});
+	var q_max = repl("select count(name) from `tabReceivable Voucher` where customer='%(cust)s'", {'cust':doc.name});
+	
+	cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Sales Invoice','Receivable Voucher');
+}
diff --git a/crm/doctype/customer/customer.py b/crm/doctype/customer/customer.py
new file mode 100644
index 0000000..d480a6c
--- /dev/null
+++ b/crm/doctype/customer/customer.py
@@ -0,0 +1,220 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import cstr, date_diff, flt, formatdate, get_defaults, getdate, has_common, now, nowdate, replace_newlines, sendmail, set_default, user_format, validate_email_add
+from webnotes.model.doc import Document, make_autoname
+from webnotes.model.code import get_obj
+from webnotes import msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+
+# ******************************************************* autoname ***********************************************************
+  def autoname(self):
+    cust_master_name = get_defaults().get('cust_master_name')
+    if cust_master_name == 'Customer Name':
+   
+      # filter out bad characters in name
+      cust = self.doc.customer_name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
+
+      supp = sql("select name from `tabSupplier` where name = %s", (cust))
+      supp = supp and supp[0][0] or ''
+      if supp:
+        msgprint("You already have a Supplier with same name")
+        raise Exception
+      else:
+        self.doc.name = cust
+        
+    else:
+      self.doc.name = make_autoname(self.doc.naming_series+'.#####')       
+
+
+# ******************************************************* triggers ***********************************************************
+  # ----------------
+  # get company abbr
+  # -----------------
+  def get_company_abbr(self):
+    return get_value('Company', self.doc.company, 'abbr')
+
+  # -----------------------------------------------------------------------------------------------------
+  # get parent account(i.e receivables group from company where default account head need to be created)
+  # -----------------------------------------------------------------------------------------------------
+  def get_receivables_group(self):
+    g = sql("select receivables_group from tabCompany where name=%s", self.doc.company)
+    g = g and g[0][0] or '' 
+    if not g:
+      msgprint("Update Company master, assign a default group for Receivables")
+      raise Exception
+    return g
+  
+# ******************************************************* validate *********************************************************
+  # ----------------
+  # validate values
+  # ----------------
+  def validate_values(self):
+    # Master name by naming series -> Series field mandatory
+    if get_defaults().get('cust_master_name') == 'Naming Series' and not self.doc.naming_series:
+      msgprint("Series is Mandatory.")
+      raise Exception
+
+  # ---------
+  # validate
+  # ---------
+  def validate(self):
+    self.validate_values()
+
+# ******************************************************* on update *********************************************************
+  # ------------------------
+  # create customer address
+  # ------------------------
+  def create_customer_address(self):
+    addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
+    address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
+
+    if self.doc.phone_1:
+      address_line = address_line + "\n" + "Phone: " + cstr(self.doc.phone_1)
+    if self.doc.email_id:
+      address_line = address_line + "\n" + "E-mail: " + cstr(self.doc.email_id)
+    set(self.doc,'address', address_line)
+    
+    telephone = "(O): " + cstr(self.doc.phone_1) +"\n"+ cstr(self.doc.phone_2) + "\n" + "(M): " +  "\n" + "(fax): " + cstr(self.doc.fax_1)
+    set(self.doc,'telephone',telephone)
+
+
+  # ------------------------------------
+  # create primary contact for customer
+  # ------------------------------------
+  def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr):
+    c1 = Document('Contact')
+    c1.first_name = nm
+    c1.contact_name = nm
+    c1.contact_no = phn_no
+    c1.email_id = email_id
+    c1.mobile_no = mob_no
+    c1.fax = fax
+    c1.contact_address = cont_addr
+    c1.is_primary_contact = 'Yes'
+    c1.is_customer =1
+    c1.customer = self.doc.name
+    c1.customer_name = self.doc.customer_name
+    c1.customer_address = self.doc.address
+    c1.customer_group = self.doc.customer_group
+    c1.save(1)
+
+
+  # ------------------------
+  # create customer contact
+  # ------------------------
+  def create_customer_contact(self):
+    contact = sql("select distinct name from `tabContact` where customer_name=%s", (self.doc.customer_name))
+    contact = contact and contact[0][0] or ''
+    if not contact:
+      # create primary contact for individual customer 
+      if self.doc.customer_type == 'Individual':
+        self.create_p_contact(self.doc.customer_name,self.doc.phone_1,self.doc.email_id,'',self.doc.fax_1,self.doc.address)
+    
+      # create primary contact for lead
+      elif self.doc.lead_name:
+        c_detail = sql("select lead_name, company_name, contact_no, mobile_no, email_id, fax, address from `tabLead` where name =%s", self.doc.lead_name, as_dict=1)
+        self.create_p_contact(c_detail and c_detail[0]['lead_name'] or '', c_detail and c_detail[0]['contact_no'] or '', c_detail and c_detail[0]['email_id'] or '', c_detail and c_detail[0]['mobile_no'] or '', c_detail and c_detail[0]['fax'] or '', c_detail and c_detail[0]['address'] or '')
+
+
+  # -------------------
+  # update lead status
+  # -------------------
+  def update_lead_status(self):
+    if self.doc.lead_name:
+      sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name)
+
+
+  # -------------------------------------------------------------------------
+  # create accont head - in tree under receivables_group of selected company
+  # -------------------------------------------------------------------------
+  def create_account_head(self):
+    if self.doc.company :
+      abbr = self.get_company_abbr()  
+      if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
+        parent_account = self.get_receivables_group()
+        arg = {'account_name':self.doc.name,'parent_account': parent_account, 'group_or_ledger':'Ledger', 'company':self.doc.company,'account_type':'','tax_rate':'0','master_type':'Customer','master_name':self.doc.name,'address':self.doc.address}
+        # create
+        ac = get_obj('GL Control').add_ac(cstr(arg))
+        msgprint("Account Head created for "+ac)
+    else :
+      msgprint("Please Select Company under which you want to create account head")
+
+
+  # ----------------------------------------
+  # update credit days and limit in account
+  # ----------------------------------------
+  def update_credit_days_limit(self):
+    sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.credit_limit, self.doc.name + " - " + self.get_company_abbr()))
+
+
+  #create address and contact from lead
+  def create_lead_address_contact(self):
+    if self.doc.lead_name:
+      details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, contact_no, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)      
+      d = Document('Address') 
+      d.address_line1 = details[0]['address_line1'] 
+      d.address_line2 = details[0]['address_line2']  
+      d.city = details[0]['city']  
+      d.country = details[0]['country']  
+      d.pincode = details[0]['pincode']
+      d.state = details[0]['state']  
+      d.fax = details[0]['fax']  
+      d.email_id = details[0]['email_id']  		
+      d.phone = details[0]['contact_no']  
+      d.customer = self.doc.name
+      d.customer_name = self.doc.customer_name
+      d.is_primary_address = 1
+      d.address_type = 'Office'
+      try:
+        d.save(1)
+      except NameError, e:
+        pass
+        
+      c = Document('Contact') 
+      c.first_name = details[0]['lead_name'] 
+      c.email_id = details[0]['email_id']
+      c.phone = details[0]['contact_no']
+      c.phone = details[0]['contact_no']  
+      c.customer = self.doc.name
+      c.customer_name = self.doc.customer_name
+      c.is_primary_contact = 1
+      try:
+        c.save(1)
+      except NameError, e:
+        pass  
+
+  # ----------
+  # on update
+  # ----------
+  def on_update(self):
+    # create customer addr
+    #self.create_customer_address()
+    # create customer contact
+    #self.create_customer_contact()
+    # update lead status
+    self.update_lead_status()
+    # create account head
+    self.create_account_head()
+    # update credit days and limit in account
+    self.update_credit_days_limit()
+    #create address and contact from lead    
+    self.create_lead_address_contact()
+
+  
+# ******************************************************* on trash *********************************************************
+  def on_trash(self):
+    if self.doc.lead_name:
+      sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
diff --git a/crm/doctype/customer/customer.txt b/crm/doctype/customer/customer.txt
new file mode 100644
index 0000000..fb7b120
--- /dev/null
+++ b/crm/doctype/customer/customer.txt
@@ -0,0 +1,1205 @@
+[
+	{
+		'_last_update': '1306307673',
+		'_user_tags': None,
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': 0,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': None,
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:08:56',
+		'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-05-26 17:31:31',
+		'modified_by': 'Guest',
+		'module': 'CRM',
+		'name': 'Customer',
+		'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': 'customer_name,customer_group,country,territory',
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'subject': "eval:'%(customer_name)s'=='%(name)s' ? ' ' : '%(customer_name)s'",
+		'tag_fields': 'customer_group,customer_type',
+		'use_template': None,
+		'version': 431
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:08:56',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2011-05-10 17:41:08',
+		'modified_by': 'Administrator',
+		'name': 'PERM00150',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2011-05-10 17:41:08',
+		'modified_by': 'Administrator',
+		'name': 'PERM00151',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2011-05-10 17:41:08',
+		'modified_by': 'Administrator',
+		'name': 'PERM00152',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2011-05-10 17:41:08',
+		'modified_by': 'Administrator',
+		'name': 'PERM00153',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2011-05-10 17:41:08',
+		'modified_by': 'Administrator',
+		'name': 'PERM00154',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2011-05-10 17:41:08',
+		'modified_by': 'Administrator',
+		'name': 'PERM00155',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Master Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-27 18:28:51',
+		'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-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04814',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'icon': None,
+		'idx': 2,
+		'in_filter': 1,
+		'label': 'Customer Name',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00830',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'customer_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': 0,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-09-01 15:47:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Customer Type',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL03770',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer_type',
+		'oldfieldtype': 'Select',
+		'options': '\nCompany\nIndividual',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Customer',
+		'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-04-22 11:41:50',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Series',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': '000000554',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'CUST',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'default': None,
+		'depends_on': None,
+		'description': 'Fetch lead which will be converted into customer.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead_name',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Lead Ref',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00835',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'lead_name',
+		'oldfieldtype': 'Link',
+		'options': 'Lead',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-27 18:28:51',
+		'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-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04815',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:56',
+		'default': None,
+		'depends_on': None,
+		'description': '<a href="javascript:cur_frm.cscript.CGHelp();">To manage Customer Groups, click here</a>',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_group',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 7,
+		'in_filter': 1,
+		'label': 'Customer Group',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00831',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer_group',
+		'oldfieldtype': 'Link',
+		'options': 'Customer Group',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:08:56',
+		'default': None,
+		'depends_on': None,
+		'description': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To manage Territory, click here</a>',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Territory',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00833',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'territory',
+		'oldfieldtype': 'Link',
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-27 18:28:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Address & Contacts',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04816',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': 'eval:doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Address Desc',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04817',
+		'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': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Address HTML',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04818',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04819',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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': '2011-05-27 18:28:51',
+		'default': None,
+		'depends_on': 'eval:doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Contact Desc',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04820',
+		'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': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'Contact HTML',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04821',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': None,
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Customer',
+		'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': 'White:FFF',
+		'creation': '2011-05-27 18:28:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'More Info',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04822',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:57',
+		'default': None,
+		'depends_on': None,
+		'description': 'To create an Account Head under a different company, then set the company and click the button below.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': 1,
+		'label': 'Company',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00855',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-08-08 17:08:57',
+		'default': None,
+		'depends_on': None,
+		'description': "Your Customer's TAX registration numbers (if applicable) or any general information",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_details',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': 'Customer Details',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00856',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer_details',
+		'oldfieldtype': 'Code',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-27 18:28:51',
+		'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-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04823',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-10-27 15:24:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'credit_days',
+		'fieldtype': 'Int',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Credit Days',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04075',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'credit_days',
+		'oldfieldtype': 'Int',
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Customer',
+		'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-10-27 15:24:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'credit_limit',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Credit Limit',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04076',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'credit_limit',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Customer',
+		'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-25 17:52:44',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'website',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': None,
+		'label': 'Website',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': '000000572',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Sales Team',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04824',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Customer',
+		'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-14 10:32:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_sales_partner',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 23,
+		'in_filter': None,
+		'label': 'Default Sales Partner',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04134',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'default_sales_partner',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Partner',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Customer',
+		'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-14 10:32:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'default_commission_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'Default Commission Rate',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04135',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'default_commission_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Customer',
+		'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-14 10:32:55',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'sales_team',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': 'Sales Team Details',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04136',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'sales_team',
+		'oldfieldtype': 'Table',
+		'options': 'Sales Team',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 26,
+		'in_filter': None,
+		'label': 'Transaction History',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04825',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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-27 18:28:51',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': None,
+		'label': 'History HTML',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL04826',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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:08:56',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 28,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-05-27 18:28:51',
+		'modified_by': 'Guest',
+		'name': 'FL00827',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Customer',
+		'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/crm/doctype/enquiry/__init__.py b/crm/doctype/enquiry/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/enquiry/__init__.py
diff --git a/crm/doctype/enquiry/enquiry.comp.js b/crm/doctype/enquiry/enquiry.comp.js
new file mode 100644
index 0000000..fc4baa4
--- /dev/null
+++ b/crm/doctype/enquiry/enquiry.comp.js
@@ -0,0 +1,38 @@
+
+$import(SMS Control)
+cur_frm.cscript.refresh=function(doc,cdt,cdn){if(!doc.docstatus){hide_field(['Update Follow up']);hide_field(['email_id1','cc_to','subject','message','Attachment Html','Create New File','enquiry_attachment_detail','Send Email']);}
+else{unhide_field(['Update Follow up']);unhide_field(['email_id1','cc_to','subject','message','Attachment Html','Create New File','enquiry_attachment_detail','Send Email']);}
+cur_frm.clear_custom_buttons();if(doc.docstatus==1){cur_frm.add_custom_button('Create Quotation',cur_frm.cscript['Create Quotation']);cur_frm.add_custom_button('Enquiry Lost',cur_frm.cscript['Declare Enquiry Lost']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}}
+cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.enquiry_from)hide_field(['customer','customer_address','contact_person','customer_name','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);if(!doc.status)set_multiple(cdt,cdn,{status:'Draft'});if(!doc.date)doc.transaction_date=date.obj_to_str(new Date());if(!doc.company&&sys_defaults.company)set_multiple(cdt,cdn,{company:sys_defaults.company});if(!doc.fiscal_year&&sys_defaults.fiscal_year)set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});if(doc.enquiry_from){if(doc.enquiry_from=='Customer'){hide_field(['lead','lead_name']);}
+else if(doc.enquiry_from=='Lead'){hide_field(['customer','customer_address','contact_person','customer_name','contact_display','customer_group']);}}
+if(doc.enquiry_from=='Lead'&&doc.lead){cur_frm.cscript.lead(doc,cdt,cdn);}
+cur_frm.cscript.set_fetch();}
+cur_frm.cscript.set_fetch=function(){cur_frm.add_fetch('item_code','item_name','item_name');cur_frm.add_fetch('item_code','stock_uom','uom');cur_frm.add_fetch('item_code','description','description');cur_frm.add_fetch('item_code','item_group','item_group');cur_frm.add_fetch('item_code','brand','brand');}
+cur_frm.cscript.enquiry_from=function(doc,cdt,cdn){cur_frm.cscript.lead_cust_show(doc,cdt,cdn);}
+cur_frm.cscript.lead_cust_show=function(doc,cdt,cdn){if(doc.enquiry_from=='Lead'){unhide_field(['lead']);hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}
+else if(doc.enquiry_from=='Customer'){unhide_field(['customer']);hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}}
+cur_frm.cscript.customer=function(doc,dt,dn){if(doc.customer)get_server_fields('get_default_customer_address',JSON.stringify({customer:doc.customer}),'',doc,dt,dn,1);if(doc.customer)unhide_field(['customer_name','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);}
+cur_frm.cscript.customer_address=cur_frm.cscript.contact_person=function(doc,dt,dn){if(doc.customer)get_server_fields('get_customer_address',JSON.stringify({customer:doc.customer,address:doc.customer_address,contact:doc.contact_person}),'',doc,dt,dn,1);}
+cur_frm.fields_dict.customer_address.on_new=function(dn){locals['Address'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Address'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
+cur_frm.fields_dict.contact_person.on_new=function(dn){locals['Contact'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Contact'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
+cur_frm.fields_dict['customer_address'].get_query=function(doc,cdt,cdn){return'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
+cur_frm.fields_dict['contact_person'].get_query=function(doc,cdt,cdn){return'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
+cur_frm.fields_dict['lead'].get_query=function(doc,cdt,cdn){return'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s"  ORDER BY  `tabLead`.`name` ASC LIMIT 50';}
+cur_frm.cscript.lead=function(doc,cdt,cdn){if(doc.lead)get_server_fields('get_lead_details',doc.lead,'',doc,cdt,cdn,1);if(doc.lead)unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);}
+cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query=function(doc,cdt,cdn){if(doc.enquiry_type=='Maintenance')
+return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';else
+return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';}
+cur_frm.cscript.item_code=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.item_code){get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);}}
+cur_frm.cscript['Create New File']=function(doc){var fl=LocalDB.create('File');fl=locals['File'][fl];loaddoc('File',fl.name);}
+cur_frm.cscript['Update Follow up']=function(doc,cdt,cdn){$c_obj(make_doclist(doc.doctype,doc.name),'update_follow_up','',function(r,rt){refresh_field('follow_up');doc.__unsaved=0;cur_frm.refresh_header();});}
+cur_frm.cscript['Create Quotation']=function(){n=createLocal("Quotation");$c('dt_map',args={'docs':compress_doclist([locals["Quotation"][n]]),'from_doctype':'Enquiry','to_doctype':'Quotation','from_docname':cur_frm.docname,'from_to_list':"[['Enquiry', 'Quotation'],['Enquiry Detail','Quotation Detail']]"},function(r,rt){loaddoc("Quotation",n);});}
+cur_frm.cscript['Declare Enquiry Lost']=function(){var e_lost_dialog;set_e_lost_dialog=function(){e_lost_dialog=new Dialog(400,150,'Add Enquiry Lost Reason');e_lost_dialog.make_body([['HTML','Message','<div class="comment">Please add enquiry lost reason</div>'],['Text','Enquiry Lost Reason'],['HTML','Response','<div class = "comment" id="update_enquiry_dialog_response"></div>'],['HTML','Add Reason','<div></div>']]);var add_reason_btn1=$a($i(e_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn1.innerHTML='Add';add_reason_btn1.onclick=function(){e_lost_dialog.add();}
+var add_reason_btn2=$a($i(e_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn2.innerHTML='Cancel';$y(add_reason_btn2,{marginLeft:'4px'});add_reason_btn2.onclick=function(){e_lost_dialog.hide();}
+e_lost_dialog.onshow=function(){e_lost_dialog.widgets['Enquiry Lost Reason'].value='';$i('update_enquiry_dialog_response').innerHTML='';}
+e_lost_dialog.add=function(){$i('update_enquiry_dialog_response').innerHTML='Processing...';var arg=strip(e_lost_dialog.widgets['Enquiry Lost Reason'].value);var call_back=function(r,rt){if(r.message=='true'){$i('update_enquiry_dialog_response').innerHTML='Done';e_lost_dialog.hide();}}
+if(arg){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);}
+else{msgprint("Please add enquiry lost reason");}}}
+if(!e_lost_dialog){set_e_lost_dialog();}
+e_lost_dialog.show();}
+cur_frm.fields_dict['territory'].get_query=function(doc,cdt,cdn){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';}
+cur_frm.cscript.validate=function(doc,cdt,cdn){}
\ No newline at end of file
diff --git a/crm/doctype/enquiry/enquiry.js b/crm/doctype/enquiry/enquiry.js
new file mode 100644
index 0000000..a8c8ea2
--- /dev/null
+++ b/crm/doctype/enquiry/enquiry.js
@@ -0,0 +1,334 @@
+$import(SMS Control)
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn){
+
+  //cur_frm.cscript.get_tips(doc, cdt, cdn);
+
+  if(!doc.docstatus){
+    hide_field(['Update Follow up']);
+    hide_field(['email_id1','cc_to','subject','message','Attachment Html', 'Create New File', 'enquiry_attachment_detail','Send Email']);
+  }
+  else{
+    unhide_field(['Update Follow up']);
+    unhide_field(['email_id1','cc_to','subject','message','Attachment Html', 'Create New File', 'enquiry_attachment_detail','Send Email']);
+  }
+
+  
+  cur_frm.clear_custom_buttons();
+  if(doc.docstatus == 1) {
+    cur_frm.add_custom_button('Create Quotation', cur_frm.cscript['Create Quotation']);
+    cur_frm.add_custom_button('Enquiry Lost', cur_frm.cscript['Declare Enquiry Lost']);
+    cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+  }
+
+  //cur_frm.cscript.clear_values(doc,cdt,cdn);
+}
+
+// ONLOAD
+// ===============================================================
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+
+  if(!doc.enquiry_from) hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'lead_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
+  if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
+  if(!doc.date) doc.transaction_date = date.obj_to_str(new Date());
+  if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
+  if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});    
+  
+  if(doc.enquiry_from) {
+    if(doc.enquiry_from == 'Customer') {
+      hide_field(['lead', 'lead_name']);
+    }
+    else if (doc.enquiry_from == 'Lead') {
+      hide_field(['customer', 'customer_address', 'contact_person', 'customer_name', 'contact_display', 'customer_group']);
+    }
+  } 
+  
+  if(doc.enquiry_from == 'Lead' && doc.lead) {
+    cur_frm.cscript.lead(doc,cdt,cdn);
+  } 
+
+  // setup fetch
+  cur_frm.cscript.set_fetch();
+}
+
+
+// fetch
+// ===============================================================
+cur_frm.cscript.set_fetch = function() {
+
+  // item
+  cur_frm.add_fetch('item_code', 'item_name', 'item_name');
+  cur_frm.add_fetch('item_code', 'stock_uom', 'uom');
+  cur_frm.add_fetch('item_code', 'description', 'description');
+  cur_frm.add_fetch('item_code', 'item_group', 'item_group');
+  cur_frm.add_fetch('item_code', 'brand', 'brand');
+
+  // customer
+
+}
+
+// hide - unhide fields on basis of enquiry_from lead or customer
+cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
+  cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
+}
+
+// hide - unhide fields based on lead or customer
+cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
+  if(doc.enquiry_from == 'Lead'){
+    unhide_field(['lead']);
+    hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+    doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
+  }
+  else if(doc.enquiry_from == 'Customer'){    
+    unhide_field(['customer']);
+    hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);    
+    doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
+  }
+}
+
+// customer
+cur_frm.cscript.customer = function(doc,dt,dn) {
+  if(doc.customer) get_server_fields('get_default_customer_address', JSON.stringify({customer: doc.customer}),'', doc, dt, dn, 1);
+  if(doc.customer) unhide_field(['customer_name','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+}
+
+cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {    
+  if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+}
+
+cur_frm.fields_dict.customer_address.on_new = function(dn) {
+  locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+}
+
+cur_frm.fields_dict.contact_person.on_new = function(dn) {
+  locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+}
+
+cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+// lead
+cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
+  return 'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s"  ORDER BY  `tabLead`.`name` ASC LIMIT 50';
+}
+
+cur_frm.cscript.lead = function(doc, cdt, cdn) {
+  if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
+  if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);  
+}
+
+
+//item getquery
+//=======================================
+cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
+  if (doc.enquiry_type == 'Maintenance')
+    return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
+  else 
+    return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
+}
+  
+ //Fetch Item Details
+//====================================================================================================================
+cur_frm.cscript.item_code = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if (d.item_code) {
+    get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);
+  }
+}
+
+/*
+ //Fetch Customer Details
+//======================================================================================================================
+cur_frm.cscript.customer = function(doc, cdt, cdn){
+  if (doc.customer) {
+    get_server_fields('get_cust_address',doc.customer,'',doc,cdt,cdn,1);
+  }
+}
+*/
+
+/*
+//=======================================================================================================================
+cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.customer = "'+ doc.customer+'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
+}
+*/
+
+/*
+//=======================================================================================================================
+cur_frm.cscript.contact_person = function(doc, cdt, cdn){
+  if (doc.contact_person) {
+    arg = {};
+    arg.contact_person = doc.contact_person;
+    arg.customer = doc.customer;
+    get_server_fields('get_contact_details',docstring(arg),'',doc,cdt,cdn,1);
+  }
+}
+*/
+
+/*
+// hide - unhide fields based on lead or customer..
+//=======================================================================================================================
+cur_frm.cscript.clear_values = function(doc,cdt,cdn) {
+  if(doc.enquiry_from == 'Lead') {
+    doc.customer = doc.customer_name = doc.contact_person = doc.customer_group = "";
+  }
+  else if(doc.enquiry_from == 'Customer') {
+    doc.lead =  doc.lead_name = "";
+  }
+  refresh_many(['lead','lead_name','customer','customer_name','contact_person','customer_group']);
+}
+*/
+
+/*
+//================ hide - unhide fields on basis of enquiry from either lead or customer =============================== 
+cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
+  cur_frm.cscript.clear_values(doc,cdt,cdn);
+   doc.address = doc.territory = doc.contact_no = doc.email_id = "";
+   refresh_many(['territory','address','contact_no','email_id']);
+}
+*/
+
+/*
+//================ create new contact ============================================================================
+cur_frm.cscript.new_contact = function(){
+  tn = createLocal('Contact');
+  locals['Contact'][tn].is_customer = 1;
+  if(doc.customer) locals['Contact'][tn].customer = doc.customer;
+  loaddoc('Contact', tn);
+}
+*/
+
+//=======================================================================================================================
+cur_frm.cscript['Create New File'] = function(doc){
+  var fl = LocalDB.create('File');
+  fl = locals['File'][fl];
+  loaddoc('File', fl.name);
+}
+
+//update follow up
+//=================================================================================
+cur_frm.cscript['Update Follow up'] = function(doc,cdt,cdn){
+
+  $c_obj(make_doclist(doc.doctype, doc.name),'update_follow_up','',function(r, rt){
+    refresh_field('follow_up');
+    doc.__unsaved = 0;
+    cur_frm.refresh_header();
+  });
+}
+
+ // Create New Quotation
+// =======================================================================================================================
+cur_frm.cscript['Create Quotation'] = function(){
+  n = createLocal("Quotation");
+  $c('dt_map', args={
+	  'docs':compress_doclist([locals["Quotation"][n]]),
+	  'from_doctype':'Enquiry',
+	  'to_doctype':'Quotation',
+	  'from_docname':cur_frm.docname,
+    'from_to_list':"[['Enquiry', 'Quotation'],['Enquiry Detail','Quotation Detail']]"
+  }
+  , function(r,rt) {
+    loaddoc("Quotation", n);
+    }
+  );
+}
+
+
+// declare enquiry  lost
+//-------------------------
+cur_frm.cscript['Declare Enquiry Lost'] = function(){
+  var e_lost_dialog;
+
+  set_e_lost_dialog = function(){
+    e_lost_dialog = new Dialog(400,150,'Add Enquiry Lost Reason');
+    e_lost_dialog.make_body([
+      ['HTML', 'Message', '<div class="comment">Please add enquiry lost reason</div>'],
+      ['Text', 'Enquiry Lost Reason'],
+      ['HTML', 'Response', '<div class = "comment" id="update_enquiry_dialog_response"></div>'],
+      ['HTML', 'Add Reason', '<div></div>']
+    ]);
+    
+    var add_reason_btn1 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
+    add_reason_btn1.innerHTML = 'Add';
+    add_reason_btn1.onclick = function(){ e_lost_dialog.add(); }
+    
+    var add_reason_btn2 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
+    add_reason_btn2.innerHTML = 'Cancel';
+    $y(add_reason_btn2,{marginLeft:'4px'});
+    add_reason_btn2.onclick = function(){ e_lost_dialog.hide();}
+    
+    e_lost_dialog.onshow = function() {
+      e_lost_dialog.widgets['Enquiry Lost Reason'].value = '';
+      $i('update_enquiry_dialog_response').innerHTML = '';
+    }
+    
+    e_lost_dialog.add = function() {
+      // sending...
+      $i('update_enquiry_dialog_response').innerHTML = 'Processing...';
+      var arg =  strip(e_lost_dialog.widgets['Enquiry Lost Reason'].value);
+      var call_back = function(r,rt) { 
+        if(r.message == 'true'){
+          $i('update_enquiry_dialog_response').innerHTML = 'Done';
+          e_lost_dialog.hide();
+        }
+      }
+      if(arg) {
+        $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);
+      }
+      else{
+        msgprint("Please add enquiry lost reason");
+      }
+      
+    }
+  }  
+  
+  if(!e_lost_dialog){
+    set_e_lost_dialog();
+  }  
+  e_lost_dialog.show();
+}
+
+//get query select Territory
+//=======================================================================================================================
+cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
+  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';}
+
+/*
+//===================== Enquiry From validation - either customer or lead is mandatory =====================================
+cur_frm.cscript.enq_frm_validate = function(doc,cdt,cdn){
+  
+  if(doc.enquiry_from == 'Lead'){
+    if(!doc.lead){
+      alert("Lead is mandatory.");  
+      validated = false; 
+    }
+  }
+  else if(doc.enquiry_from == 'Customer'){
+      if(!doc.customer){
+      alert("Customer is mandatory.");
+      validated = false;
+    }
+    else if(!doc.contact_person){
+      alert("Contact Person is mandatory.");
+      validated = false;
+    }
+    else if(!doc.customer_group){
+      alert("Customer Group is mandatory.");
+      validated = false;
+    }
+  } 
+}
+*/
+
+//===================validation function ==============================================================================
+
+cur_frm.cscript.validate = function(doc,cdt,cdn){
+  //cur_frm.cscript.enq_frm_validate(doc,cdt,cdn);
+}
diff --git a/crm/doctype/enquiry/enquiry.py b/crm/doctype/enquiry/enquiry.py
new file mode 100644
index 0000000..61bc4ec
--- /dev/null
+++ b/crm/doctype/enquiry/enquiry.py
@@ -0,0 +1,335 @@
+# 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
+	
+# -----------------------------------------------------------------------------------------
+
+from utilities.transaction_base import TransactionBase
+
+class DocType(TransactionBase):
+  def __init__(self,doc,doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.fname = 'enq_details'
+    self.tname = 'Enquiry Detail'
+
+  # Autoname
+  # ====================================================================================================================
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.####')
+
+  #--------Get customer address-------
+  # ====================================================================================================================
+  def get_cust_address(self,name):
+    details = sql("select customer_name, address, territory, customer_group from `tabCustomer` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
+    if details:
+      ret = {
+        'customer_name':  details and details[0]['customer_name'] or '',
+        'address'  :  details and details[0]['address'] or '',
+        'territory'       :  details and details[0]['territory'] or '',
+        'customer_group'    :  details and details[0]['customer_group'] or ''
+      }
+      # ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
+
+      contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
+
+      
+      ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
+      ret['contact_no']     = contact_det and contact_det[0]['contact_no'] or ''
+      ret['email_id']       = contact_det and contact_det[0]['email_id'] or ''
+    
+      return cstr(ret)
+    else:
+      msgprint("Customer : %s does not exist in system." % (name))
+      raise Exception
+    
+
+  # ====================================================================================================================    
+  def get_contact_details(self, arg):
+    arg = eval(arg)
+    contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1)
+    ret = {
+      'contact_no' : contact and contact[0]['contact_no'] or '',
+      'email_id' : contact and contact[0]['email_id'] or ''
+    }
+    return str(ret)   
+    
+  # ====================================================================================================================
+  def on_update(self):
+    # Add to calendar
+    #if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
+    if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
+      if self.doc.contact_by:
+        self.add_calendar_event()
+      set(self.doc, 'contact_date_ref',self.doc.contact_date)
+    set(self.doc, 'status', 'Draft')
+  
+  # Add to Calendar
+  # ====================================================================================================================
+  def add_calendar_event(self):
+    desc=''
+    user_lst =[]
+    if self.doc.customer:
+      if self.doc.contact_person:
+        desc = 'Contact '+cstr(self.doc.contact_person)
+      else:
+        desc = 'Contact customer '+cstr(self.doc.customer)
+    elif self.doc.lead:
+      if self.doc.lead_name:
+        desc = 'Contact '+cstr(self.doc.lead_name)
+      else:
+        desc = 'Contact lead '+cstr(self.doc.lead)
+    desc = desc+ '. By : ' + cstr(self.doc.contact_by)
+    
+    if self.doc.to_discuss:
+      desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
+    
+    ev = Document('Event')
+    ev.description = desc
+    ev.event_date = self.doc.contact_date
+    ev.event_hour = '10:00'
+    ev.event_type = 'Private'
+    ev.ref_type = 'Enquiry'
+    ev.ref_name = self.doc.name
+    ev.save(1)
+    
+    user_lst.append(self.doc.owner)
+    
+    chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
+    if chk:
+      user_lst.append(chk[0][0])
+    
+    for d in user_lst:
+      ch = addchild(ev, 'event_individuals', 'Event User', 0)
+      ch.person = d
+      ch.save(1)
+    
+    #user_list = ['Sales Manager', 'Sales User']
+    #for d in user_list:
+    #  ch = addchild(ev, 'event_individuals', 'Event User', 0)
+    #  ch.person = d
+    #  ch.save()
+
+  #--------------Validation For Last Contact Date-----------------
+  # ====================================================================================================================
+  def set_last_contact_date(self):
+    #if not self.doc.contact_date_ref:
+      #self.doc.contact_date_ref=self.doc.contact_date
+      #self.doc.last_contact_date=self.doc.contact_date_ref
+    if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
+      if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
+        self.doc.last_contact_date=self.doc.contact_date_ref
+      else:
+        msgprint("Contact Date Cannot be before Last Contact Date")
+        raise Exception
+      #set(self.doc, 'contact_date_ref',self.doc.contact_date)
+  
+  # check if item present in item table
+  # ====================================================================================================================
+  def validate_item_details(self):
+    if not getlist(self.doclist, 'enquiry_details'):
+      msgprint("Please select items for which enquiry needs to be made")
+      raise Exception
+  
+  #check if enquiry date in the range of fiscal year selected
+  #=====================================================
+  def validate_fiscal_year(self):
+    fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
+    ysd=fy and fy[0][0] or ""
+    yed=add_days(str(ysd),365)
+    if str(self.doc.transaction_date) < str(ysd) or str(self.doc.transaction_date) > str(yed):
+      msgprint("Enquiry Date is not within the Fiscal Year selected")
+      raise Exception    
+  
+  def validate(self):
+    self.validate_fiscal_year()
+    self.set_last_contact_date()
+    self.validate_item_details()
+    
+  # On Submit Functions
+  # ====================================================================================================================
+  def on_submit(self):
+    set(self.doc, 'status', 'Submitted')
+    
+  # ====================================================================================================================  
+  def on_cancel(self):
+    chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
+    if chk:
+      msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus can not be cancelled.")
+      raise Exception
+    else:
+      set(self.doc, 'status', 'Cancelled')
+
+    get_obj('Feed Control').make_feed(self.doc, 'cancelled')
+    
+  # declare as enquiry lost
+  #---------------------------
+  def declare_enquiry_lost(self,arg):
+    chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
+    if chk:
+      msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus 'Enquiry Lost' can not be declared against it.")
+      raise Exception
+    else:
+      set(self.doc, 'status', 'Enquiry Lost')
+      set(self.doc, 'order_lost_reason', arg)
+      return cstr('true')
+    
+  # ====================================================================================================================  
+  def update_follow_up(self):
+    
+    sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name);
+    for d in getlist(self.doclist, 'follow_up'):    
+      d.save()
+    self.doc.save()
+    
+    
+  # On Send Email
+  # ====================================================================================================================
+  #def send_emails(self,email,sender,subject,message):
+  #  if email:
+  #    sendmail(email,sender,subject=subject or 'Enquiry',parts=[['text/plain',message or self.get_enq_summary()]])
+
+  # Prepare HTML Table and Enter Enquiry Details in it, which will be added in enq summary
+  # ====================================================================================================================
+  def quote_table(self):
+    if getlist(self.doclist,'enq_details'):
+      header_lbl = ['Item Code','Item Name','Description','Reqd Qty','UOM']
+      item_tbl = '''<table style="width:90%%; border:1px solid #AAA; border-collapse:collapse"><tr>'''
+      for i in header_lbl:
+        item_header = '''<td style="width=20%%; border:1px solid #AAA; border-collapse:collapse;"><b>%s</b></td>''' % i
+        item_tbl += item_header
+      item_tbl += '''</tr>'''
+      
+      for d in getlist(self.doclist,'enq_details'):
+        item_det = '''
+          <tr><td style="width:20%%; border:1px solid #AAA; border-collpase:collapse">%s</td>
+          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
+          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
+          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
+          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td></tr>
+        ''' % (d.item_code,d.item_name,d.description,d.reqd_qty,d.uom)
+        item_tbl += item_det
+      item_tbl += '''</table>'''
+      return item_tbl
+      
+  # Prepare HTML Page containing summary of Enquiry, which will be sent as message in E-mail
+  # ====================================================================================================================
+  def get_enq_summary(self):
+
+    t = """
+        <html><head></head>
+        <body>
+          <div style="border:1px solid #AAA; padding:20px; width:100%%">
+            <div style="text-align:center;font-size:14px"><b>Request For Quotation</b><br></div>
+            <div style="text-align:center;font-size:12px"> %(from_company)s</div>
+            <div style="text-align:center; font-size:10px"> %(company_address)s</div>
+            <div style="border-bottom:1px solid #AAA; padding:10px"></div> 
+            
+            <div style="padding-top:10px"><b>Quotation Details</b></div>
+            <div><table style="width:100%%">
+            <tr><td style="width:40%%">Enquiry No:</td> <td style="width:60%%"> %(name)s</td></tr>
+            <tr><td style="width:40%%">Opening Date:</td> <td style="width:60%%"> %(transaction_date)s</td></tr>
+            <tr><td style="width:40%%">Expected By Date:</td> <td style="width:60%%"> %(expected_date)s</td></tr>
+            </table>
+            </div>
+            
+            <div style="padding-top:10px"><b>Terms and Conditions</b></div>
+            <div> %(terms_and_conditions)s</div>
+            
+            <div style="padding-top:10px"><b>Contact Details</b></div>
+            <div><table style="width:100%%">
+            <tr><td style="width=40%%">Contact Person:</td><td style="width:60%%"> %(contact_person)s</td></tr>
+            <tr><td style="width=40%%">Contact No:</td><td style="width:60%%"> %(contact_no)s</td></tr>
+            <tr><td style="width=40%%">Email:</td><td style="width:60%%"> %(email)s</td></tr>
+            </table></div>
+            """ % (self.doc.fields)
+    
+    t += """<br><div><b>Quotation Items</b><br></div><div style="width:100%%">%s</div>
+            <br>
+To login into the system, use link : <div><a href='http://67.205.111.118/v160/login.html' target='_blank'>http://67.205.111.118/v160/login.html</a></div><br><br>
+            </div>
+          </body>
+          </html>
+          """ % (self.quote_table())
+    return t
+      
+  #-----------------Email-------------------------------------------- 
+  # ====================================================================================================================
+  def send_emails(self, email=[], subject='', message=''):
+    if email:
+      sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user'])
+      if sender_email and sender_email[0][0]:
+        attach_list=[]
+        for at in getlist(self.doclist,'enquiry_attachment_detail'):
+          if at.select_file:
+            attach_list.append(at.select_file)
+        cc_list=[]
+        if self.doc.cc_to:
+          for cl in (self.doc.cc_to.split(',')):
+            if not validate_email_add(cl.strip(' ')):
+              msgprint('error:%s is not a valid email id' % cl.strip(' '))
+              raise Exception
+            cc_list.append(cl.strip(' ')) 
+            sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list)           
+        sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list)
+        #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
+        msgprint("Mail has been sent")
+        self.add_in_follow_up(message,'Email')
+      else:
+        msgprint("Please enter your mail id in Profile")
+        raise Exception
+  
+  #-------------------------Checking Sent Mails Details----------------------------------------------
+  # ====================================================================================================================
+  def sent_mail(self):
+    if not self.doc.subject or not self.doc.message:
+      msgprint("Please enter subject & message in their respective fields.")
+    elif not self.doc.email_id1:
+      msgprint("Recipient not specified. Please add email id in 'Send To'.")
+      raise Exception
+    else :
+      if not validate_email_add(self.doc.email_id1.strip(' ')):
+        msgprint('error:%s is not a valid email id' % self.doc.email_id1)
+      else:
+        self.send_emails([self.doc.email_id1.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
+
+  #---------------------- Add details in follow up table----------------
+  # ====================================================================================================================
+  def add_in_follow_up(self,message,type):
+    import datetime
+    child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
+    child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
+    child.notes = message
+    child.follow_up_type = type
+    child.save()
+
+  #-------------------SMS----------------------------------------------
+  # ====================================================================================================================
+  def send_sms(self):
+    if not self.doc.sms_message:
+      msgprint("Please enter message in SMS Section ")
+      raise Exception
+    elif not getlist(self.doclist, 'enquiry_sms_detail'):
+      msgprint("Please mention mobile no. to which sms needs to be sent")
+      raise Exception
+    else:
+      receiver_list = []
+      for d in getlist(self.doclist,'enquiry_sms_detail'):
+        if d.other_mobile_no:
+          receiver_list.append(d.other_mobile_no)
+    
+    if receiver_list:
+      msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
+      self.add_in_follow_up(self.doc.sms_message,'SMS')
diff --git a/crm/doctype/enquiry/enquiry.txt b/crm/doctype/enquiry/enquiry.txt
new file mode 100644
index 0000000..26a5587
--- /dev/null
+++ b/crm/doctype/enquiry/enquiry.txt
@@ -0,0 +1,1529 @@
+[
+	{
+		'_last_update': '1305205067',
+		'_user_tags': None,
+		'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': '2010-08-08 17:09:00',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Transaction',
+		'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-05-12 18:27:46',
+		'modified_by': 'Guest',
+		'module': 'CRM',
+		'name': 'Enquiry',
+		'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': 'status,transaction_date,customer,lead,enquiry_type,territory,company',
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'subject': 'To %(customer_name)s%(lead_name)s on %(transaction_date)s',
+		'tag_fields': None,
+		'use_template': None,
+		'version': 586
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:00',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2010-09-29 11:08:48',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00219',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:00',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-09-29 11:08:48',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00220',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:00',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-09-29 11:08:48',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00221',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:00',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-09-29 11:08:48',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00222',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:00',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2010-09-29 11:08:48',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00223',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:00',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2010-09-29 11:08:48',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00224',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:44:45',
+		'default': None,
+		'depends_on': None,
+		'description': 'Enter customer enquiry for which you might raise a quotation in future',
+		'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:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05166',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:00',
+		'default': 'ENQ',
+		'depends_on': None,
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Series',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01222',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'ENQUIRY\nENQ',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:09:00',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'enquiry_from',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Enquiry From',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01224',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'enquiry_from',
+		'oldfieldtype': 'Select',
+		'options': '\nLead\nCustomer',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:00',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Customer',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01225',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:44',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Customer Address',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL05158',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Address',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:00',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_person',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'icon': None,
+		'idx': 6,
+		'in_filter': 1,
+		'label': 'Contact Person',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01229',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-09-01 15:48:02',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Customer Name',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL03786',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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:00',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Lead',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01226',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'lead',
+		'oldfieldtype': 'Link',
+		'options': 'Lead',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Enquiry',
+		'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:09:00',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead_name',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Name',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01227',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'lead_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Enquiry',
+		'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:44:44',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Small Text',
+		'hidden': 0,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Address',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL05159',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'address',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:44:44',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_display',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Contact',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL05160',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:44:44',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_mobile',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': None,
+		'label': 'Contact Mobile No',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL05161',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:44:44',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_email',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Contact Email',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL05162',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:44:45',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05167',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'sneha@webnotestech.com',
+		'parent': 'Enquiry',
+		'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:01',
+		'default': 'Today',
+		'depends_on': None,
+		'description': 'The date at which current entry is made in system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Enquiry Date',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01232',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': '50px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'enquiry_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Enquiry Type',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01233',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'enquiry_type',
+		'oldfieldtype': 'Select',
+		'options': 'Sales\nMaintenance',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:00',
+		'default': 'Draft',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': 'Status',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01223',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nDraft\nSubmitted\nQuotation Sent\nOrder Confirmed\nEnquiry Lost\nCancelled',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': 'Amended From',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01234',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Amendment Date',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01235',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To Manage Territory, click here</a>',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 20,
+		'in_filter': 1,
+		'label': 'Territory',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01230',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': None,
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': 'eval:doc.enquiry_from=="Customer"',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_group',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 21,
+		'in_filter': 0,
+		'label': 'Customer Group',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01245',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'customer_group',
+		'oldfieldtype': 'Link',
+		'options': 'Customer Group',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': 0,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:44:45',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Items',
+		'modified': '2011-05-25 12:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05168',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:01',
+		'default': None,
+		'depends_on': None,
+		'description': "Items which do not exist in Item master can also be entered on customer's request",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'enquiry_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 23,
+		'in_filter': None,
+		'label': 'Enquiry Details',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01237',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'enquiry_details',
+		'oldfieldtype': 'Table',
+		'options': 'Enquiry Detail',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:45',
+		'default': None,
+		'depends_on': None,
+		'description': 'Filing in Additional Information about the Enquiry will help you analyze your data better.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'More Info',
+		'modified': '2011-05-25 12:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05169',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:45',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05170',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 26,
+		'in_filter': 1,
+		'label': 'Company',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01242',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01243',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'source',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 28,
+		'in_filter': None,
+		'label': 'Source',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01240',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'source',
+		'oldfieldtype': 'Select',
+		'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWalk In",
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:01',
+		'default': None,
+		'depends_on': None,
+		'description': 'Enter name of campaign if source of enquiry is campaign',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'campaign',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 29,
+		'in_filter': None,
+		'label': 'Campaign',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01241',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'campaign',
+		'oldfieldtype': 'Link',
+		'options': 'Campaign',
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:01',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'order_lost_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 30,
+		'in_filter': None,
+		'label': 'Order Lost Reason',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01248',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'order_lost_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:45',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 31,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05171',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Enquiry',
+		'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:01',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your sales person who will contact the customer in future',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_by',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 32,
+		'in_filter': 1,
+		'label': 'Next Contact By',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01250',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_by',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Person',
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '75px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your sales person will get a reminder on this date to contact the customer',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 33,
+		'in_filter': None,
+		'label': 'Next Contact Date',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01251',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': 'Date on which the lead was last contacted',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'last_contact_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 34,
+		'in_filter': None,
+		'label': 'Last Contact Date',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01252',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'last_contact_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'to_discuss',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 35,
+		'in_filter': None,
+		'label': 'To Discuss',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01254',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'to_discuss',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'parent': 'Enquiry',
+		'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:45',
+		'default': None,
+		'depends_on': None,
+		'description': 'Keep a track of communication related to this enquiry which will help for future reference.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 36,
+		'in_filter': None,
+		'label': 'Communication History',
+		'modified': '2011-05-25 12:44:45',
+		'modified_by': 'Guest',
+		'name': 'FL05172',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'sneha@webnotestech.com',
+		'parent': 'Enquiry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:01',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'follow_up',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 37,
+		'in_filter': None,
+		'label': 'Follow Up',
+		'modified': '2011-05-25 12:44:44',
+		'modified_by': 'Guest',
+		'name': 'FL01256',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'follow_up',
+		'oldfieldtype': 'Table',
+		'options': 'Follow up',
+		'owner': 'sneha@webnotestech.com',
+		'parent': 'Enquiry',
+		'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/crm/doctype/enquiry_attachment_detail/__init__.py b/crm/doctype/enquiry_attachment_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/enquiry_attachment_detail/__init__.py
diff --git a/crm/doctype/enquiry_attachment_detail/enquiry_attachment_detail.txt b/crm/doctype/enquiry_attachment_detail/enquiry_attachment_detail.txt
new file mode 100644
index 0000000..c50339e
--- /dev/null
+++ b/crm/doctype/enquiry_attachment_detail/enquiry_attachment_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-11 11:38:27', 'search_fields': None, 'module': 'CRM', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'dhanalekshmi@webnotestech.com', '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': 3, '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': 'ashwini@webnotestech.com', 'document_type': None, 'name': 'Enquiry Attachment Detail', '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': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00530', 'parent': 'Enquiry Attachment Detail', 'read': None, 'create': None, 'creation': '2009-12-11 11:38:27', 'modified': '2010-08-08 11:11:22', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 1, 'parenttype': 'DocType', 'role': '', 'owner': 'dhanalekshmi@webnotestech.com', 'docstatus': 0, 'permlevel': None, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-12-11 11:38:27', 'doctype': 'DocField', 'oldfieldname': 'select_file', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Select File For Attachment', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Attachment Detail', 'search_index': None, 'allow_on_submit': 1, 'icon': None, 'name': 'FL03493', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 11:11:22', 'parenttype': 'DocType', 'fieldname': 'select_file', 'fieldtype': 'Link', 'options': 'File', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/enquiry_detail/__init__.py b/crm/doctype/enquiry_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/enquiry_detail/__init__.py
diff --git a/crm/doctype/enquiry_detail/enquiry_detail.txt b/crm/doctype/enquiry_detail/enquiry_detail.txt
new file mode 100644
index 0000000..01e61ed
--- /dev/null
+++ b/crm/doctype/enquiry_detail/enquiry_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-10-08 14:19:27', 'search_fields': None, 'module': 'CRM', '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': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 59, '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': 'Enquiry 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-11-24 16:20:41', 'doctype': 'DocField', 'oldfieldname': 'item_code', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Item Code', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03405', 'idx': 1, 'default': None, 'colour': 'White:FFF', 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'item_code', 'fieldtype': 'Link', 'options': 'Item', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-24 16:20:41', 'doctype': 'DocField', 'oldfieldname': 'item_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Item Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03406', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'item_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-18 14:38:27', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Description', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03527', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2010-01-06 15:43:58', 'doctype': 'DocField', 'oldfieldname': 'qty', 'owner': 'saumil@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Qty', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03546', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'qty', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-11-24 16:20:41', 'doctype': 'DocField', 'oldfieldname': 'uom', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'UOM', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03408', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'uom', 'fieldtype': 'Link', 'options': 'UOM', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-04-23 17:01:00', 'doctype': 'DocField', 'oldfieldname': 'item_group', 'owner': 'harshada@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Item Group', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04892', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'item_group', 'fieldtype': 'Link', 'options': 'Item Group', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-04-23 17:01:00', 'doctype': 'DocField', 'oldfieldname': 'brand', 'owner': 'harshada@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Brand', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04893', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'brand', 'fieldtype': 'Link', 'options': 'Brand', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2010-05-04 11:20:50', 'doctype': 'DocField', 'oldfieldname': 'basic_rate', 'owner': 'harshada@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Basic Rate', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04970', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-08-01 14:51:49', 'parenttype': 'DocType', 'fieldname': 'basic_rate', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/enquiry_sms_detail/__init__.py b/crm/doctype/enquiry_sms_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/enquiry_sms_detail/__init__.py
diff --git a/crm/doctype/enquiry_sms_detail/enquiry_sms_detail.txt b/crm/doctype/enquiry_sms_detail/enquiry_sms_detail.txt
new file mode 100644
index 0000000..84d0907
--- /dev/null
+++ b/crm/doctype/enquiry_sms_detail/enquiry_sms_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-11 11:45:55', 'search_fields': None, 'module': 'CRM', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'dhanalekshmi@webnotestech.com', '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': 5, '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': 'ashwini@webnotestech.com', 'document_type': None, 'name': 'Enquiry SMS Detail', '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': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-11 11:45:55', 'doctype': 'DocField', 'oldfieldname': 'other_mobile_no', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Mobile No', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry SMS Detail', 'search_index': None, 'allow_on_submit': 1, 'icon': None, 'name': 'FL03494', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 11:13:11', 'parenttype': 'DocType', 'fieldname': 'other_mobile_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/follow_up/__init__.py b/crm/doctype/follow_up/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/follow_up/__init__.py
diff --git a/crm/doctype/follow_up/follow_up.txt b/crm/doctype/follow_up/follow_up.txt
new file mode 100644
index 0000000..71766bb
--- /dev/null
+++ b/crm/doctype/follow_up/follow_up.txt
@@ -0,0 +1,197 @@
+[
+	{
+		'_last_update': '1303109476',
+		'_user_tags': None,
+		'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': '2010-08-08 17:09:02',
+		'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': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': 1,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-05-09 15:40:46',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'Follow up',
+		'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': 'Tray',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'use_template': None,
+		'version': 9
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-08-08 17:09:02',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Date',
+		'modified': '2011-05-09 15:40:46',
+		'modified_by': 'Administrator',
+		'name': 'FL01361',
+		'no_copy': None,
+		'oldfieldname': 'date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Follow up',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-08-08 17:09:02',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'notes',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Notes',
+		'modified': '2011-05-09 15:40:46',
+		'modified_by': 'Administrator',
+		'name': 'FL01362',
+		'no_copy': None,
+		'oldfieldname': 'notes',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Follow up',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '300px'
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:02',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'follow_up_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Follow up type',
+		'modified': '2011-05-09 15:40:46',
+		'modified_by': 'Administrator',
+		'name': 'FL01363',
+		'no_copy': None,
+		'oldfieldname': 'follow_up_type',
+		'oldfieldtype': 'Select',
+		'options': '\nPhone\nEmail\nSMS\nVisit\nOther',
+		'owner': 'Administrator',
+		'parent': 'Follow up',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-12-14 10:32:58',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'follow_up_by',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Follow up by',
+		'modified': '2011-05-09 15:40:46',
+		'modified_by': 'Administrator',
+		'name': 'FL04147',
+		'no_copy': None,
+		'oldfieldname': 'follow_up_by',
+		'oldfieldtype': 'Link',
+		'options': 'Profile',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Follow up',
+		'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/crm/doctype/industry_type/__init__.py b/crm/doctype/industry_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/industry_type/__init__.py
diff --git a/crm/doctype/industry_type/industry_type.js b/crm/doctype/industry_type/industry_type.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/crm/doctype/industry_type/industry_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/crm/doctype/industry_type/industry_type.txt b/crm/doctype/industry_type/industry_type.txt
new file mode 100644
index 0000000..f7f4245
--- /dev/null
+++ b/crm/doctype/industry_type/industry_type.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-04 12:28:02', 'search_fields': None, 'module': 'CRM', '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': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 5, '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:industry', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Industry Type', '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': 'PERM00998', 'parent': 'Industry Type', 'read': 1, 'create': 1, 'creation': '2010-05-04 12:28:02', 'modified': '2010-09-20 09:41:52', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00999', 'parent': 'Industry Type', 'read': 1, 'create': None, 'creation': '2010-05-04 12:31:05', 'modified': '2010-09-20 09:41:52', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales 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': 'PERM01000', 'parent': 'Industry Type', 'read': 1, 'create': 1, 'creation': '2010-05-04 12:31:05', 'modified': '2010-09-20 09:41:52', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 3, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-05-04 12:28:02', 'doctype': 'DocField', 'oldfieldname': 'industry', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Industry', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Industry Type', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04976', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:41:52', 'parenttype': 'DocType', 'fieldname': 'industry', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/installation_note/__init__.py b/crm/doctype/installation_note/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/installation_note/__init__.py
diff --git a/crm/doctype/installation_note/installation_note.js b/crm/doctype/installation_note/installation_note.js
new file mode 100644
index 0000000..3fe7998
--- /dev/null
+++ b/crm/doctype/installation_note/installation_note.js
@@ -0,0 +1,69 @@
+cur_frm.cscript.tname = "Installed Item Details";
+cur_frm.cscript.fname = "installed_item_details";
+
+cur_frm.cscript.onload = function(doc, dt, dn) {
+  if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
+  if(doc.__islocal){
+    set_multiple(dt,dn,{inst_date:get_today()});
+    hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);        
+  }
+  if (doc.customer) {
+     unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+  }   
+}
+
+cur_frm.fields_dict['delivery_note_no'].get_query = function(doc) {
+  doc = locals[this.doctype][this.docname];
+  var cond = '';
+  if(doc.customer) {
+    cond = '`tabDelivery Note`.customer = "'+doc.customer+'" AND';
+  }
+  return repl('SELECT DISTINCT `tabDelivery Note`.name, `tabDelivery Note`.customer_name  FROM `tabDelivery Note`, `tabDelivery Note Detail` WHERE `tabDelivery Note`.company = "%(company)s" AND `tabDelivery Note`.docstatus = 1 AND ifnull(`tabDelivery Note`.per_installed,0) < 100 AND %(cond)s `tabDelivery Note`.name LIKE "%s" ORDER BY `tabDelivery Note`.name DESC LIMIT 50', {company:doc.company, cond:cond});
+}
+
+
+cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
+  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';
+}
+
+cur_frm.cscript['Get Items'] = function(doc, dt, dn) {
+  var callback = function(r,rt) { 
+	  unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+	  cur_frm.refresh();
+  }
+  get_server_fields('pull_delivery_note_details','','',doc, dt, dn,1,callback);
+}
+
+//customer
+cur_frm.cscript.customer = function(doc,dt,dn) {
+  var callback = function(r,rt) {
+      var doc = locals[cur_frm.doctype][cur_frm.docname];
+      cur_frm.refresh();
+  }   
+
+  if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
+  if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+}
+
+cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {    
+  if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+}
+
+cur_frm.fields_dict.customer_address.on_new = function(dn) {
+  locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+}
+
+cur_frm.fields_dict.contact_person.on_new = function(dn) {
+  locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+}
+
+cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
diff --git a/crm/doctype/installation_note/installation_note.py b/crm/doctype/installation_note/installation_note.py
new file mode 100644
index 0000000..011785e
--- /dev/null
+++ b/crm/doctype/installation_note/installation_note.py
@@ -0,0 +1,209 @@
+# 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
+	
+# -----------------------------------------------------------------------------------------
+
+from utilities.transaction_base import TransactionBase
+
+class DocType(TransactionBase):
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.tname = 'Installed Item Details'
+    self.fname = 'installed_item_details'
+
+  # Autoname
+  # ---------
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+  
+  #fetch customer details
+  #=================================
+  #def get_customer_details(self):
+  #  det = sql("select t1.customer_name, t1.address,t1.territory,t2.contact_name from `tabCustomer` t1, `tabContact` t2 where t1.name = '%s' and t1.name=t2.customer and t2.is_primary_contact = 'Yes'"%self.doc.customer, as_dict=1)
+    
+  #  ret = {
+  #    'customer_name':  det and det[0]['customer_name'] or '',
+  #    'address'  :  det and det[0]['address'] or '',
+  #    'territory':  det and det[0]['territory'] or '',
+  #    'contact_person' : det and det[0]['contact_name'] or ''
+  #  }
+
+  #  return str(ret)
+  
+  #fetch delivery note details
+  #====================================
+  def pull_delivery_note_details(self):
+    self.validate_prev_docname()
+    self.doclist = get_obj('DocType Mapper', 'Delivery Note-Installation Note').dt_map('Delivery Note', 'Installation Note', self.doc.delivery_note_no, self.doc, self.doclist, "[['Delivery Note', 'Installation Note'],['Delivery Note Detail', 'Installed Item Details']]")
+  
+  # Validates that Delivery Note is not pulled twice 
+  #============================================
+  def validate_prev_docname(self):
+    for d in getlist(self.doclist, 'installed_item_details'): 
+      if self.doc.delivery_note_no == d.prevdoc_docname:
+        msgprint(cstr(self.doc.delivery_note_no) + " delivery note details have already been pulled. ")
+        raise Exception, "Validation Error. "
+  
+  #Fiscal Year Validation
+  #================================
+  def validate_fiscal_year(self):
+    get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.inst_date,'Installation Date')
+  
+  #  Validate Mandatory 
+  #===============================
+  def validate_mandatory(self):
+    # Amendment Date
+    if self.doc.amended_from and not self.doc.amendment_date:
+      msgprint("Please Enter Amendment Date")
+      raise Exception, "Validation Error. "
+  
+  # Validate values with reference document
+  #----------------------------------------
+  def validate_reference_value(self):
+    get_obj('DocType Mapper', 'Delivery Note-Installation Note', with_children = 1).validate_reference_value(self, self.doc.name)
+  
+  #check if serial no added
+  #-----------------------------
+  def is_serial_no_added(self,item_code,serial_no):
+    ar_required = sql("select has_serial_no from tabItem where name = '%s'" % item_code)
+    ar_required = ar_required and ar_required[0][0] or ''
+    if ar_required == 'Yes' and not serial_no:
+      msgprint("Serial No is mandatory for item: "+ item_code)
+      raise Exception
+    elif ar_required != 'Yes' and cstr(serial_no).strip():
+      msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :"+item_code)
+      raise Exception
+  
+  #check if serial no exist in system
+  #-------------------------------------
+  def is_serial_no_exist(self, item_code, serial_no):
+    for x in serial_no:
+      chk = sql("select name from `tabSerial No` where name =%s", x)
+      if not chk:
+        msgprint("Serial No "+x+" does not exist in the system")
+        raise Exception
+  
+  #check if serial no already installed
+  #------------------------------------------
+  def is_serial_no_installed(self,cur_s_no,item_code):
+    for x in cur_s_no:
+      status = sql("select status from `tabSerial No` where name = %s", x)
+      status = status and status[0][0] or ''
+      
+      if status == 'Installed':
+        msgprint("Item "+item_code+" with serial no. "+x+" already installed")
+        raise Exception, "Validation Error."
+  
+  #get list of serial no from previous_doc
+  #----------------------------------------------
+  def get_prevdoc_serial_no(self, prevdoc_detail_docname, prevdoc_docname):
+    from material_management.doctype.stock_ledger.stock_ledger import get_sr_no_list
+	
+    res = sql("select serial_no from `tabDelivery Note Detail` where name = '%s' and parent ='%s'" % (prevdoc_detail_docname, prevdoc_docname))
+    return get_sr_no_list(res[0][0])
+    
+  #check if all serial nos from current record exist in resp delivery note
+  #---------------------------------------------------------------------------------
+  def is_serial_no_match(self, cur_s_no, prevdoc_s_no, prevdoc_docname):
+    for x in cur_s_no:
+      if not(x in prevdoc_s_no):
+        msgprint("Serial No. "+x+" not present in the Delivery Note "+prevdoc_docname, raise_exception = 1)
+        raise Exception, "Validation Error."
+  
+  #validate serial number
+  #----------------------------------------
+  def validate_serial_no(self):
+    cur_s_no, prevdoc_s_no, sr_list = [], [], []
+    from material_management.doctype.stock_ledger.stock_ledger import get_sr_no_list
+    
+    for d in getlist(self.doclist, 'installed_item_details'):
+      self.is_serial_no_added(d.item_code, d.serial_no)
+      
+      if d.serial_no:
+
+        sr_list = get_sr_no_list(d.serial_no, d.qty)
+        self.is_serial_no_exist(d.item_code, sr_list)
+        
+        prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname, d.prevdoc_docname)
+        if prevdoc_s_no:
+          self.is_serial_no_match(sr_list, prevdoc_s_no, d.prevdoc_docname)
+        
+        self.is_serial_no_installed(sr_list, d.item_code)
+    return sr_list
+  
+  #validate installation date
+  #-------------------------------
+  def validate_installation_date(self):
+    for d in getlist(self.doclist, 'installed_item_details'):
+      if d.prevdoc_docname:
+        d_date = sql("select posting_date from `tabDelivery Note` where name=%s", d.prevdoc_docname)
+        d_date = d_date and d_date[0][0] or ''
+        
+        if d_date > getdate(self.doc.inst_date):
+          msgprint("Installation Date can not be before Delivery Date "+cstr(d_date)+" for item "+d.item_code)
+          raise Exception
+  
+  def validate(self):
+    self.validate_fiscal_year()
+    self.validate_installation_date()
+    self.check_item_table()
+    sales_com_obj = get_obj(dt = 'Sales Common')
+    sales_com_obj.check_active_sales_items(self)
+    sales_com_obj.get_prevdoc_date(self)
+    self.validate_mandatory()
+    self.validate_reference_value()
+  
+  def check_item_table(self):
+    if not(getlist(self.doclist, 'installed_item_details')):
+      msgprint("Please fetch items from Delivery Note selected")
+      raise Exception
+  
+  def on_update(self):
+    set(self.doc, 'status', 'Draft')
+  
+  def on_submit(self):
+    valid_lst = []
+    valid_lst = self.validate_serial_no()
+    
+    get_obj("Sales Common").update_prevdoc_detail(1,self)
+    
+    for x in valid_lst:
+      wp = sql("select warranty_period from `tabSerial No` where name = '%s'"% x)
+      wp = wp and wp[0][0] or 0
+      if wp:
+        sql("update `tabSerial No` set maintenance_status = 'Under Warranty' where name = '%s'" % x)
+      
+      sql("update `tabSerial No` set status = 'Installed' where name = '%s'" % x)
+    
+    set(self.doc, 'status', 'Submitted')
+
+  
+  def on_cancel(self):
+    cur_s_no = []
+    sales_com_obj = get_obj(dt = 'Sales Common')
+    sales_com_obj.update_prevdoc_detail(0,self)
+    
+    for d in getlist(self.doclist, 'installed_item_details'):
+      if d.serial_no:
+        #get current list of serial no
+        cur_serial_no = d.serial_no.replace(' ', '')
+        cur_s_no = cur_serial_no.split(',')
+    
+    for x in cur_s_no:
+      sql("update `tabSerial No` set status = 'Delivered' where name = '%s'" % x)
+      
+    set(self.doc, 'status', 'Cancelled')
diff --git a/crm/doctype/installation_note/installation_note.txt b/crm/doctype/installation_note/installation_note.txt
new file mode 100644
index 0000000..4b4fc41
--- /dev/null
+++ b/crm/doctype/installation_note/installation_note.txt
@@ -0,0 +1,1205 @@
+[
+	{
+		'_last_update': '1305630270',
+		'_user_tags': None,
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': None,
+		'autoname': 'IN/.####',
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:04',
+		'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': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-05-17 16:34:30',
+		'modified_by': 'Guest',
+		'module': 'CRM',
+		'name': 'Installation Note',
+		'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,
+		'subject': 'At %(customer_name)s on %(inst_date)s',
+		'tag_fields': None,
+		'use_template': None,
+		'version': 96
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:04',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00265',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:04',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00266',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:04',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00267',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:04',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00268',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:04',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00269',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:04',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00270',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': None,
+		'write': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:48',
+		'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': 'Installation Note',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05181',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05182',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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-10-12 15:19:26',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Series',
+		'modified': '2011-05-25 12:44:47',
+		'modified_by': 'Guest',
+		'name': 'FL03978',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': '\nIN',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Installation Note',
+		'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-09-01 15:48:02',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Customer',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL03787',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Customer Address',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05174',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Address',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_person',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Contact Person',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01525',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Name',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01523',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Address',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05175',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_display',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Contact',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05176',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_mobile',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Mobile No',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05177',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_email',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Contact Email',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05178',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'Territory',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01526',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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': '2011-05-25 12:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Customer Group',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05179',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Customer Group',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05183',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'inst_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Installation Date',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01533',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'inst_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'inst_time',
+		'fieldtype': 'Time',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Installation Time',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01534',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'inst_time',
+		'oldfieldtype': 'Time',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:04',
+		'default': 'Draft',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': 'Status',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01532',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': 'Draft\nSubmitted\nCancelled',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'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:04',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select the relevant company name if you have multiple companies.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': 1,
+		'label': 'Company',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01535',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Select',
+		'options': 'link:Company',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01536',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Amended From',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01529',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'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:04',
+		'default': None,
+		'depends_on': None,
+		'description': 'The date at which current entry is corrected in the system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'icon': None,
+		'idx': 21,
+		'in_filter': None,
+		'label': 'Amendment Date',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01530',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'remarks',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Remarks',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01537',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'remarks',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Installation Note',
+		'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': '2010-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 23,
+		'in_filter': None,
+		'label': 'Cancel Reason',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01538',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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:44:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'Item Details',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL05184',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'delivery_note_no',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': 'Delivery Note No',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01527',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'delivery_note_no',
+		'oldfieldtype': 'Link',
+		'options': 'Delivery Note',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'icon': None,
+		'idx': 26,
+		'in_filter': None,
+		'label': 'Get Items',
+		'modified': '2010-09-17 12:05:21',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'FL01528',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'pull_delivery_note_details',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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-04-19 14:05:12',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'icon': None,
+		'idx': 26,
+		'in_filter': None,
+		'label': 'Get Items',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': '000002566',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'pull_delivery_note_details',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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-08-08 17:09:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'installed_item_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': None,
+		'label': 'Installed Item Details',
+		'modified': '2011-05-25 12:44:48',
+		'modified_by': 'Guest',
+		'name': 'FL01540',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'installed_item_details',
+		'oldfieldtype': 'Table',
+		'options': 'Installed Item Details',
+		'owner': 'Administrator',
+		'parent': 'Installation Note',
+		'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/crm/doctype/installed_item_details/__init__.py b/crm/doctype/installed_item_details/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/installed_item_details/__init__.py
diff --git a/crm/doctype/installed_item_details/installed_item_details.txt b/crm/doctype/installed_item_details/installed_item_details.txt
new file mode 100644
index 0000000..ea67565
--- /dev/null
+++ b/crm/doctype/installed_item_details/installed_item_details.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-30 07:28:32', 'search_fields': None, 'module': 'CRM', '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': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 24, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'IID/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Installed Item Details', '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': '2010-06-30 07:28:32', 'doctype': 'DocField', 'oldfieldname': 'item_code', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Item Code', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Installed Item Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05484', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'item_code', 'fieldtype': 'Link', 'options': 'Item', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-06-30 07:28:32', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Installed Item Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05485', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Date', 'creation': '2010-06-30 12:51:00', 'doctype': 'DocField', 'oldfieldname': 'prevdoc_date', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 0, 'modified_by': 'Administrator', 'label': 'Delivery Date', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 0, 'permlevel': 1, 'description': None, 'parent': 'Installed Item Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05502', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'prevdoc_date', 'fieldtype': 'Date', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2010-06-30 07:28:32', 'doctype': 'DocField', 'oldfieldname': 'qty', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Installed Qty', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Installed Item Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05487', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'qty', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2010-06-30 07:28:32', 'doctype': 'DocField', 'oldfieldname': 'serial_no', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Serial No', 'width': '180px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Installed Item Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05488', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'serial_no', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-06-30 07:28:32', 'doctype': 'DocField', 'oldfieldname': 'prevdoc_detail_docname', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Against Document Detail No', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Installed Item Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05489', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'prevdoc_detail_docname', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-06-30 12:35:29', 'doctype': 'DocField', 'oldfieldname': 'prevdoc_docname', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Against Document No', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Installed Item Details', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05499', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'prevdoc_docname', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-06-30 12:35:29', 'doctype': 'DocField', 'oldfieldname': 'prevdoc_doctype', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Document Type', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Installed Item Details', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL05500', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-07-07 11:00:30', 'parenttype': 'DocType', 'fieldname': 'prevdoc_doctype', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/lead/__init__.py b/crm/doctype/lead/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/lead/__init__.py
diff --git a/crm/doctype/lead/lead.comp.js b/crm/doctype/lead/lead.comp.js
new file mode 100644
index 0000000..e960c44
--- /dev/null
+++ b/crm/doctype/lead/lead.comp.js
@@ -0,0 +1,18 @@
+
+$import(SMS Control)
+cur_frm.cscript.onload=function(doc,cdt,cdn){if(user=='Guest'){hide_field(['status','naming_series','order_lost_reason','customer','rating','fax','website','territory','TerritoryHelp','address_line1','address_line2','city','state','country','pincode','address','lead_owner','market_segment','industry','campaign_name','interested_in','company','fiscal_year','contact_by','contact_date','last_contact_date','contact_date_ref','to_discuss','More Info','follow_up','Communication History','cc_to','subject','message','Attachment Html','Create New File','lead_attachment_detail','Send Email','Email','Create Customer','Create Enquiry','Next Steps','transaction_date','type','source']);doc.source='Website';}
+if(!doc.status)set_multiple(dt,dn,{status:'Open'});if(!doc.date){doc.date=date.obj_to_str(new Date());}
+if(user=='Guest')doc.naming_series='WebLead';cur_frm.add_fetch('customer','customer_name','company_name');}
+cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons()
+if(!doc.__islocal&&!in_list(['Converted','Lead Lost'],doc.status)){cur_frm.add_custom_button('Create Customer',cur_frm.cscript['Create Customer']);cur_frm.add_custom_button('Create Enquiry',cur_frm.cscript['Create Enquiry']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}}
+cur_frm.cscript.status=function(doc,cdt,cdn){cur_frm.cscript.refresh(doc,cdt,cdn);}
+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);}
+cur_frm.cscript['Create New File']=function(doc){new_doc("File");}
+cur_frm.cscript.item_code=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.item_code){get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);}}
+cur_frm.cscript['Create Customer']=function(){var doc=cur_frm.doc;$c('runserverobj',args={'method':'check_status','docs':compress_doclist([doc])},function(r,rt){if(r.message=='Converted'){msgprint("This lead is already converted to customer");}
+else{n=createLocal("Customer");$c('dt_map',args={'docs':compress_doclist([locals["Customer"][n]]),'from_doctype':'Lead','to_doctype':'Customer','from_docname':doc.name,'from_to_list':"[['Lead', 'Customer']]"},function(r,rt){loaddoc("Customer",n);});}});}
+cur_frm.cscript['Send Email']=function(doc,cdt,cdn){if(doc.__islocal!=1){$c_obj(make_doclist(doc.doctype,doc.name),'send_mail','',function(r,rt){});}else{msgprint("Please save lead first before sending email")}}
+cur_frm.cscript['Create Enquiry']=function(){var doc=cur_frm.doc;$c('runserverobj',args={'method':'check_status','docs':compress_doclist([doc])},function(r,rt){if(r.message=='Converted'){msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");}
+else{n=createLocal("Enquiry");$c('dt_map',args={'docs':compress_doclist([locals["Enquiry"][n]]),'from_doctype':'Lead','to_doctype':'Enquiry','from_docname':doc.name,'from_to_list':"[['Lead', 'Enquiry']]"},function(r,rt){loaddoc("Enquiry",n);});}});}
+cur_frm.fields_dict['territory'].get_query=function(doc,cdt,cdn){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';}
\ No newline at end of file
diff --git a/crm/doctype/lead/lead.js b/crm/doctype/lead/lead.js
new file mode 100644
index 0000000..888c030
--- /dev/null
+++ b/crm/doctype/lead/lead.js
@@ -0,0 +1,147 @@
+// Module CRM
+
+$import(SMS Control)
+
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  if(user =='Guest'){
+    hide_field(['status', 'naming_series', 'order_lost_reason', 'customer', 'rating', 'fax', 'website', 'territory', 'TerritoryHelp', 'address_line1', 'address_line2', 'city', 'state', 'country', 'pincode', 'address', 'lead_owner', 'market_segment', 'industry', 'campaign_name', 'interested_in', 'company', 'fiscal_year', 'contact_by', 'contact_date', 'last_contact_date', 'contact_date_ref', 'to_discuss', 'More Info', 'follow_up', 'Communication History', 'cc_to', 'subject', 'message', 'Attachment Html', 'Create New File', 'lead_attachment_detail', 'Send Email', 'Email', 'Create Customer', 'Create Enquiry', 'Next Steps', 'transaction_date', 'type', 'source']);
+    doc.source = 'Website';
+  }
+  if(!doc.status) set_multiple(dt,dn,{status:'Open'});
+
+  if (!doc.date){ 
+    doc.date = date.obj_to_str(new Date());
+  }
+  // set naming series
+  if(user=='Guest') doc.naming_series = 'WebLead';
+  
+  cur_frm.add_fetch('customer', 'customer_name', 'company_name');	
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  // custom buttons
+  //---------------
+  cur_frm.clear_custom_buttons()
+  if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
+    cur_frm.add_custom_button('Create Customer', cur_frm.cscript['Create Customer']);
+    cur_frm.add_custom_button('Create Enquiry', cur_frm.cscript['Create Enquiry']);
+    cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+  }
+}
+
+
+// Client Side Triggers
+// ===========================================================
+// ************ Status ******************
+cur_frm.cscript.status = function(doc, cdt, cdn){
+  cur_frm.cscript.refresh(doc, cdt, cdn);
+}
+
+/*
+// *********** Country ******************
+// This will show states belonging to country
+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.TerritoryHelp = function(doc,dt,dn){
+  var call_back = function(){
+    var sb_obj = new SalesBrowser();        
+    sb_obj.set_val('Territory');
+  }
+
+  loadpage('Sales Browser',call_back);
+}
+
+// Create New File
+// ===============================================================
+cur_frm.cscript['Create New File'] = function(doc){
+  new_doc("File");
+}
+
+//Trigger in Item Table
+//===================================
+cur_frm.cscript.item_code=function(doc,cdt,cdn){
+  var d = locals[cdt][cdn];
+  if (d.item_code) { get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);}
+}
+
+// Create New Customer
+// ===============================================================
+cur_frm.cscript['Create Customer'] = function(){
+  var doc = cur_frm.doc;
+  $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
+    function(r,rt){
+      if(r.message == 'Converted'){
+        msgprint("This lead is already converted to customer");
+      }
+      else{
+        n = createLocal("Customer");
+        $c('dt_map', args={
+          'docs':compress_doclist([locals["Customer"][n]]),
+          'from_doctype':'Lead',
+          'to_doctype':'Customer',
+          'from_docname':doc.name,
+          'from_to_list':"[['Lead', 'Customer']]"
+        }, 
+        function(r,rt) {
+          loaddoc("Customer", n);
+        }
+        );
+      }
+    }
+  );
+}
+
+// send email
+// ===============================================================
+cur_frm.cscript['Send Email'] = function(doc,cdt,cdn){
+  if(doc.__islocal != 1){
+    $c_obj(make_doclist(doc.doctype, doc.name),'send_mail','',function(r,rt){});
+  }else{
+    msgprint("Please save lead first before sending email")
+  }
+}
+
+// Create New Enquiry
+// ===============================================================
+cur_frm.cscript['Create Enquiry'] = function(){
+  var doc = cur_frm.doc;
+  $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
+    function(r,rt){
+      if(r.message == 'Converted'){
+        msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
+      }
+      else{
+        n = createLocal("Enquiry");
+        $c('dt_map', args={
+          'docs':compress_doclist([locals["Enquiry"][n]]),
+          'from_doctype':'Lead',
+          'to_doctype':'Enquiry',
+          'from_docname':doc.name,
+          'from_to_list':"[['Lead', 'Enquiry']]"
+        }
+        , function(r,rt) {
+            loaddoc("Enquiry", n);
+          }
+        );
+      }
+    }
+  );
+}
+
+//get query select Territory
+cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
+  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';
+}
diff --git a/crm/doctype/lead/lead.py b/crm/doctype/lead/lead.py
new file mode 100644
index 0000000..1bf8c8d
--- /dev/null
+++ b/crm/doctype/lead/lead.py
@@ -0,0 +1,212 @@
+# 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
+  
+  # Autoname
+  # ---------
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+  
+  #check status of lead
+  #------------------------
+  def check_status(self):
+    chk = sql("select status from `tabLead` where name=%s", self.doc.name)
+    chk = chk and chk[0][0] or ''
+    return cstr(chk)
+
+  # Gets states belonging cto country selected
+  # =====================================================================
+  #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)])
+  
+  # Get item detail (will be removed later)
+  #=======================================
+  def get_item_detail(self,item_code):
+    it=sql("select item_name,brand,item_group,description,stock_uom from `tabItem` where name='%s'"%item_code)
+    if it:
+      ret = {
+      'item_name'  : it and it[0][0] or '',
+      'brand'      : it and it[0][1] or '',
+      'item_group' : it and it[0][2] or '',
+      'description': it and it[0][3] or '',
+      'uom' : it and it[0][4] or ''
+      }
+      return cstr(ret)
+  
+  def validate(self):
+    import string
+    # Get Address
+    # ======================================================================
+    #if (self.doc.address_line1) or (self.doc.address_line2) or (self.doc.city) or (self.doc.state) or (self.doc.country) or (self.doc.pincode):
+    #  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"
+    #  if self.doc.website:
+    #    comp_address += "Website : "+ self.doc.website
+    #  self.doc.address = comp_address
+    
+    if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason:
+      msgprint("Please Enter Order Lost Reason")
+      raise Exception  
+    
+    if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest':
+      msgprint("Please specify campaign name")
+      raise Exception
+    
+    if self.doc.email_id:
+      if not validate_email_add(self.doc.email_id):
+        msgprint('Please enter valid email id.')
+        raise Exception
+    
+    if not self.doc.naming_series:
+      if session['user'] == 'Guest':
+        so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'")
+        #so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'")
+        if so:
+          sr = so[0][0].split("\n")
+          set(self.doc, 'naming_series', sr[0])
+      else:
+        msgprint("Please specify naming series")
+        raise Exception  
+  
+  def on_update(self):
+    # Add to calendar
+    # ========================================================================
+    if self.doc.contact_by:
+      self.add_calendar_event()
+    
+    if session['user'] == 'Guest':
+      if self.doc.email_id:
+        self.send_email_notification()
+    
+    if not self.doc.naming_series:
+      if session['user'] == 'Guest':
+        #so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'")
+        so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'")
+        if so:
+          sr = so[0][0].split("\n")
+          set(self.doc, 'naming_series', sr[0])
+      else:
+        msgprint("Please specify naming series")
+        raise Exception
+  
+  def send_email_notification(self):
+    if not validate_email_add(self.doc.email_id.strip(' ')):
+      msgprint('error:%s is not a valid email id' % self.doc.email_id.strip(' '))
+      raise Exception
+    else:
+      subject = 'Thank you for interest in erpnext'
+       
+      sendmail([self.doc.email_id.strip(' ')], sender = sender_email[0][0], subject = subject , parts = [['text/html', self.get_notification_msg()]])
+      #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
+      msgprint("Mail Sent")
+  
+  def get_notification_msg(self):
+    t = """
+<html>
+<body>
+Dear %s,<br><br>
+
+Thank you for contacting us.<br><br>
+
+You have left following message for us,<br>
+%s
+<br><br>
+
+You will receive reply on this shortly.<br><br>
+
+Cheers!
+</body>
+</html>
+""" % (self.doc.lead_name, self.doc.remark)
+
+    return t
+
+  # Add to Calendar
+  # ===========================================================================
+  def add_calendar_event(self):
+    # delete any earlier event by this lead
+    sql("delete from tabEvent where ref_type='Lead' and ref_name=%s", self.doc.name)
+  
+    in_calendar_of = self.doc.lead_owner
+    
+    # get profile (id) if exists for contact_by
+    email_id = webnotes.conn.get_value('Sales Person', self.doc.contact_by, 'email_id')
+    if webnotes.conn.exists('Profile', email_id):
+      in_calendar_of = email_id
+    
+    ev = Document('Event')
+    ev.owner = in_calendar_of
+    ev.description = 'Contact ' + cstr(self.doc.lead_name) + '.By : ' + cstr(self.doc.contact_by) + '.To Discuss : ' + cstr(self.doc.to_discuss)
+    ev.event_date = self.doc.contact_date
+    ev.event_hour = '10:00'
+    ev.event_type = 'Private'
+    ev.ref_type = 'Lead'
+    ev.ref_name = self.doc.name
+    ev.save(1)
+
+
+#-----------------Email-------------------------------------------- 
+  def send_emails(self, email=[], subject='', message=''):
+    if email:
+      sendmail(email, sender = webnotes.user.name, subject = subject , parts = [['text/html', message]])
+      msgprint("Mail Sent")
+      self.add_in_follow_up(message,'Email')
+
+#-------------------------Checking Sent Mails Details----------------------------------------------        
+  def send_mail(self):
+    if not self.doc.subject or not self.doc.message:
+      msgprint("Please enter subject & message in their respective fields.")
+    elif not self.doc.email_id:
+      msgprint("Recipient not specified. Please add email id of lead in 'Email id' field provided in 'Contact Info' section.")
+      raise Exception
+    else :
+     self.send_emails([self.doc.email_id.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
+
+#---------------------- Add details in follow up table----------------
+  def add_in_follow_up(self,message,type):
+    import datetime
+    child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
+    child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
+    child.notes = message
+    child.follow_up_type = type
+    child.save()
+
+#-------------------SMS----------------------------------------------
+  def send_sms(self):
+    if not self.doc.sms_message or not self.doc.mobile_no:
+      msgprint("Please enter mobile number in Basic Info Section and message in SMS Section ")
+      raise Exception
+    else:
+      receiver_list = []
+      if self.doc.mobile_no:
+        receiver_list.append(self.doc.mobile_no)
+      for d in getlist(self.doclist,'lead_sms_detail'):
+        if d.other_mobile_no:
+          receiver_list.append(d.other_mobile_no)
+    
+    if receiver_list:
+      msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
+      self.add_in_follow_up(self.doc.sms_message,'SMS')
diff --git a/crm/doctype/lead/lead.txt b/crm/doctype/lead/lead.txt
new file mode 100644
index 0000000..6c77978
--- /dev/null
+++ b/crm/doctype/lead/lead.txt
@@ -0,0 +1,1840 @@
+[
+	{
+		'_last_update': '1305009922',
+		'_user_tags': None,
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': None,
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'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-05-10 12:15:21',
+		'modified_by': 'Guest',
+		'module': 'CRM',
+		'name': 'Lead',
+		'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': 'lead_name,lead_owner,status',
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'subject': '%(lead_name)s from %(company_name)s | To Discuss: %(to_discuss)s',
+		'tag_fields': 'status,source',
+		'use_template': None,
+		'version': 394
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00314',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00315',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 0,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00316',
+		'owner': 'swarnalata@webnotestech.com',
+		'parent': 'Lead',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00317',
+		'owner': 'swarnalata@webnotestech.com',
+		'parent': 'Lead',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00318',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'All',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00319',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'submit': 0,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': 1,
+		'creation': '2010-10-07 12:49:37',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 7,
+		'match': None,
+		'modified': '2010-10-19 11:33:05',
+		'modified_by': 'ashwini@webnotestech.com',
+		'name': 'PERM00707',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Guest',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:44:51',
+		'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': 'Basic Info',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05191',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05192',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Contact Name',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01766',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'lead_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'source',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Source',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01768',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'source',
+		'oldfieldtype': 'Select',
+		'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWebsite",
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': "eval:doc.source == 'Existing Customer'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'From Customer',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01769',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': "eval:doc.source == 'Campaign'",
+		'description': 'Enter campaign name if the source of lead is campaign.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'campaign_name',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Campaign Name',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01793',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'campaign_name',
+		'oldfieldtype': 'Link',
+		'options': 'Campaign',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': 'Name of organization from where lead has come',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': 1,
+		'label': 'Company Name',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01770',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': 'LEAD',
+		'depends_on': None,
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Series',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01763',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'LEAD\nLEAD/10-11/\nLEAD/MUMBAI/\nLEAD/AGENT1/\nLEAD/AGENT2/',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': 'Open',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': 1,
+		'label': 'Status',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01764',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nOpen\nAttempted to Contact\nContact in Future\nContacted\nInterested\nNot interested\nLead Lost\nConverted',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': 'Today',
+		'depends_on': None,
+		'description': 'The date at which current entry is made in system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': 1,
+		'label': 'Lead Date',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01767',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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': '2011-05-25 12:44:51',
+		'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:51',
+		'modified_by': 'Guest',
+		'name': 'FL05193',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'Lead Type',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01771',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'type',
+		'oldfieldtype': 'Select',
+		'options': '\nClient\nChannel Partner\nConsultant',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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-10-07 12:51:59',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'request_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Request Type',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL03976',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'request_type',
+		'oldfieldtype': 'Select',
+		'options': '\nProduct Enquiry\nRequest for Information\nSuggestions\nOther',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': 'Probability of lead converting to customer',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rating',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': 1,
+		'label': 'Rating',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01772',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'rating',
+		'oldfieldtype': 'Select',
+		'options': '\nHot\nWarm\nCold',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'remark',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Remark',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01773',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'remark',
+		'oldfieldtype': 'Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': "eval:doc.status == 'Lead Lost'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'order_lost_reason',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': 'Lost Reason',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01765',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'order_lost_reason',
+		'oldfieldtype': 'Link',
+		'options': 'Order Lost Reason',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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-10-19 13:01:59',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL04091',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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:44:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': 'Contact Info',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05194',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:50',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'phone',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Phone',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL05187',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_no',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'mobile_no',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Mobile No.',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01776',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'mobile_no',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'email_id',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': None,
+		'label': 'Email Id',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01777',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'email_id',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'fax',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Fax',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01778',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'fax',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'website',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 23,
+		'in_filter': None,
+		'label': 'Website',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01779',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'website',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To manage Territory, click here</a>',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'Territory',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01780',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'territory',
+		'oldfieldtype': 'Link',
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:44:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05195',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address_line1',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 26,
+		'in_filter': None,
+		'label': 'Address Line 1',
+		'modified': '2011-05-25 12:44:50',
+		'modified_by': 'Guest',
+		'name': 'FL01782',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'address_line1',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address_line2',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': None,
+		'label': 'Address Line 2',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01783',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'address_line2',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'city',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 28,
+		'in_filter': None,
+		'label': 'City',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01784',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'city',
+		'oldfieldtype': 'Select',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'country',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 29,
+		'in_filter': None,
+		'label': 'Country',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01785',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'country',
+		'oldfieldtype': 'Select',
+		'options': 'link:Country',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'state',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 30,
+		'in_filter': None,
+		'label': 'State',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01786',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'state',
+		'oldfieldtype': 'Select',
+		'options': 'link:State',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'pincode',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 31,
+		'in_filter': None,
+		'label': 'Pin Code',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01787',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'pincode',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:44:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 32,
+		'in_filter': None,
+		'label': 'More Info',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05196',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 33,
+		'in_filter': None,
+		'label': 'Company',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01795',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': '__user',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead_owner',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 34,
+		'in_filter': 1,
+		'label': 'Lead Owner',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01790',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'lead_owner',
+		'oldfieldtype': 'Link',
+		'options': 'Profile',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'market_segment',
+		'fieldtype': 'Select',
+		'hidden': 0,
+		'icon': None,
+		'idx': 35,
+		'in_filter': 1,
+		'label': 'Market Segment',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01791',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'market_segment',
+		'oldfieldtype': 'Select',
+		'options': '\nLower Income\nMiddle Income\nUpper Income',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'industry',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 36,
+		'in_filter': None,
+		'label': 'Industry',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01792',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'industry',
+		'oldfieldtype': 'Link',
+		'options': 'Industry Type',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your products or facilities in which the lead is interested',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'interested_in',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 37,
+		'in_filter': None,
+		'label': 'Interested In',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01794',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'interested_in',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'icon': None,
+		'idx': 38,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01796',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:51',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 39,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05197',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your sales person who will contact the lead in future',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_by',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 40,
+		'in_filter': 1,
+		'label': 'Next Contact By',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01798',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_by',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Person',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your sales person will get a reminder on this date to contact the lead',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 41,
+		'in_filter': 1,
+		'label': 'Next Contact Date',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01799',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'contact_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:44:51',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': 'Date on which the lead was last contacted',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'last_contact_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 42,
+		'in_filter': None,
+		'label': 'Last Contact Date',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05190',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'last_contact_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'to_discuss',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 43,
+		'in_filter': None,
+		'label': 'To Discuss',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01802',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'to_discuss',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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:51',
+		'default': None,
+		'depends_on': None,
+		'description': 'Keep a track of communication with this lead which will help for future reference.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 44,
+		'in_filter': None,
+		'label': 'Communication History',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL05198',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': None,
+		'creation': '2010-08-08 17:09:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'follow_up',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 45,
+		'in_filter': None,
+		'label': 'Follow up',
+		'modified': '2011-05-25 12:44:51',
+		'modified_by': 'Guest',
+		'name': 'FL01804',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'follow_up',
+		'oldfieldtype': 'Table',
+		'options': 'Follow up',
+		'owner': 'Administrator',
+		'parent': 'Lead',
+		'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/crm/doctype/lead_attachment_detail/__init__.py b/crm/doctype/lead_attachment_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/lead_attachment_detail/__init__.py
diff --git a/crm/doctype/lead_attachment_detail/lead_attachment_detail.txt b/crm/doctype/lead_attachment_detail/lead_attachment_detail.txt
new file mode 100644
index 0000000..85f086c
--- /dev/null
+++ b/crm/doctype/lead_attachment_detail/lead_attachment_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-10-06 12:12:21', 'search_fields': None, 'module': 'CRM', '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': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 2, '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': 'Lead Attachment 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-10-06 12:12:21', 'doctype': 'DocField', 'oldfieldname': 'select_file', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Select File For Attachment', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Lead Attachment Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03137', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-10-06 12:35:51', 'parenttype': 'DocType', 'fieldname': 'select_file', 'fieldtype': 'Link', 'options': 'File', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/lead_item_detail/__init__.py b/crm/doctype/lead_item_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/lead_item_detail/__init__.py
diff --git a/crm/doctype/lead_item_detail/lead_item_detail.txt b/crm/doctype/lead_item_detail/lead_item_detail.txt
new file mode 100644
index 0000000..2f83a9f
--- /dev/null
+++ b/crm/doctype/lead_item_detail/lead_item_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-30 15:38:55', 'search_fields': None, 'module': 'CRM', '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': 1, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'swarnalata@webnotestech.com', 'document_type': None, 'name': 'Lead Item Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': None, '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-03-30 15:38:55', 'doctype': 'DocField', 'oldfieldname': 'item_code', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Item Code', 'width': '200px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01565', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'item_code', 'fieldtype': 'Link', 'options': 'Item', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-19 11:15:06', 'doctype': 'DocField', 'oldfieldname': 'item_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Item Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02098', 'idx': 2, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'item_name', 'fieldtype': 'Data', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-07-08 11:17:32', 'doctype': 'DocField', 'oldfieldname': 'item_group', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Item Group', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02551', 'idx': 3, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'item_group', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-07-08 11:17:32', 'doctype': 'DocField', 'oldfieldname': 'brand', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Brand', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02552', 'idx': 4, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'brand', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-03-30 15:38:55', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Description', 'width': '100px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01566', 'idx': 5, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-30 15:38:55', 'doctype': 'DocField', 'oldfieldname': 'uom', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'UOM', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 0, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01567', 'idx': 6, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'uom', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-30 15:38:55', 'doctype': 'DocField', 'oldfieldname': 'qty', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': 0, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Qty', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': 0, 'permlevel': 0, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01568', 'idx': 7, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'qty', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-30 15:38:55', 'doctype': 'DocField', 'oldfieldname': 'rate', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Rate', 'width': '100px', 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01569', 'idx': 8, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'rate', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Read Only', 'creation': '2009-03-30 15:38:55', 'doctype': 'DocField', 'oldfieldname': 'amount', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'swarnalata@webnotestech.com', 'label': 'Amount', 'width': '100px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Lead Item Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01570', 'idx': 9, 'default': None, 'colour': None, 'modified': '2009-10-09 15:32:48', 'parenttype': 'DocType', 'fieldname': 'amount', 'fieldtype': 'Read Only', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/lead_sms_detail/__init__.py b/crm/doctype/lead_sms_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/lead_sms_detail/__init__.py
diff --git a/crm/doctype/lead_sms_detail/lead_sms_detail.txt b/crm/doctype/lead_sms_detail/lead_sms_detail.txt
new file mode 100644
index 0000000..aeb93cb
--- /dev/null
+++ b/crm/doctype/lead_sms_detail/lead_sms_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-10-06 12:10:26', 'search_fields': None, 'module': 'CRM', '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': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 2, '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': 'Lead SMS 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': 'Data', 'creation': '2009-10-06 12:10:26', 'doctype': 'DocField', 'oldfieldname': 'other_mobile_no', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Mobile No', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Lead SMS Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03136', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-10-06 17:26:45', 'parenttype': 'DocType', 'fieldname': 'other_mobile_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/plot_control/__init__.py b/crm/doctype/plot_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/plot_control/__init__.py
diff --git a/crm/doctype/plot_control/plot_control.py b/crm/doctype/plot_control/plot_control.py
new file mode 100644
index 0000000..d403053
--- /dev/null
+++ b/crm/doctype/plot_control/plot_control.py
@@ -0,0 +1,229 @@
+# 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 ,self.doclist = doc, doclist
+
+  #============================get monthly sales====================================================  
+  def get_monthwise_amount(self,lst):
+    lst = lst.split(',')
+    if not lst[1]:
+      ret = convert_to_lists(sql("SELECT SUM(grand_total) AMOUNT,CASE MONTH(due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME FROM `tabReceivable Voucher` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY MONTH(due_date) ORDER BY MONTH(due_date)"%lst[0]))
+    else:
+      ret = convert_to_lists(sql("select sum(t2.amount) AMOUNT ,CASE MONTH(t1.due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME from `tabReceivable Voucher` t1,`tabRV Detail` t2 WHERE t1.name = t2.parent and t1.docstatus = 1 and t2.item_group = '%s' AND t1.fiscal_year = '%s' GROUP BY MONTH(t1.due_date) ORDER BY MONTH(t1.due_date)"%(lst[1],lst[0])))
+    
+    m =cint(sql("select month('%s')"%(get_defaults()['year_start_date']))[0][0])
+
+    lst1 = [[1,'JAN'],[2 ,'FEB'], [3,'MAR'],[4,'APR'],[5,'MAY'],[6,'JUN'],[7,'JUL'],[8,'AUG'],[9,'SEP'],[10,'OCT'],[11,'NOV'],[12,'DEC']]
+    lst2=[]
+    k=1
+
+    for i in range(1,13):
+      for j in lst1:
+        if j[0]==m:
+          lst2.append([k,j[1]])
+      m +=1
+      if m==13: m=1
+      k +=1
+    return {'msg_data':ret,'x_axis':lst2}
+
+  #===============================get weekly sales=================================================
+  def get_weekwise_amount(self,lst):
+   
+    lst = lst.split(',')
+    
+    cases = self.get_week_cases(lst[0],lst[1])
+          
+    if not lst[2]:
+      query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+ cases +"END Weekly FROM `tabReceivable Voucher` WHERE MONTH(due_date) = %d AND docstatus = 1 AND fiscal_year = '%s' GROUP BY Weekly  ORDER BY Weekly"
+      
+      ret = convert_to_lists(sql(query%(cint(lst[0]),lst[1])))
+    
+    else:
+          
+      query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly FROM `tabReceivable Voucher` t1, `tabRV Detail` t2 WHERE MONTH(t1.due_date) = %d AND t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly  ORDER BY Weekly"
+      
+      ret =convert_to_lists(sql(query%(cint(lst[0]),lst[1],lst[2])))
+ 
+    return ret and ret or ''
+  #================================================================================
+  def get_week_cases(self,m1,fy):
+    d1 = self.make_date("%s,%s"%(cstr(m1),fy))
+     
+    w = sql("select week('%s'),week(last_day('%s'))"%(d1,d1))
+    w1 = cint(w[0][0]) 
+    w2 = cint(w[0][1])
+   
+    w3 = []
+    str1 = " "
+    for i in range(1,7):
+      if(w1 <= w2):
+        w3.append(w1)
+        str1 += "WHEN "+ cstr(w1) +" THEN 'Week"+cstr(i) +"' "
+        w1 += 1
+    
+    return str1
+      
+  #===============================get yearly weekwise sales=================================================
+  def get_year_weekwise_amount(self,lst):
+    
+    lst = lst.split(',')
+    yr_st = get_defaults()['year_start_date']
+    
+    fy = lst[0]
+    m1 = cint(yr_st.split('-')[1])
+
+    cases = ' '
+    for i in range(1,13):
+      cases += self.get_week_cases(m1,fy)
+      m1 +=1
+      if(m1 == 13): m1 = 1 
+    
+    if not lst[1]:
+      query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+cases+"END Weekly, month(due_date) month FROM `tabReceivable Voucher` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY `month`,weekly ORDER BY `month`,weekly"
+      ret = convert_to_lists(sql(query%lst[0]))
+    
+    else:
+    
+      query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly, month(due_date) month FROM `tabReceivable Voucher` t1, `tabRV Detail` t2 WHERE t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly  ORDER BY Weekly"
+      ret = convert_to_lists(sql(query%(lst[0],lst[1])))
+      
+    
+    return ret and ret or ''
+  
+
+  #====================================make yearly weekwise dates================================================
+  def yr_wk_dates(self,fy):
+    
+    from datetime import date
+    yr_st = get_defaults()['year_start_date']
+    yr_en = get_defaults()['year_end_date']
+    
+    fy = fy.split('-')
+    y1 = yr_st.split('-')
+    date1 = date(cint(fy[0]),cint(y1[1]),cint(y1[2]))
+    
+    y2 = yr_en.split('-')
+    date2 = date(cint(fy[1]),cint(y2[1]),cint(y2[2]))
+    
+    
+
+    date_lst = [[1,self.get_months(cint(y1[1]))]]
+    m1=cint(y1[1])+1
+    x_axis_lst = [[1,'Week1',cint(y1[1])]]
+    
+    from datetime import date, timedelta
+    d =dt= date1
+
+    week=k=1
+    for i in range(0,53): 
+
+      if dt <= date2:
+        
+        if(d.weekday()>3):
+          d = d+timedelta(7-d.weekday())
+        else:
+          d = d - timedelta(d.weekday())
+        dlt = timedelta(days = (week-1)*7)
+        dt = d + dlt + timedelta(days=6)
+        
+        m2 = cint(sql("Select month('%s')"%dt)[0][0])
+        
+        if(m1 == m2):
+          date_lst.append([i+2,self.get_months(m2)])
+          x_axis_lst.append([i+2,'Week1',m2])
+          k=1
+          m1 += 1 
+          if(m1==13): m1 =1
+        else:
+          date_lst.append([i+2,' '])
+          x_axis_lst.append([i+2,'Week%d'%k,m2])
+        week += 1
+        k +=1
+        
+               
+    return [date_lst,x_axis_lst]
+  #===================================================================================
+
+  def get_months(self,m):
+    m_lst = {1:'JAN',2:'FEB',3:'MAR',4:'APR',5:'MAY',6:'JUN',7:'JUL',8:'AUG',9:'SEP',10:'OCT',11:'NOV',12:'DEC'}
+    return m_lst[m]
+
+  
+    
+  def get_weekdates(self,lst):
+    from datetime import date, timedelta
+  
+    d = dt = self.make_date(lst)
+    date_lst = [[1,cstr(d.strftime("%d/%m/%y"))]]
+    week=flag =1
+    j=1
+    last_day = sql("select last_day('%s')"%d)[0][0]
+    lst_m = cint(lst.split(',')[0])
+    for i in range(2,8):
+      f=0
+      if(dt < last_day):
+        #if(d.weekday()>4):
+        #d = d+timedelta(7-d.weekday()) 
+        #else:
+        d = d - timedelta(d.weekday()-1)
+        dlt = timedelta(days = (week-1)*7)
+        dt = d + dlt + timedelta(days=6)
+        
+        if(cint(sql("select month('%s')"%dt)[0][0]) == lst_m and dt!=last_day):
+          for k in date_lst:      
+            if(cstr(dt.strftime("%d/%m/%y")) == k[1]):
+              f = 1
+          if f == 0:   
+            date_lst.append([i,cstr(dt.strftime("%d/%m/%y"))])
+          
+        elif(dt==last_day and flag ==1):
+          date_lst.append([i,cstr(last_day.strftime("%d/%m/%y"))])
+          flag = 0
+      
+        elif(flag == 1):
+          date_lst.append([i,cstr(last_day.strftime("%d/%m/%y"))])
+        week += 1
+       
+    return date_lst and date_lst or ''
+        
+          
+  def make_date(self,lst):
+    
+    from datetime import date, timedelta
+    lst = lst.split(',')
+    year = lst[1].split('-')
+    if(len(lst[0])==1):  month = '0'+lst[0]
+    else: month = lst[0]
+    if(1<=cint(month)<=3): year = year[1]    
+    elif(4<=cint(month)<=12): year = year[0]
+    
+    d = date(cint(year),cint(month),1)
+    
+    return d 
+    
+  def get_item_groups(self):
+    ret = convert_to_lists(sql("select name from `tabItem Group` where docstatus != 2 and is_group = 'No'"))
+    #ret = convert_to_lists(sql("select item_group from `tabItem` where is_sales_item='Yes' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life >  now()) and item_group !=''"))
+    return ret and ret or ''
+    
+  def get_fiscal_year(self):
+    ret = convert_to_lists(sql("select name from `tabFiscal Year` where docstatus =0"))
+    return ret and ret or ''
\ No newline at end of file
diff --git a/crm/doctype/plot_control/plot_control.txt b/crm/doctype/plot_control/plot_control.txt
new file mode 100644
index 0000000..cab7968
--- /dev/null
+++ b/crm/doctype/plot_control/plot_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-17 10:36:31', 'search_fields': None, 'module': 'CRM', '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': 215, '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': 'Plot 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/crm/doctype/quotation/__init__.py b/crm/doctype/quotation/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/quotation/__init__.py
diff --git a/crm/doctype/quotation/quotation.comp.js b/crm/doctype/quotation/quotation.comp.js
new file mode 100644
index 0000000..2808e49
--- /dev/null
+++ b/crm/doctype/quotation/quotation.comp.js
@@ -0,0 +1,40 @@
+
+cur_frm.cscript.tname="Quotation Detail";cur_frm.cscript.fname="quotation_details";cur_frm.cscript.other_fname="other_charges";cur_frm.cscript.sales_team_fname="sales_team";$import(Sales Common)
+$import(Other Charges)
+$import(SMS Control)
+cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.quotation_to)hide_field(['customer','customer_address','contact_person','customer_name','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);if(!doc.price_list_name)set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});if(!doc.status)set_multiple(cdt,cdn,{status:'Draft'});if(!doc.transaction_date)set_multiple(cdt,cdn,{transaction_date:get_today()});if(!doc.conversion_rate)set_multiple(cdt,cdn,{conversion_rate:'1.00'});if(!doc.currency&&sys_defaults.currency)set_multiple(cdt,cdn,{currency:sys_defaults.currency});if(!doc.company&&sys_defaults.company)set_multiple(cdt,cdn,{company:sys_defaults.company});if(!doc.fiscal_year&&sys_defaults.fiscal_year)set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});if(doc.__islocal&&!getchildren('RV Tax Detail',doc.name,'other_charges',doc.doctype).length)cur_frm.cscript.load_taxes(doc,cdt,cdn);if(doc.__islocal==1){cur_frm.cscript.price_list_name(doc,cdt,cdn);}
+if(doc.quotation_to){if(doc.quotation_to=='Customer'){hide_field(['lead','lead_name']);}
+else if(doc.quotation_to=='Lead'){hide_field(['customer','customer_address','contact_person','customer_name','contact_display','customer_group']);}}}
+cur_frm.cscript.lead_cust_show=function(doc,cdt,cdn){if(doc.quotation_to=='Lead'){unhide_field(['lead']);hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}
+else if(doc.quotation_to=='Customer'){unhide_field(['customer']);hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}}
+cur_frm.cscript.quotation_to=function(doc,cdt,cdn){cur_frm.cscript.lead_cust_show(doc,cdt,cdn);}
+cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons();if(doc.docstatus==1&&doc.status!='Order Lost'){cur_frm.add_custom_button('Make Sales Order',cur_frm.cscript['Make Sales Order']);cur_frm.add_custom_button('Set as Lost',cur_frm.cscript['Declare Order Lost']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}
+if(!doc.docstatus)hide_field(['Update Follow up']);else unhide_field(['Update Follow up']);}
+cur_frm.cscript.customer=function(doc,dt,dn){if(doc.customer)get_server_fields('get_default_customer_address',JSON.stringify({customer:doc.customer}),'',doc,dt,dn,1);if(doc.customer)unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);}
+cur_frm.cscript.customer_address=cur_frm.cscript.contact_person=function(doc,dt,dn){if(doc.customer)get_server_fields('get_customer_address',JSON.stringify({customer:doc.customer,address:doc.customer_address,contact:doc.contact_person}),'',doc,dt,dn,1);}
+cur_frm.fields_dict.customer_address.on_new=function(dn){locals['Address'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Address'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
+cur_frm.fields_dict.contact_person.on_new=function(dn){locals['Contact'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Contact'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
+cur_frm.fields_dict['customer_address'].get_query=function(doc,cdt,cdn){return'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
+cur_frm.fields_dict['contact_person'].get_query=function(doc,cdt,cdn){return'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
+cur_frm.fields_dict['lead'].get_query=function(doc,cdt,cdn){return'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s"  ORDER BY  `tabLead`.`name` ASC LIMIT 50';}
+cur_frm.cscript.lead=function(doc,cdt,cdn){if(doc.lead)get_server_fields('get_lead_details',doc.lead,'',doc,cdt,cdn,1);if(doc.lead)unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);}
+cur_frm.fields_dict['enq_no'].get_query=function(doc,cdt,cdn){var cond='';var cond1='';if(doc.order_type)cond='ifnull(`tabEnquiry`.enquiry_type, "") = "'+doc.order_type+'" AND';if(doc.customer)cond1='`tabEnquiry`.customer = "'+doc.customer+'" AND';else if(doc.lead)cond1='`tabEnquiry`.lead = "'+doc.lead+'" AND';return repl('SELECT `tabEnquiry`.`name` FROM `tabEnquiry` WHERE `tabEnquiry`.`docstatus` = 1 AND `tabEnquiry`.status = "Submitted" AND %(cond)s %(cond1)s `tabEnquiry`.`name` LIKE "%s" ORDER BY `tabEnquiry`.`name` ASC LIMIT 50',{cond:cond,cond1:cond1});}
+cur_frm.cscript['Make Sales Order']=function(){var doc=cur_frm.doc;if(doc.docstatus==1){var n=createLocal("Sales Order");$c('dt_map',args={'docs':compress_doclist([locals["Sales Order"][n]]),'from_doctype':'Quotation','to_doctype':'Sales Order','from_docname':doc.name,'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"},function(r,rt){loaddoc("Sales Order",n);});}}
+cur_frm.cscript['Pull Enquiry Detail']=function(doc,cdt,cdn){var callback=function(r,rt){if(r.message){doc.quotation_to=r.message;if(doc.quotation_to=='Lead'){unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);}
+else if(doc.quotation_to=='Customer'){unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);}
+refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);}}
+$c_obj(make_doclist(doc.doctype,doc.name),'pull_enq_details','',callback);}
+cur_frm.cscript['Update Follow up']=function(doc){$c_obj(make_doclist(doc.doctype,doc.name),'update_followup_details','',function(r,rt){refresh_field('follow_up');doc.__unsaved=0;cur_frm.refresh_header();});}
+cur_frm.cscript['Declare Order Lost']=function(){var qtn_lost_dialog;set_qtn_lost_dialog=function(doc,cdt,cdn){qtn_lost_dialog=new Dialog(400,400,'Add Quotation Lost Reason');qtn_lost_dialog.make_body([['HTML','Message','<div class="comment">Please add quotation lost reason</div>'],['Text','Quotation Lost Reason'],['HTML','Response','<div class = "comment" id="update_quotation_dialog_response"></div>'],['HTML','Add Reason','<div></div>']]);var add_reason_btn1=$a($i(qtn_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn1.innerHTML='Add';add_reason_btn1.onclick=function(){qtn_lost_dialog.add();}
+var add_reason_btn2=$a($i(qtn_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn2.innerHTML='Cancel';$y(add_reason_btn2,{marginLeft:'4px'});add_reason_btn2.onclick=function(){qtn_lost_dialog.hide();}
+qtn_lost_dialog.onshow=function(){qtn_lost_dialog.widgets['Quotation Lost Reason'].value='';$i('update_quotation_dialog_response').innerHTML='';}
+qtn_lost_dialog.add=function(){$i('update_quotation_dialog_response').innerHTML='Processing...';var arg=strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);var call_back=function(r,rt){if(r.message=='true'){$i('update_quotation_dialog_response').innerHTML='Done';qtn_lost_dialog.hide();}}
+if(arg)$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_order_lost',arg,call_back);else msgprint("Please add Quotation lost reason");}}
+if(!qtn_lost_dialog){set_qtn_lost_dialog(doc,cdt,cdn);}
+qtn_lost_dialog.show();}
+cur_frm.cscript['Get Report']=function(doc,cdt,cdn){var callback=function(report){report.set_filter('Sales Order Detail','Quotation No.',doc.name)
+report.dt.run();}
+loadreport('Sales Order Detail','Itemwise Sales Details',callback);}
+cur_frm.cscript.quot_to_validate=function(doc,cdt,cdn){if(doc.quotation_to=='Lead'){if(!doc.lead){alert("Lead is mandatory.");validated=false;}}
+else if(doc.quotation_to=='Customer'){if(!doc.customer){alert("Customer is mandatory.");validated=false;}}}
+cur_frm.cscript.validate=function(doc,cdt,cdn){cur_frm.cscript.quot_to_validate(doc,cdt,cdn);}
\ No newline at end of file
diff --git a/crm/doctype/quotation/quotation.js b/crm/doctype/quotation/quotation.js
new file mode 100644
index 0000000..bdf6781
--- /dev/null
+++ b/crm/doctype/quotation/quotation.js
@@ -0,0 +1,309 @@
+// Module CRM
+cur_frm.cscript.tname = "Quotation Detail";
+cur_frm.cscript.fname = "quotation_details";
+cur_frm.cscript.other_fname = "other_charges";
+cur_frm.cscript.sales_team_fname = "sales_team";
+
+// =====================================================================================
+$import(Sales Common)
+$import(Other Charges)
+$import(SMS Control)
+
+// ONLOAD
+// ===================================================================================
+cur_frm.cscript.onload = function(doc, cdt, cdn) {  
+  if(!doc.quotation_to) hide_field(['customer','customer_address','contact_person','customer_name','lead', 'lead_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
+  if(!doc.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
+  if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
+  if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
+  if(!doc.conversion_rate) set_multiple(cdt,cdn,{conversion_rate:'1.00'});
+  if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
+  //if(!doc.price_list_name && sys_defaults.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
+  if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
+  if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
+
+  // load default charges
+  if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length) cur_frm.cscript.load_taxes(doc, cdt, cdn);
+
+  if(doc.__islocal==1){  cur_frm.cscript.price_list_name(doc, cdt, cdn);}
+  
+  if(doc.quotation_to) {
+    if(doc.quotation_to == 'Customer') {
+      hide_field(['lead', 'lead_name']);
+    }
+    else if (doc.quotation_to == 'Lead') {
+      hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']);
+    }
+  }
+}
+
+// hide - unhide fields based on lead or customer..
+// =======================================================================================================================
+cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
+  if(doc.quotation_to == 'Lead'){
+    unhide_field(['lead']);
+    hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+    doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
+  }
+  else if(doc.quotation_to == 'Customer'){    
+    unhide_field(['customer']);
+    hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);    
+    doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
+  }
+  //refresh_many(['lead','customer']);
+}
+
+
+
+//================ hide - unhide fields on basis of quotation to either lead or customer =============================== 
+cur_frm.cscript.quotation_to = function(doc,cdt,cdn){
+  cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
+  //doc.customer_address = doc.territory = doc.contact_no = doc.email_id = "";
+  //refresh_many(['territory','customer_address','contact_no','email_id']);
+  //doc.address_display = doc.contact_display = "";
+  //refresh_many(['address_display','contact_display']);
+}
+
+
+// REFRESH
+// ===================================================================================
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+
+  cur_frm.clear_custom_buttons();
+
+  if(doc.docstatus == 1 && doc.status!='Order Lost') {
+    cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
+    cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
+    cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+  }
+  
+  if (!doc.docstatus) hide_field(['Update Follow up']);
+  else unhide_field(['Update Follow up']);
+  //cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
+}
+
+// ============== Lead and its Details ============================
+
+/*
+//================ create new contact ============================================================================
+cur_frm.cscript.new_contact = function(){
+  tn = createLocal('Contact');
+  locals['Contact'][tn].is_customer = 1;
+  if(doc.customer) locals['Contact'][tn].customer = doc.customer;
+  loaddoc('Contact', tn);
+}
+*/
+
+
+// DOCTYPE TRIGGERS
+// ====================================================================================
+
+/*
+// ***************** Get Contact Person based on customer selected *****************
+cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabContact`.contact_name, `tabContact`.email_id FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.docstatus != 2 AND `tabContact`.customer = "'+ doc.customer +'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
+}
+*/
+
+//customer
+cur_frm.cscript.customer = function(doc,dt,dn) {
+  var callback = function(r,rt) {
+      var doc = locals[cur_frm.doctype][cur_frm.docname];
+      cur_frm.refresh();
+  }   
+
+  if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
+  if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+}
+
+cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
+  if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+}
+
+cur_frm.fields_dict.customer_address.on_new = function(dn) {
+  locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;  
+}
+
+cur_frm.fields_dict.contact_person.on_new = function(dn) {
+  locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;  
+}
+
+cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+//lead
+cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
+  return 'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s"  ORDER BY  `tabLead`.`name` ASC LIMIT 50';
+}
+
+cur_frm.cscript.lead = function(doc, cdt, cdn) {
+  if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
+  if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);  
+}
+
+
+// =====================================================================================
+cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
+  var cond='';
+  var cond1='';
+  if(doc.order_type) cond = 'ifnull(`tabEnquiry`.enquiry_type, "") = "'+doc.order_type+'" AND';
+  if(doc.customer) cond1 = '`tabEnquiry`.customer = "'+doc.customer+'" AND';
+  else if(doc.lead) cond1 = '`tabEnquiry`.lead = "'+doc.lead+'" AND';
+
+  return repl('SELECT `tabEnquiry`.`name` FROM `tabEnquiry` WHERE `tabEnquiry`.`docstatus` = 1 AND `tabEnquiry`.status = "Submitted" AND %(cond)s %(cond1)s `tabEnquiry`.`name` LIKE "%s" ORDER BY `tabEnquiry`.`name` ASC LIMIT 50', {cond:cond, cond1:cond1});
+}
+
+// Make Sales Order
+// =====================================================================================
+cur_frm.cscript['Make Sales Order'] = function() {
+  var doc = cur_frm.doc;
+
+  if (doc.docstatus == 1) { 
+    var n = createLocal("Sales Order");
+    $c('dt_map', args={
+      'docs':compress_doclist([locals["Sales Order"][n]]),
+      'from_doctype':'Quotation',
+      'to_doctype':'Sales Order',
+      'from_docname':doc.name,
+      'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"
+    }, function(r,rt) {
+      loaddoc("Sales Order", n);
+    });
+  }
+}
+
+//pull enquiry details
+cur_frm.cscript['Pull Enquiry Detail'] = function(doc,cdt,cdn){
+
+  var callback = function(r,rt){
+    if(r.message){
+      doc.quotation_to = r.message;
+      
+		  if(doc.quotation_to == 'Lead') {
+  			  unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);			  
+		  }
+		  else if(doc.quotation_to == 'Customer') {
+			  unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+		  }
+		  refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);
+    }
+  }   
+  
+  $c_obj(make_doclist(doc.doctype, doc.name),'pull_enq_details','',callback);
+
+}
+
+//update follow up
+//=================================================================================
+cur_frm.cscript['Update Follow up'] = function(doc){
+
+  $c_obj(make_doclist(doc.doctype, doc.name),'update_followup_details','',function(r, rt){
+    refresh_field('follow_up');
+    doc.__unsaved = 0;
+    cur_frm.refresh_header();
+  });
+}
+
+
+// declare order lost
+//-------------------------
+cur_frm.cscript['Declare Order Lost'] = function(){
+  var qtn_lost_dialog;
+  
+  set_qtn_lost_dialog = function(doc,cdt,cdn){
+    qtn_lost_dialog = new Dialog(400,400,'Add Quotation Lost Reason');
+    qtn_lost_dialog.make_body([
+      ['HTML', 'Message', '<div class="comment">Please add quotation lost reason</div>'],
+      ['Text', 'Quotation Lost Reason'],
+      ['HTML', 'Response', '<div class = "comment" id="update_quotation_dialog_response"></div>'],
+      ['HTML', 'Add Reason', '<div></div>']
+    ]);
+    
+    var add_reason_btn1 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
+    add_reason_btn1.innerHTML = 'Add';
+    add_reason_btn1.onclick = function(){ qtn_lost_dialog.add(); }
+    
+    var add_reason_btn2 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
+    add_reason_btn2.innerHTML = 'Cancel';
+    $y(add_reason_btn2,{marginLeft:'4px'});
+    add_reason_btn2.onclick = function(){ qtn_lost_dialog.hide();}
+    
+    qtn_lost_dialog.onshow = function() {
+      qtn_lost_dialog.widgets['Quotation Lost Reason'].value = '';
+      $i('update_quotation_dialog_response').innerHTML = '';
+    }
+    
+    qtn_lost_dialog.add = function() {
+      // sending...
+      $i('update_quotation_dialog_response').innerHTML = 'Processing...';
+      var arg =  strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);
+      var call_back = function(r,rt) { 
+        if(r.message == 'true'){
+          $i('update_quotation_dialog_response').innerHTML = 'Done';
+          qtn_lost_dialog.hide();
+        }
+      }
+      if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
+      else msgprint("Please add Quotation lost reason");
+    }
+  }  
+  
+  if(!qtn_lost_dialog){
+    set_qtn_lost_dialog(doc,cdt,cdn);
+  }  
+  qtn_lost_dialog.show();
+}
+
+
+// GET REPORT
+// ========================================================================================
+cur_frm.cscript['Get Report'] = function(doc,cdt,cdn) {
+  var callback = function(report){
+  report.set_filter('Sales Order Detail', 'Quotation No.',doc.name)
+  report.dt.run();
+ }
+ loadreport('Sales Order Detail','Itemwise Sales Details', callback);
+}
+
+
+
+
+/*
+//get query select Territory
+cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
+  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';}
+*/
+
+//===================== Quotation to validation - either customer or lead mandatory ====================
+cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
+  
+  if(doc.quotation_to == 'Lead'){
+  
+    if(!doc.lead){
+      alert("Lead is mandatory.");  
+      validated = false; 
+    }
+  }
+  else if(doc.quotation_to == 'Customer'){
+   
+    if(!doc.customer){
+      alert("Customer is mandatory.");
+      validated = false;
+    }
+    
+  }
+ 
+}
+
+//===================validation function =================================
+
+cur_frm.cscript.validate = function(doc,cdt,cdn){
+  cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
+}
diff --git a/crm/doctype/quotation/quotation.py b/crm/doctype/quotation/quotation.py
new file mode 100644
index 0000000..caa0430
--- /dev/null
+++ b/crm/doctype/quotation/quotation.py
@@ -0,0 +1,362 @@
+# 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, load_json
+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
+	
+# -----------------------------------------------------------------------------------------
+
+from utilities.transaction_base import TransactionBase
+
+class DocType(TransactionBase):
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.tname = 'Quotation Detail'
+    self.fname = 'quotation_details'
+    
+    # Notification objects
+    self.notify_obj = get_obj('Notification Control')
+
+  # Autoname
+  # ---------
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+
+
+# DOCTYPE TRIGGER FUNCTIONS
+# ==============================================================================    
+ 
+  # Pull Enquiry Details
+  # --------------------
+  def pull_enq_details(self):
+    self.doc.clear_table(self.doclist, 'quotation_details')
+    get_obj('DocType Mapper', 'Enquiry-Quotation').dt_map('Enquiry', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Enquiry', 'Quotation'],['Enquiry Detail', 'Quotation Detail']]")
+
+    self.get_adj_percent()
+
+    return cstr(self.doc.quotation_to)
+    
+  # Get Customer Details
+  # --------------------
+  #def get_customer_details(self):
+  #  return cstr(get_obj('Sales Common').get_customer_details(self))
+
+  # Get contact person details based on customer selected
+  # ------------------------------------------------------
+  def get_contact_details(self):
+    return cstr(get_obj('Sales Common').get_contact_details(self,0))
+  
+  # Clear Quotation Details
+  # -----------------------
+  def clear_quotation_details(self):
+    self.doc.clear_table(self.doclist, 'quotation_details')  
+  
+    
+# QUOTATION DETAILS TRIGGER FUNCTIONS
+# ================================================================================    
+
+  # Get Item Details
+  # -----------------
+  def get_item_details(self, item_code):
+    return get_obj('Sales Common').get_item_details(item_code, self)
+  
+  # Re-calculates Basic Rate & amount based on Price List Selected
+  # --------------------------------------------------------------
+  def get_adj_percent(self, arg=''):
+    get_obj('Sales Common').get_adj_percent(self)
+    
+
+# OTHER CHARGES TRIGGER FUNCTIONS
+# ====================================================================================
+  
+  # Get Tax rate if account type is TAX
+  # -----------------------------------
+  def get_rate(self,arg):
+    return get_obj('Sales Common').get_rate(arg)
+
+  # Load Default Charges
+  # ----------------------------------------------------------
+  def load_default_taxes(self):
+    return get_obj('Sales Common').load_default_taxes(self)
+
+  # Pull details from other charges master (Get Other Charges)
+  # ----------------------------------------------------------
+  def get_other_charges(self):
+    return get_obj('Sales Common').get_other_charges(self)
+  
+  # Get Lead Details along with its details
+  # ==============================================================
+  def get_lead_details1(self, name):    
+    details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, territory, contact_no, mobile_no, email_id from `tabLead` where name = '%s'" %(name), as_dict = 1)   
+    ret = {
+      'lead_name' : details and details[0]['lead_name'] or '',
+      'address_display' : (details and details[0]['address_line1']
+				     + (details[0]['address_line2'] and '\n' + details[0]['address_line2'] or '') + '\n' 
+				     + details[0]['city'] 
+				     + (details[0]['pincode'] and ', ' + details[0]['pincode'] or '') + '\n' 
+				     + (details[0]['state'] and details[0]['state']+', ' or '') 
+				     + details[0]['country'] + '\nTel: ' + details[0]['contact_no'] + '\n' or '-'),
+      'territory' : details and details[0]['territory'] or '',
+      'contact_mobile' : details and details[0]['mobile_no'] or '-',
+      'contact_email' : details and details[0]['email_id'] or '-'      
+    }
+    return cstr(ret)
+
+     
+# GET TERMS AND CONDITIONS
+# ====================================================================================
+  def get_tc_details(self):
+    return get_obj('Sales Common').get_tc_details(self)
+
+    
+# VALIDATE
+# ==============================================================================================
+  
+  # Amendment date is necessary if document is amended
+  # --------------------------------------------------
+  def validate_mandatory(self):
+    if self.doc.amended_from and not self.doc.amendment_date:
+      msgprint("Please Enter Amendment Date")
+      raise Exception
+
+  # Fiscal Year Validation
+  # ----------------------
+  def validate_fiscal_year(self):
+    get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Quotation Date')
+  
+  # Does not allow same item code to be entered twice
+  # -------------------------------------------------
+  def validate_for_items(self):
+    check_list=[]
+    chk_dupl_itm = []
+    for d in getlist(self.doclist,'quotation_details'):
+      ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
+      if ch and ch[0][0]=='Yes':
+        if cstr(d.item_code) in check_list:
+	  msgprint("Item %s has been entered twice." % d.item_code)
+	  raise Exception
+	else:
+	  check_list.append(cstr(d.item_code))
+      
+      if ch and ch[0][0]=='No':
+        f = [cstr(d.item_code),cstr(d.description)]
+	if f in chk_dupl_itm:
+	  msgprint("Item %s has been entered twice." % d.item_code)
+	  raise Exception
+	else:
+	  chk_dupl_itm.append(f)
+
+
+  #do not allow sales item in maintenance quotation and service item in sales quotation
+  #-----------------------------------------------------------------------------------------------
+  def validate_order_type(self):
+    if self.doc.order_type == 'Maintenance':
+      for d in getlist(self.doclist, 'quotation_details'):
+        is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
+        is_service_item = is_service_item and is_service_item[0][0] or 'No'
+        
+        if is_service_item == 'No':
+          msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation")
+          raise Exception
+    else:
+      for d in getlist(self.doclist, 'quotation_details'):
+        is_sales_item = sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
+        is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
+        
+        if is_sales_item == 'No':
+          msgprint("You can not select non sales item "+d.item_code+" in Sales Quotation")
+          raise Exception
+  
+  #--------------Validation For Last Contact Date-----------------
+  # ====================================================================================================================
+  def set_last_contact_date(self):
+    #if not self.doc.contact_date_ref:
+      #self.doc.contact_date_ref=self.doc.contact_date
+      #self.doc.last_contact_date=self.doc.contact_date_ref
+    if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
+      if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
+        self.doc.last_contact_date=self.doc.contact_date_ref
+      else:
+        msgprint("Contact Date Cannot be before Last Contact Date")
+        raise Exception
+      #set(self.doc, 'contact_date_ref',self.doc.contact_date)
+  
+
+  # Validate
+  # --------
+  def validate(self):
+    self.validate_fiscal_year()
+    self.validate_mandatory()
+    self.set_last_contact_date()
+    self.validate_order_type()
+    self.validate_for_items()
+    sales_com_obj = get_obj('Sales Common')
+    sales_com_obj.check_active_sales_items(self)
+    sales_com_obj.validate_max_discount(self,'quotation_details') #verify whether rate is not greater than max_discount
+    sales_com_obj.check_conversion_rate(self)
+    
+    # Get total in words
+    self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
+    self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
+
+  def on_update(self):
+    # Add to calendar
+    #if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
+    if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
+      if self.doc.contact_by:
+        self.add_calendar_event()
+      set(self.doc, 'contact_date_ref',self.doc.contact_date)
+    
+    # Set Quotation Status
+    set(self.doc, 'status', 'Draft')
+
+    # subject for follow
+    self.doc.subject = '[%(status)s] To %(customer)s worth %(currency)s %(grand_total)s' % self.doc.fields
+
+  
+  # Add to Calendar
+  # ====================================================================================================================
+  def add_calendar_event(self):
+    desc=''
+    user_lst =[]
+    if self.doc.customer:
+      if self.doc.contact_person:
+        desc = 'Contact '+cstr(self.doc.contact_person)
+      else:
+        desc = 'Contact customer '+cstr(self.doc.customer)
+    elif self.doc.lead:
+      if self.doc.lead_name:
+        desc = 'Contact '+cstr(self.doc.lead_name)
+      else:
+        desc = 'Contact lead '+cstr(self.doc.lead)
+    desc = desc+ '.By : ' + cstr(self.doc.contact_by)
+    
+    if self.doc.to_discuss:
+      desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
+    
+    ev = Document('Event')
+    ev.description = desc
+    ev.event_date = self.doc.contact_date
+    ev.event_hour = '10:00'
+    ev.event_type = 'Private'
+    ev.ref_type = 'Enquiry'
+    ev.ref_name = self.doc.name
+    ev.save(1)
+    
+    user_lst.append(self.doc.owner)
+    
+    chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
+    if chk:
+      user_lst.append(chk[0][0])
+    
+    for d in user_lst:
+      ch = addchild(ev, 'event_individuals', 'Event User', 0)
+      ch.person = d
+      ch.save(1)
+  
+  #update enquiry
+  #------------------
+  def update_enquiry(self, flag):
+    prevdoc=''
+    for d in getlist(self.doclist, 'quotation_details'):
+      if d.prevdoc_docname:
+        prevdoc = d.prevdoc_docname
+    
+    if prevdoc:
+      if flag == 'submit': #on submit
+        sql("update `tabEnquiry` set status = 'Quotation Sent' where name = %s", prevdoc)
+      elif flag == 'cancel': #on cancel
+        sql("update `tabEnquiry` set status = 'Open' where name = %s", prevdoc)
+      elif flag == 'order lost': #order lost
+        sql("update `tabEnquiry` set status = 'Enquiry Lost' where name=%s", prevdoc)
+      elif flag == 'order confirm': #order confirm
+        sql("update `tabEnquiry` set status='Order Confirmed' where name=%s", prevdoc)
+  
+  # declare as order lost
+  #-------------------------
+  def declare_order_lost(self,arg):
+    chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and t2.prevdoc_docname = %s",self.doc.name)
+    if chk:
+      msgprint("Sales Order No. "+cstr(chk[0][0])+" is submitted against this Quotation. Thus 'Order Lost' can not be declared against it.")
+      raise Exception
+    else:
+      set(self.doc, 'status', 'Order Lost')
+      set(self.doc, 'order_lost_reason', arg)
+      self.update_enquiry('order lost')
+      return cstr('true')
+  
+  #check if value entered in item table
+  #--------------------------------------
+  def check_item_table(self):
+    if not getlist(self.doclist, 'quotation_details'):
+      msgprint("Please enter item details")
+      raise Exception
+    
+  # ON SUBMIT
+  # =========================================================================
+  def on_submit(self):
+    self.check_item_table()
+    if not self.doc.amended_from:
+      set(self.doc, 'message', 'Quotation: '+self.doc.name+' has been sent')
+    else:
+      set(self.doc, 'message', 'Quotation has been amended. New Quotation no:'+self.doc.name)
+    
+    # Check for Approving Authority
+    get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
+
+    # Set Quotation Status
+    set(self.doc, 'status', 'Submitted')
+    
+    #update enquiry status
+    self.update_enquiry('submit')
+    
+    # on submit notification
+    self.notify_obj.notify_contact('Quotation', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.contact_person)
+    
+# ON CANCEL
+# ==========================================================================
+  def on_cancel(self):
+    set(self.doc, 'message', 'Quotation: '+self.doc.name+' has been cancelled')
+    
+    #update enquiry status
+    self.update_enquiry('cancel')
+    
+    set(self.doc,'status','Cancelled')
+    
+  
+# SEND SMS
+# =============================================================================
+  def send_sms(self):
+    if not self.doc.customer_mobile_no:
+      msgprint("Please enter customer mobile no")
+    elif not self.doc.message:
+      msgprint("Please enter the message you want to send")
+    else:
+      msgprint(get_obj("SMS Control", "SMS Control").send_sms([self.doc.contact_mobile,], self.doc.message))
+  
+# Print other charges
+# ===========================================================================
+  def print_other_charges(self,docname):
+    print_lst = []
+    for d in getlist(self.doclist,'other_charges'):
+      lst1 = []
+      lst1.append(d.description)
+      lst1.append(d.total)
+      print_lst.append(lst1)
+    return print_lst
+  
+  def update_followup_details(self):
+    sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name)
+    for d in getlist(self.doclist, 'follow_up'):
+      d.save()
diff --git a/crm/doctype/quotation/quotation.txt b/crm/doctype/quotation/quotation.txt
new file mode 100644
index 0000000..527264d
--- /dev/null
+++ b/crm/doctype/quotation/quotation.txt
@@ -0,0 +1,2953 @@
+[
+	{
+		'_last_update': '1305804973',
+		'_user_tags': None,
+		'allow_attach': 1,
+		'allow_copy': None,
+		'allow_email': 0,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': None,
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Transaction',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': 0,
+		'idx': None,
+		'in_create': None,
+		'in_dialog': None,
+		'is_transaction_doc': 1,
+		'issingle': None,
+		'istable': None,
+		'max_attachments': 1,
+		'menu_index': None,
+		'modified': '2011-05-17 16:24:50',
+		'modified_by': 'Guest',
+		'module': 'CRM',
+		'name': 'Quotation',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': None,
+		'read_only_onload': 1,
+		'search_fields': 'status,transaction_date, customer,company,order_type',
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'subject': 'To %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s',
+		'tag_fields': 'status',
+		'use_template': None,
+		'version': 594
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2011-03-21 16:39:48',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': '000001912',
+		'owner': 'rahul@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': None,
+		'role': 'user print',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00435',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00436',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00437',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00438',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': 'customer_name',
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00439',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Customer',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 7,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00440',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Maintenance Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 8,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00441',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Maintenance Manager',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 9,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00442',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Maintenance User',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:17',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 10,
+		'match': None,
+		'modified': '2011-04-29 14:22:54',
+		'modified_by': 'ravi@iwebnotes.com',
+		'name': 'PERM00443',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Maintenance User',
+		'submit': None,
+		'write': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:09',
+		'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': 'Basic Info',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05298',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05299',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:17',
+		'default': 'QTN',
+		'depends_on': None,
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Series',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02632',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'QTN',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'quotation_to',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Quotation To',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02634',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'quotation_to',
+		'oldfieldtype': 'Select',
+		'options': '\nLead\nCustomer',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-09-01 15:48:02',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'icon': None,
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Customer',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL03788',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'icon': None,
+		'idx': 6,
+		'in_filter': 1,
+		'label': 'Customer Address',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02638',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_person',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'icon': None,
+		'idx': 7,
+		'in_filter': 1,
+		'label': 'Contact Person',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02639',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_person',
+		'oldfieldtype': 'Link',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Name',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02635',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'icon': None,
+		'idx': 9,
+		'in_filter': 1,
+		'label': 'Lead',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02636',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'lead',
+		'oldfieldtype': 'Link',
+		'options': 'Lead',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Quotation',
+		'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': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'lead_name',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Name',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02637',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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': 'White:FFF',
+		'creation': '2011-05-25 12:45:08',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Small Text',
+		'hidden': 0,
+		'icon': None,
+		'idx': 11,
+		'in_filter': 0,
+		'label': 'Address',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL05289',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer_address',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:08',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_display',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': 0,
+		'label': 'Contact',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL05290',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 0,
+		'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:08',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_mobile',
+		'fieldtype': 'Text',
+		'hidden': 0,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Mobile No',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL05291',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 0,
+		'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:08',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_email',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'Contact Email',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL05292',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05300',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:17',
+		'default': 'Today',
+		'depends_on': None,
+		'description': 'The date at which current entry is made in system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': 1,
+		'label': 'Quotation Date',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02642',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'order_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': 1,
+		'label': 'Order Type',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02631',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'order_type',
+		'oldfieldtype': 'Select',
+		'options': '\nSales\nMaintenance',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 0,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': 'Draft',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': 1,
+		'label': 'Status',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02633',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nDraft\nSubmitted\nOrder Confirmed\nOrder Lost\nCancelled',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Amended From',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02643',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': 'The date at which current entry is corrected in the system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Amendment Date',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02644',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': "To create Quotation against Enquiry, Select Enquiry No. and click on 'Pull Enquiry Details' ",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'enq_no',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 21,
+		'in_filter': 1,
+		'label': 'Enquiry No',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02645',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'enq_no',
+		'oldfieldtype': 'Link',
+		'options': 'Enquiry',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'icon': None,
+		'idx': 22,
+		'in_filter': None,
+		'label': 'Pull Enquiry Detail',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02646',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': 'Will be fetched from Customer',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'icon': None,
+		'idx': 23,
+		'in_filter': 1,
+		'label': 'Territory',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02640',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': 1,
+		'label': 'Customer Group',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02680',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer_group',
+		'oldfieldtype': 'Link',
+		'options': 'Customer Group',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:09',
+		'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': 'Items',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05301',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 26,
+		'in_filter': None,
+		'label': 'Clear Table',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02650',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'clear_quotation_details',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select the price list as entered in "Price List" master. This will pull the reference rates of items against this price list as specified in "Item" master.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'price_list_name',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': 1,
+		'label': 'Price List',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02651',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'price_list_name',
+		'oldfieldtype': 'Select',
+		'options': 'link:Price List',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 28,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05302',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:17',
+		'default': None,
+		'depends_on': None,
+		'description': "Customer's currency - If you want to select a currency that is not the default currency, then you must also specify the Currency Conversion Rate.",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'currency',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 29,
+		'in_filter': 1,
+		'label': 'Currency',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02647',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'currency',
+		'oldfieldtype': 'Select',
+		'options': 'link:Currency',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 0,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': '1.00',
+		'depends_on': None,
+		'description': "Rate at which customer's currency is converted to your currency",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'conversion_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 30,
+		'in_filter': None,
+		'label': 'Currency Conversion Rate',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02648',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'conversion_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 31,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05303',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Simple',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': 'Field Descriptions for Quotation Details\n\n<b>Ref Rate: </b>Rate in your selected Price List. Price Lists help you track discounts.\n\n<b>Page Break:</b> If you want to break the page on this item in the Print Format',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'quotation_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 32,
+		'in_filter': None,
+		'label': 'Quotation Details',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02652',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'quotation_details',
+		'oldfieldtype': 'Table',
+		'options': 'Quotation Detail',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '40px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'net_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 33,
+		'in_filter': None,
+		'label': 'Net Total*',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02653',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'net_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 34,
+		'in_filter': None,
+		'label': 'Re-Calculate Values',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02654',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 35,
+		'in_filter': None,
+		'label': 'Note HTML',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05304',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': '<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 36,
+		'in_filter': None,
+		'label': 'Taxes',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05305',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'charge',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 37,
+		'in_filter': None,
+		'label': 'Select Charges Master',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02657',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'charge',
+		'oldfieldtype': 'Link',
+		'options': 'Other Charges',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'icon': None,
+		'idx': 38,
+		'in_filter': None,
+		'label': 'Get Charges',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02658',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'other_charges',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 39,
+		'in_filter': None,
+		'label': 'Other Charges',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02659',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'other_charges',
+		'oldfieldtype': 'Table',
+		'options': 'RV Tax Detail',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 40,
+		'in_filter': None,
+		'label': 'Calculate Charges',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02660',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'other_charges_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 41,
+		'in_filter': None,
+		'label': 'Charges Total*',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02661',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'other_charges_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:17',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'grand_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 42,
+		'in_filter': None,
+		'label': 'Grand Total*',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02662',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'grand_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 43,
+		'in_filter': None,
+		'label': 'Other Charges Calculation',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05306',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 44,
+		'in_filter': None,
+		'label': 'OT Notes',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05307',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': '<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 45,
+		'in_filter': None,
+		'label': 'Totals',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05308',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rounded_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 46,
+		'in_filter': None,
+		'label': 'Rounded Total',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02686',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'rounded_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': 'In Words will be visible once you save the Quotation.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'in_words',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 47,
+		'in_filter': None,
+		'label': 'In Words',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02687',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'in_words',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 48,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05309',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'grand_total_export',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 49,
+		'in_filter': None,
+		'label': 'Grand Total (Export)',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02689',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'grand_total_export',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rounded_total_export',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 50,
+		'in_filter': None,
+		'label': 'Rounded Total (Export)',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02690',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'rounded_total_export',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': 'In Words (Export) will be visible once you save the Quotation.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'in_words_export',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 51,
+		'in_filter': None,
+		'label': 'In Words (Export)',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02691',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'in_words_export',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Add Terms and Conditions for the Quotation like Payment Terms, Validity of Offer etc. You can also prepare a master Term Sheet and use the Template',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 52,
+		'in_filter': None,
+		'label': 'Terms',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05310',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-12-14 10:23:20',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'letter_head',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'icon': None,
+		'idx': 53,
+		'in_filter': None,
+		'label': 'Letter Head',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL04223',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'letter_head',
+		'oldfieldtype': 'Select',
+		'options': 'link:Letter Head',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'tc_name',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 54,
+		'in_filter': None,
+		'label': 'Select Terms',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02666',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'tc_name',
+		'oldfieldtype': 'Link',
+		'options': 'Term',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 55,
+		'in_filter': None,
+		'label': 'Get Terms',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02667',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'get_tc_details',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 56,
+		'in_filter': None,
+		'label': 'Terms HTML',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05311',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': 'You can add Terms and Notes that will be printed in the Transaction',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'terms',
+		'fieldtype': 'Text Editor',
+		'hidden': None,
+		'icon': None,
+		'idx': 57,
+		'in_filter': None,
+		'label': 'Term Details',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02669',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'terms',
+		'oldfieldtype': 'Text Editor',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Filling in additional information about the Quotation will help you analyze your data better.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 58,
+		'in_filter': None,
+		'label': 'More Info',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05312',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'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': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select the relevant company name if you have multiple companies.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 59,
+		'in_filter': 1,
+		'label': 'Company',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02675',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 60,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02676',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'enq_det',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'icon': None,
+		'idx': 61,
+		'in_filter': None,
+		'label': 'Enquiry Detail',
+		'modified': '2011-05-25 12:45:08',
+		'modified_by': 'Guest',
+		'name': 'FL02672',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'enq_det',
+		'oldfieldtype': 'Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'source',
+		'fieldtype': 'Select',
+		'hidden': 0,
+		'icon': None,
+		'idx': 62,
+		'in_filter': None,
+		'label': 'Source',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02673',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'source',
+		'oldfieldtype': 'Select',
+		'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign",
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'campaign',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 63,
+		'in_filter': None,
+		'label': 'Campaign',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02674',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'campaign',
+		'oldfieldtype': 'Link',
+		'options': 'Campaign',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'select_print_heading',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 64,
+		'in_filter': None,
+		'label': 'Select Print Heading',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02683',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'select_print_heading',
+		'oldfieldtype': 'Link',
+		'options': 'Print Heading',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 65,
+		'in_filter': None,
+		'label': 'Cancel Reason',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02677',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'order_lost_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 66,
+		'in_filter': None,
+		'label': 'Order Lost Reason',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02678',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'order_lost_reason',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-25 12:45:09',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 67,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05313',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-20 17:46:40',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your sales person who will contact the customer/lead in future',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_by',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 68,
+		'in_filter': None,
+		'label': 'Next Contact By',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL03767',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_by',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Person',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'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-20 17:46:40',
+		'default': None,
+		'depends_on': None,
+		'description': 'Your sales person will get a reminder on this date to contact the customer/lead',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 69,
+		'in_filter': None,
+		'label': 'Next Contact Date',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL03768',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'contact_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'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-20 17:46:40',
+		'default': None,
+		'depends_on': None,
+		'description': 'Date on which the lead/customer was last contacted',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'last_contact_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 70,
+		'in_filter': None,
+		'label': 'Last Contact Date',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL03769',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'last_contact_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-20 17:46:40',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'to_discuss',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 71,
+		'in_filter': None,
+		'label': 'To Discuss',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL03771',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'to_discuss',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Quotation',
+		'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:09',
+		'default': None,
+		'depends_on': None,
+		'description': 'Keep a track on communications regarding this Quotation. This will help you remember earlier communications in case the Customer comes back again',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 72,
+		'in_filter': None,
+		'label': 'Communication History',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL05314',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'follow_up',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 73,
+		'in_filter': None,
+		'label': 'Follow up',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02694',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'follow_up',
+		'oldfieldtype': 'Table',
+		'options': 'Follow up',
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '40px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'file_list',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'icon': None,
+		'idx': 74,
+		'in_filter': None,
+		'label': 'File List',
+		'modified': '2011-05-25 12:45:09',
+		'modified_by': 'Guest',
+		'name': 'FL02703',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Quotation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/crm/doctype/quotation_detail/__init__.py b/crm/doctype/quotation_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/quotation_detail/__init__.py
diff --git a/crm/doctype/quotation_detail/quotation_detail.txt b/crm/doctype/quotation_detail/quotation_detail.txt
new file mode 100644
index 0000000..1196618
--- /dev/null
+++ b/crm/doctype/quotation_detail/quotation_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': 0, 'creation': '2009-03-12 12:10:03', 'search_fields': None, 'module': 'CRM', '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': 23, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': 'QUOD/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': None, 'name': 'Quotation Detail', '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}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'item_code', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': 0, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Item Code', 'width': '150px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': 0, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01048', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'item_code', 'fieldtype': 'Link', 'options': 'Item', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-21 14:38:24', 'doctype': 'DocField', 'oldfieldname': 'item_name', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Item Name', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01458', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'item_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': 0, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Description', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01049', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'stock_uom', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'UOM', 'width': '100px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01050', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'stock_uom', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'qty', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 0, 'print_hide': 0, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Quantity', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': 0, 'allow_on_submit': None, 'icon': None, 'name': 'FL01052', 'idx': 5, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'qty', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'ref_rate', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Ref Rate', 'width': '100px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01053', 'idx': 6, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'ref_rate', 'fieldtype': 'Currency', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Float', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'adj_rate', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Discount (%)', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01054', 'idx': 7, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'adj_rate', 'fieldtype': 'Float', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'export_rate', 'owner': 'Administrator', 'reqd': 0, 'in_filter': 0, 'print_hide': 0, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Rate', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': 0, 'allow_on_submit': None, 'icon': None, 'name': 'FL01057', 'idx': 8, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'export_rate', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'export_amount', 'owner': 'Administrator', 'reqd': 0, 'in_filter': 0, 'print_hide': 0, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Amount', 'width': '100px', 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': 0, 'allow_on_submit': None, 'icon': None, 'name': 'FL01058', 'idx': 9, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'export_amount', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2010-06-08 11:19:43', 'doctype': 'DocField', 'oldfieldname': 'base_ref_rate', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Ref Rate*', 'width': '100px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05292', 'idx': 10, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'base_ref_rate', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'basic_rate', 'owner': 'Administrator', 'reqd': 0, 'in_filter': 0, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Basic Rate*', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': 0, 'allow_on_submit': None, 'icon': None, 'name': 'FL01055', 'idx': 11, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'basic_rate', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-12 12:10:03', 'doctype': 'DocField', 'oldfieldname': 'amount', 'owner': 'Administrator', 'reqd': 0, 'in_filter': 0, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Amount*', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': 0, 'allow_on_submit': None, 'icon': None, 'name': 'FL01056', 'idx': 12, 'default': '0.00', 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'amount', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-05-26 10:40:03', 'doctype': 'DocField', 'oldfieldname': 'item_group', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Item Group', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL02181', 'idx': 13, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'item_group', 'fieldtype': 'Link', 'options': 'Item Group', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-03-21 14:38:24', 'doctype': 'DocField', 'oldfieldname': 'brand', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Brand', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01457', 'idx': 14, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'brand', 'fieldtype': 'Link', 'options': 'Brand', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2009-04-07 16:38:16', 'doctype': 'DocField', 'oldfieldname': 'item_tax_rate', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Item Tax Rate', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01728', 'idx': 15, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'item_tax_rate', 'fieldtype': 'Small Text', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Check', 'creation': '2009-09-03 15:07:15', 'doctype': 'DocField', 'oldfieldname': 'page_break', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Page Break', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 0, 'permlevel': 0, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': 1, 'icon': None, 'name': 'FL02916', 'idx': 16, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'page_break', 'fieldtype': 'Check', 'options': None, 'report_hide': 1, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-08-05 08:25:32', 'doctype': 'DocField', 'oldfieldname': 'prevdoc_docname', 'owner': 'ashwini@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Against Docname', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05832', 'idx': 17, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:32', 'parenttype': 'DocType', 'fieldname': 'prevdoc_docname', 'fieldtype': 'Data', 'options': None, 'report_hide': 0, 'parentfield': 'fields'}, {'no_copy': 1, 'oldfieldtype': 'Data', 'creation': '2010-08-05 08:25:33', 'doctype': 'DocField', 'oldfieldname': 'prevdoc_doctype', 'owner': 'ashwini@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Against Doctype', 'width': '150px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 1, 'description': None, 'parent': 'Quotation Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05833', 'idx': 18, 'default': None, 'colour': None, 'modified': '2010-08-05 08:25:33', 'parenttype': 'DocType', 'fieldname': 'prevdoc_doctype', 'fieldtype': 'Data', 'options': None, 'report_hide': 0, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/return_detail/__init__.py b/crm/doctype/return_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/return_detail/__init__.py
diff --git a/crm/doctype/return_detail/return_detail.txt b/crm/doctype/return_detail/return_detail.txt
new file mode 100644
index 0000000..51152d4
--- /dev/null
+++ b/crm/doctype/return_detail/return_detail.txt
@@ -0,0 +1,370 @@
+[
+	{
+		'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': '2010-08-08 17:09:19',
+		'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': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': 1,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'Return Detail',
+		'name_case': None,
+		'owner': 'wasim@webnotestech.com',
+		'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': 12
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:19',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': 'Item Code',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02844',
+		'no_copy': None,
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Return Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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:19',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Description',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02845',
+		'no_copy': None,
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Return Detail',
+		'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:20',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'uom',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'UOM',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02848',
+		'no_copy': None,
+		'oldfieldname': 'uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Return Detail',
+		'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:20',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Rate',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02849',
+		'no_copy': None,
+		'oldfieldname': 'rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Return Detail',
+		'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:19',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Qty',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02846',
+		'no_copy': None,
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Return Detail',
+		'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:19',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'returned_qty',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Returned Qty',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02847',
+		'no_copy': None,
+		'oldfieldname': 'returned_qty',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Return Detail',
+		'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-01-21 12:06:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Serial No',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL04415',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Return Detail',
+		'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-01-21 12:06:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'batch_no',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Batch No',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL04416',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Return Detail',
+		'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:19',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'detail_name',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Detail Name',
+		'modified': '2011-02-23 19:09:05',
+		'modified_by': 'Administrator',
+		'name': 'FL02843',
+		'no_copy': None,
+		'oldfieldname': 'detail_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Return Detail',
+		'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/crm/doctype/sales_common/__init__.py b/crm/doctype/sales_common/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/sales_common/__init__.py
diff --git a/crm/doctype/sales_common/sales_common.comp.js b/crm/doctype/sales_common/sales_common.comp.js
new file mode 100644
index 0000000..c03d5df
--- /dev/null
+++ b/crm/doctype/sales_common/sales_common.comp.js
@@ -0,0 +1,74 @@
+
+cur_frm.cscript.load_taxes=function(doc,cdt,cdn){if(doc.customer)return;$c_obj([doc],'load_default_taxes','',function(r,rt){refresh_field('other_charges');});}
+cur_frm.add_fetch('company','default_currency','currency');cur_frm.cscript.customer=function(doc,cdt,cdn){if(doc.customer){if(!doc.company){msgprint("Please select company to proceed");doc.customer='';refresh_field('customer');}else{var callback=function(r,rt){cur_frm.refresh();}
+$c_obj(make_doclist(doc.doctype,doc.name),'get_customer_details','',callback);}}}
+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);}
+cur_frm.cscript.CGHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Customer Group');}
+loadpage('Sales Browser',call_back);}
+cur_frm.cscript.currency=function(doc,cdt,cdn){cur_frm.cscript.price_list_name(doc,cdt,cdn);}
+cur_frm.cscript.price_list_name=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;if(doc.price_list_name&&doc.currency){$c_obj(make_doclist(doc.doctype,doc.name),'get_adj_percent','',function(r,rt){refresh_field(fname);var doc=locals[cdt][cdn];cur_frm.cscript.recalc(doc,3);});}}
+cur_frm.cscript.conversion_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,3);}
+cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query=function(doc,cdt,cdn){if(doc.order_type=='Maintenance')
+return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';else
+return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';}
+cur_frm.cscript.item_code=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;var d=locals[cdt][cdn];if(d.item_code){if(!doc.company){msgprint("Please select company to proceed");d.item_code='';refresh_field('item_code',d.name,fname);}else{var callback=function(r,rt){cur_frm.cscript.recalc(doc,1);}
+get_server_fields('get_item_details',d.item_code,fname,doc,cdt,cdn,1,callback);}}
+if(cur_frm.cscript.custom_item_code){cur_frm.cscript.custom_item_code(doc,cdt,cdn);}}
+cur_frm.cscript.qty=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,1);}
+cur_frm.cscript.adj_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,1);}
+cur_frm.cscript.ref_rate=function(doc,cdt,cdn){var d=locals[cdt][cdn];set_multiple(cur_frm.cscript.tname,d.name,{'export_rate':flt(d.ref_rate)*(100-flt(d.adj_rate))/100},cur_frm.cscript.fname);cur_frm.cscript.recalc(doc,3);}
+cur_frm.cscript.basic_rate=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;var d=locals[cdt][cdn];;if(!d.qty)
+{d.qty=1;refresh_field('qty',d.name,fname);}
+cur_frm.cscript.recalc(doc,2);}
+cur_frm.cscript.export_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,3);}
+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`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';}
+cur_frm.cscript['Get Charges']=function(doc,cdt,cdn){$c_obj(make_doclist(doc.doctype,doc.name),'get_other_charges','',function(r,rt){cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);});}
+cur_frm.cscript.recalc=function(doc,n){if(!n)n=0;doc=locals[doc.doctype][doc.name];var tname=cur_frm.cscript.tname;var fname=cur_frm.cscript.fname;var sales_team=cur_frm.cscript.sales_team_fname;var other_fname=cur_frm.cscript.other_fname;if(!flt(doc.conversion_rate)){doc.conversion_rate=1;refresh_field('conversion_rate');}
+if(n>0)cur_frm.cscript.update_fname_table(doc,tname,fname,n);if(flt(doc.net_total)>0){var cl=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var i=0;i<cl.length;i++){cl[i].total_tax_amount=0;cl[i].total_amount=0;cl[i].tax_amount=0;cl[i].total=0;cl[i].item_wise_tax_detail="";if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type)&&!cl[i].row_id){alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);validated=false;}}
+cur_frm.cscript.calc_other_charges(doc,tname,fname,other_fname);}
+cur_frm.cscript.calc_doc_values(doc,cdt,cdn,tname,fname,other_fname);cl=getchildren('Sales Team',doc.name,sales_team);for(var i=0;i<cl.length;i++){if(cl[i].allocated_percentage){cl[i].allocated_amount=flt(flt(doc.net_total)*flt(cl[i].allocated_percentage)/100);refresh_field('allocated_amount',cl[i].name,sales_team);}}
+doc.in_words='';doc.in_words_export='';refresh_many(['total_discount_rate','total_discount','net_total','total_commission','grand_total','rounded_total','grand_total_export','rounded_total_export','in_words','in_words_export','other_charges','other_charges_total']);if(cur_frm.cscript.custom_recalc)cur_frm.cscript.custom_recalc(doc);}
+cur_frm.cscript.calc_doc_values=function(doc,cdt,cdn,tname,fname,other_fname){doc=locals[doc.doctype][doc.name];var net_total=0;var other_charges_total=0;var cl=getchildren(tname,doc.name,fname);for(var i=0;i<cl.length;i++){net_total+=flt(cl[i].amount);}
+var d=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var j=0;j<d.length;j++){other_charges_total+=flt(d[j].amount);}
+doc.net_total=flt(net_total);doc.other_charges_total=flt(other_charges_total);doc.grand_total=flt(flt(net_total)+flt(other_charges_total));doc.rounded_total=Math.round(doc.grand_total);doc.grand_total_export=flt(flt(doc.grand_total)/flt(doc.conversion_rate));doc.rounded_total_export=Math.round(doc.grand_total_export);doc.total_commission=flt(flt(net_total)*flt(doc.commission_rate)/100);}
+cur_frm.cscript.calc_other_charges=function(doc,tname,fname,other_fname){doc=locals[doc.doctype][doc.name];cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML='<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>';var cl=getchildren(tname,doc.name,fname);var tax=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);var otc=make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area,cl.length+1,tax.length+1,'90%',[],{border:'1px solid #AAA',padding:'2px'});$y(otc,{marginTop:'8px'});var tax_desc={};var tax_desc_rates=[];var net_total=0;for(var i=0;i<cl.length;i++){net_total+=flt(flt(cl[i].qty)*flt(cl[i].basic_rate));var prev_total=flt(cl[i].amount);if(cl[i].item_tax_rate)
+var check_tax=eval('var a='+cl[i].item_tax_rate+';a');$td(otc,i+1,0).innerHTML=cl[i].item_code?cl[i].item_code:cl[i].description;var tax=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);var total=net_total;for(var t=0;t<tax.length;t++){var account=tax[t].account_head;$td(otc,0,t+1).innerHTML=account?account:'';if(cl[i].item_tax_rate&&check_tax[account]!=null){rate=flt(check_tax[account]);}
+else
+rate=flt(tax[t].rate);var tax_amount=cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t,cl[i],rate);item_wise_tax_detail=cur_frm.cscript.get_item_wise_tax_detail(doc,rate,cl,i,tax,t);if(tax[t].charge_type!="Actual")tax[t].item_wise_tax_detail+=item_wise_tax_detail;tax[t].total_amount=flt(tax_amount.toFixed(2));tax[t].total_tax_amount=flt(prev_total.toFixed(2));tax[t].tax_amount+=flt(tax_amount.toFixed(2));var total_amount=flt(tax[t].tax_amount);total_tax_amount=flt(tax[t].total_tax_amount)+flt(total_amount);set_multiple('RV Tax Detail',tax[t].name,{'item_wise_tax_detail':tax[t].item_wise_tax_detail,'amount':total_amount,'total':flt(total)+flt(tax[t].tax_amount)},other_fname);prev_total+=flt(tax[t].total_amount);total+=flt(tax[t].tax_amount);if(tax[t].charge_type=='Actual')
+$td(otc,i+1,t+1).innerHTML=fmt_money(tax[t].total_amount);else
+$td(otc,i+1,t+1).innerHTML='('+fmt_money(rate)+'%) '+fmt_money(tax[t].total_amount);}}}
+cur_frm.cscript.check_charge_type_and_get_tax_amount=function(doc,tax,t,cl,rate,print_amt){doc=locals[doc.doctype][doc.name];if(!print_amt)print_amt=0;var tax_amount=0;if(tax[t].charge_type=='Actual'){var value=flt(tax[t].rate)/flt(doc.net_total);return tax_amount=flt(value)*flt(cl.amount);}
+else if(tax[t].charge_type=='On Net Total'){if(flt(print_amt)==1){doc.excise_rate=flt(rate);doc.total_excise_rate+=flt(rate);refresh_field('excise_rate');refresh_field('total_excise_rate');return}
+return tax_amount=(flt(rate)*flt(cl.amount)/100);}
+else if(tax[t].charge_type=='On Previous Row Amount'){if(flt(print_amt)==1){doc.total_excise_rate+=flt(flt(doc.excise_rate)*0.01*flt(rate));refresh_field('total_excise_rate');return}
+var row_no=(tax[t].row_id).toString();var row=(row_no).split("+");for(var r=0;r<row.length;r++){var id=cint(row[r].replace(/^\s+|\s+$/g,""));tax_amount+=(flt(rate)*flt(tax[id-1].total_amount)/100);}
+var row_id=row_no.indexOf("/");if(row_id!=-1){rate='';var row=(row_no).split("/");if(row.length>2)alert("You cannot enter more than 2 nos. for division");var id1=cint(row[0].replace(/^\s+|\s+$/g,""));var id2=cint(row[1].replace(/^\s+|\s+$/g,""));tax_amount=flt(tax[id1-1].total_amount)/flt(tax[id2-1].total_amount);}
+return tax_amount}
+else if(tax[t].charge_type=='On Previous Row Total'){if(flt(print_amt)==1){doc.sales_tax_rate+=flt(rate);refresh_field('sales_tax_rate');return}
+var row=cint(tax[t].row_id);return tax_amount=flt(rate)*(flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount))/100;}}
+cur_frm.cscript.update_fname_table=function(doc,tname,fname,n){doc=locals[doc.doctype][doc.name]
+var net_total=0
+var cl=getchildren(tname,doc.name,fname);for(var i=0;i<cl.length;i++){if(n==1){if(flt(cl[i].ref_rate)>0)
+set_multiple(tname,cl[i].name,{'export_rate':flt(flt(cl[i].ref_rate)*(100-flt(cl[i].adj_rate))/100)},fname);set_multiple(tname,cl[i].name,{'export_amount':flt(flt(cl[i].qty)*flt(cl[i].export_rate)),'basic_rate':flt(flt(cl[i].export_rate)*flt(doc.conversion_rate)),'amount':flt((flt(cl[i].export_rate)*flt(doc.conversion_rate))*flt(cl[i].qty))},fname);}
+else if(n==2){if(flt(cl[i].ref_rate)>0)
+set_multiple(tname,cl[i].name,{'adj_rate':100-flt(flt(cl[i].basic_rate)*100/(flt(cl[i].ref_rate)*flt(doc.conversion_rate)))},fname);set_multiple(tname,cl[i].name,{'amount':flt(flt(cl[i].qty)*flt(cl[i].basic_rate)),'export_rate':flt(flt(cl[i].basic_rate)/flt(doc.conversion_rate)),'export_amount':flt((flt(cl[i].basic_rate)/flt(doc.conversion_rate))*flt(cl[i].qty))},fname);}
+else if(n==3){set_multiple(tname,cl[i].name,{'basic_rate':flt(flt(cl[i].export_rate)*flt(doc.conversion_rate))},fname);set_multiple(tname,cl[i].name,{'amount':flt(flt(cl[i].basic_rate)*flt(cl[i].qty)),'export_amount':flt(flt(cl[i].export_rate)*flt(cl[i].qty))},fname);if(cl[i].ref_rate>0)
+set_multiple(tname,cl[i].name,{'adj_rate':100-flt(flt(cl[i].export_rate)*100/flt(cl[i].ref_rate)),'base_ref_rate':flt(flt(cl[i].ref_rate)*flt(doc.conversion_rate))},fname);}
+net_total+=flt(flt(cl[i].qty)*flt(cl[i].basic_rate));}
+doc.net_total=net_total;refresh_field('net_total');}
+cur_frm.cscript.get_item_wise_tax_detail=function(doc,rate,cl,i,tax,t){doc=locals[doc.doctype][doc.name];var detail='';detail=cl[i].item_code+" : "+cstr(rate)+NEWLINE;return detail;}
+cur_frm.cscript['Re-Calculate Values']=function(doc,cdt,cdn){cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);}
+cur_frm.cscript['Calculate Charges']=function(doc,cdt,cdn){var other_fname=cur_frm.cscript.other_fname;var cl=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var i=0;i<cl.length;i++){cl[i].total_tax_amount=0;cl[i].total_amount=0;cl[i].tax_amount=0;cl[i].total=0;if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type)&&!cl[i].row_id){alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);validated=false;}}
+cur_frm.cscript.recalc(doc,1);}
+cur_frm.cscript.sales_partner=function(doc,cdt,cdn){if(doc.sales_partner){get_server_fields('get_comm_rate',doc.sales_partner,'',doc,cdt,cdn,1);}}
+cur_frm.cscript.commission_rate=function(doc,cdt,cdn){if(doc.commission_rate>100){alert("Commision rate cannot be greater than 100.");doc.total_commission=0;doc.commission_rate=0;}
+else
+doc.total_commission=doc.net_total*doc.commission_rate/100;refresh_many(['total_commission','commission_rate']);}
+cur_frm.cscript.total_commission=function(doc,cdt,cdn){if(doc.net_total){if(doc.net_total<doc.total_commission){alert("Total commission cannot be greater than net total.");doc.total_commission=0;doc.commission_rate=0;}
+else
+doc.commission_rate=doc.total_commission*100/doc.net_total;refresh_many(['total_commission','commission_rate']);}}
+cur_frm.cscript.allocated_percentage=function(doc,cdt,cdn){var fname=cur_frm.cscript.sales_team_fname;var d=locals[cdt][cdn];if(d.allocated_percentage){d.allocated_amount=flt(flt(doc.net_total)*flt(d.allocated_percentage)/100);refresh_field('allocated_amount',d.name,fname);}}
+cur_frm.cscript.validate=function(doc,cdt,cdn){cur_frm.cscript.validate_items(doc);var cl=getchildren('Other Charges',doc.name,'other_charges');for(var i=0;i<cl.length;i++){if(!cl[i].amount){alert("Please Enter Amount in Row no. "+cl[i].idx+" in Other Charges table");validated=false;}}
+cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);if(cur_frm.cscript.calc_adjustment_amount)cur_frm.cscript.calc_adjustment_amount(doc);}
+cur_frm.cscript.validate_items=function(doc){var cl=getchildren(cur_frm.cscript.tname,doc.name,cur_frm.cscript.fname);if(!cl.length){alert("Please enter Items for "+doc.doctype);validated=false;}}
\ No newline at end of file
diff --git a/crm/doctype/sales_common/sales_common.js b/crm/doctype/sales_common/sales_common.js
new file mode 100644
index 0000000..f4b3f02
--- /dev/null
+++ b/crm/doctype/sales_common/sales_common.js
@@ -0,0 +1,479 @@
+// Preset
+// ------
+// cur_frm.cscript.tname - Details table name
+// cur_frm.cscript.fname - Details fieldname
+// cur_frm.cscript.other_fname - Other Charges fieldname
+// cur_frm.cscript.sales_team_fname - Sales Team fieldname
+
+
+// ============== Load Default Taxes ===================
+cur_frm.cscript.load_taxes = function(doc, cdt, cdn) {
+  // run if this is not executed from dt_map...
+  if(doc.customer) return;
+  $c_obj([doc],'load_default_taxes','',function(r,rt){
+     refresh_field('other_charges');
+  });
+}
+
+
+// -----------------
+// Shipping Address
+// -----------------
+//cur_frm.add_fetch('ship_det_no', 'shipping_address', 'shipping_address');
+//cur_frm.add_fetch('ship_det_no', 'ship_to', 'ship_to');
+cur_frm.add_fetch('company', 'default_currency', 'currency');
+
+
+// ============== Customer and its primary contact Details ============================
+cur_frm.cscript.customer = function(doc, cdt, cdn) {
+  if(doc.customer){
+    if (!doc.company) {
+      msgprint("Please select company to proceed");
+      doc.customer = '';
+      refresh_field('customer');
+    } else {
+      var callback = function(r, rt){
+	    	cur_frm.refresh();
+      }
+      $c_obj(make_doclist(doc.doctype, doc.name), 'get_customer_details', '',callback);
+    }
+  }
+}
+
+//====================opens territory tree page ==================
+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);
+}
+
+//====================opens customer group tree page ==================
+cur_frm.cscript.CGHelp = function(doc,dt,dn){
+	var call_back = function(){
+		var sb_obj = new SalesBrowser();				
+		sb_obj.set_val('Customer Group');
+	}
+	loadpage('Sales Browser',call_back);
+}
+
+/*
+// ============= Customer's Contact Person Details =====================================
+cur_frm.cscript.contact_person = function(doc, cdt, cdn) {
+  var callback = function(){
+    refresh_many(['contact_no','email_id','customer_mobile_no','customer_address']);
+  }
+  get_server_fields('get_contact_details','','',doc, cdt, cdn, 1, callback);
+}
+*/
+
+// TRIGGERS FOR CALCULATIONS
+// =====================================================================================================
+
+// ********************* CURRENCY ******************************
+cur_frm.cscript.currency = function(doc, cdt, cdn) {     
+	cur_frm.cscript.price_list_name(doc, cdt, cdn);
+}
+
+// ******************** PRICE LIST ******************************
+cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
+  var fname = cur_frm.cscript.fname;
+  if(doc.price_list_name && doc.currency) {
+    $c_obj(make_doclist(doc.doctype, doc.name), 'get_adj_percent', '',
+      function(r, rt) {
+        refresh_field(fname);
+        var doc = locals[cdt][cdn];
+        cur_frm.cscript.recalc(doc,3);    //this is to re-calculate BASIC RATE and AMOUNT on basis of changed REF RATE
+      }
+    );
+  }
+}
+
+
+// ******************* CONVERSION RATE ***************************
+cur_frm.cscript.conversion_rate = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 3);/*cur_frm.cscript.price_list_name(doc, cdt, cdn);*/ }
+
+// ******************** ITEM CODE ******************************** 
+cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
+  if (doc.order_type == 'Maintenance')
+    return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
+  else 
+    return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
+}
+
+
+
+cur_frm.cscript.item_code = function(doc, cdt, cdn) {
+  var fname = cur_frm.cscript.fname;
+  var d = locals[cdt][cdn];
+  if (d.item_code) {
+    if (!doc.company) {
+      msgprint("Please select company to proceed");
+      d.item_code = '';
+      refresh_field('item_code', d.name, fname);
+    } else {
+      var callback = function(r, rt){
+        cur_frm.cscript.recalc(doc, 1);
+      }
+      get_server_fields('get_item_details',d.item_code, fname,doc,cdt,cdn,1,callback);
+    }
+  }
+  if(cur_frm.cscript.custom_item_code){
+  	cur_frm.cscript.custom_item_code(doc, cdt, cdn);
+  }
+}
+
+// *********************** QUANTITY ***************************
+cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
+  
+// ************************ DISCOUNT (%) ***********************
+cur_frm.cscript.adj_rate = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
+
+// ************************ REF RATE ****************************
+cur_frm.cscript.ref_rate = function(doc, cdt, cdn){
+  var d = locals[cdt][cdn];
+  set_multiple(cur_frm.cscript.tname, d.name, {'export_rate': flt(d.ref_rate) * (100 - flt(d.adj_rate)) / 100}, cur_frm.cscript.fname);
+  cur_frm.cscript.recalc(doc, 3);
+}
+
+// *********************** BASIC RATE **************************
+cur_frm.cscript.basic_rate = function(doc, cdt, cdn) { 
+  var fname = cur_frm.cscript.fname;
+  var d = locals[cdt][cdn];;
+  if(!d.qty)
+  {
+    d.qty = 1;
+    refresh_field('qty', d.name, fname);
+
+  }
+  cur_frm.cscript.recalc(doc, 2); 
+}
+
+// ************************ EXPORT RATE *************************
+cur_frm.cscript.export_rate = function(doc,cdt,cdn) { cur_frm.cscript.recalc(doc, 3);}
+
+// ************* GET OTHER CHARGES BASED ON COMPANY *************
+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`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
+}
+
+// ********************* Get Charges ****************************
+cur_frm.cscript['Get Charges'] = function(doc, cdt, cdn) {
+   $c_obj(make_doclist(doc.doctype,doc.name),'get_other_charges','', function(r, rt) { cur_frm.cscript['Calculate Charges'](doc, cdt, cdn);});
+}
+
+
+// CALCULATION OF TOTAL AMOUNTS
+// ======================================================================================================== 
+cur_frm.cscript.recalc = function(doc, n) {
+  if(!n)n=0;
+  doc = locals[doc.doctype][doc.name];
+  var tname = cur_frm.cscript.tname;
+  var fname = cur_frm.cscript.fname;
+  var sales_team = cur_frm.cscript.sales_team_fname;
+  var other_fname  = cur_frm.cscript.other_fname;
+  
+  if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); }
+
+  if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n); // updates all values in table (i.e. amount, export amount, net total etc.)
+  
+  if(flt(doc.net_total) > 0) {
+    var cl = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
+    for(var i = 0; i<cl.length; i++){
+      cl[i].total_tax_amount = 0;
+      cl[i].total_amount = 0;
+      cl[i].tax_amount = 0;                    // this is done to calculate other charges
+      cl[i].total = 0;
+      cl[i].item_wise_tax_detail = "";
+      if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
+        alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
+        validated = false;
+      }
+    }
+    cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
+  }
+  cur_frm.cscript.calc_doc_values(doc, cdt, cdn, tname, fname, other_fname); // calculates total amounts
+
+  // ******************* calculate allocated amount of sales person ************************
+  cl = getchildren('Sales Team', doc.name, sales_team);
+  for(var i=0;i<cl.length;i++) {
+    if (cl[i].allocated_percentage) {
+      cl[i].allocated_amount = flt(flt(doc.net_total)*flt(cl[i].allocated_percentage)/100);
+      refresh_field('allocated_amount', cl[i].name, sales_team);
+    }
+  }
+  doc.in_words = '';
+  doc.in_words_export = '';
+  refresh_many(['total_discount_rate','total_discount','net_total','total_commission','grand_total','rounded_total','grand_total_export','rounded_total_export','in_words','in_words_export','other_charges','other_charges_total']);
+  if(cur_frm.cscript.custom_recalc)cur_frm.cscript.custom_recalc(doc);
+}
+
+// ******* Calculation of total amounts of document (item amount + other charges)****************
+cur_frm.cscript.calc_doc_values = function(doc, cdt, cdn, tname, fname, other_fname) {
+  doc = locals[doc.doctype][doc.name];
+  var net_total = 0; var other_charges_total = 0;
+  var cl = getchildren(tname, doc.name, fname);
+  for(var i = 0; i<cl.length; i++){
+    net_total += flt(cl[i].amount);
+  }
+  var d = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
+  for(var j = 0; j<d.length; j++){
+    other_charges_total += flt(d[j].amount);
+  }
+  doc.net_total = flt(net_total);
+  doc.other_charges_total = flt(other_charges_total);
+  doc.grand_total = flt(flt(net_total) + flt(other_charges_total));
+  doc.rounded_total = Math.round(doc.grand_total);
+  doc.grand_total_export = flt(flt(doc.grand_total) / flt(doc.conversion_rate));
+  doc.rounded_total_export = Math.round(doc.grand_total_export);
+  doc.total_commission = flt(flt(net_total) * flt(doc.commission_rate) / 100);
+}
+
+// ******************************* OTHER CHARGES *************************************
+cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) {
+  doc = locals[doc.doctype][doc.name];
+  // make display area
+  // ------------------
+
+  cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>';
+  var cl = getchildren(tname, doc.name, fname);
+  var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
+  // make display table
+  // ------------------
+  var otc = make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'});
+  $y(otc,{marginTop:'8px'});
+  
+  var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
+  
+  
+  for(var i=0;i<cl.length;i++) {
+    net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
+    var prev_total = flt(cl[i].amount);
+    if(cl[i].item_tax_rate)
+      var check_tax = eval('var a='+cl[i].item_tax_rate+';a');        //to get in dictionary
+    
+    // Add Item Code in new Row 
+    //--------------------------
+    $td(otc,i+1,0).innerHTML = cl[i].item_code ? cl[i].item_code : cl[i].description;
+    
+    var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
+    var total = net_total;
+    
+    for(var t=0;t<tax.length;t++){
+     
+      var account = tax[t].account_head;
+      $td(otc,0,t+1).innerHTML = account?account:'';
+      //Check For Rate
+      if(cl[i].item_tax_rate && check_tax[account]!=null)  {rate = flt(check_tax[account]);}
+      else               // if particular item doesn't have particular rate it will take other charges rate
+        rate = flt(tax[t].rate);
+      //Check For Rate and get tax amount
+      var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);
+      
+      //enter item_wise_tax_detail i.e. tax rate on each item
+      
+      item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail( doc, rate, cl, i, tax, t);
+      
+      // this is calculation part for all types
+      if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
+      tax[t].total_amount = flt(tax_amount.toFixed(2));     //stores actual tax amount in virtual field
+      tax[t].total_tax_amount = flt(prev_total.toFixed(2));      //stores total amount in virtual field
+      tax[t].tax_amount += flt(tax_amount.toFixed(2));       
+      var total_amount = flt(tax[t].tax_amount);
+      total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
+      set_multiple('RV Tax Detail', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)+flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname);
+      prev_total += flt(tax[t].total_amount);   // for previous row total
+      total += flt(tax[t].tax_amount);     // for adding total to previous amount
+      
+      if(tax[t].charge_type == 'Actual')
+        $td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount);
+      else
+        $td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount);
+      
+    }
+  }
+}
+cur_frm.cscript.check_charge_type_and_get_tax_amount = function( doc, tax, t, cl, rate, print_amt) {
+  doc = locals[doc.doctype][doc.name];
+  if (! print_amt) print_amt = 0;
+  var tax_amount = 0;
+  if(tax[t].charge_type == 'Actual') {
+    var value = flt(tax[t].rate) / flt(doc.net_total);   // this give the ratio in which all items are divided           
+    return tax_amount = flt(value) * flt(cl.amount);
+   }   
+  else if(tax[t].charge_type == 'On Net Total') {
+    if (flt(print_amt) == 1) {
+      doc.excise_rate = flt(rate);
+      doc.total_excise_rate += flt(rate);
+      refresh_field('excise_rate');
+      refresh_field('total_excise_rate');
+      return
+    }
+    return tax_amount = (flt(rate) * flt(cl.amount) / 100);
+  }
+  else if(tax[t].charge_type == 'On Previous Row Amount'){
+    if(flt(print_amt) == 1) {
+      doc.total_excise_rate += flt(flt(doc.excise_rate) * 0.01 * flt(rate));
+      refresh_field('total_excise_rate');
+      return
+    }
+    var row_no = (tax[t].row_id).toString();
+    var row = (row_no).split("+");      // splits the values and stores in an array
+    for(var r = 0;r<row.length;r++){
+      var id = cint(row[r].replace(/^\s+|\s+$/g,""));
+      tax_amount += (flt(rate) * flt(tax[id-1].total_amount) / 100);
+    }
+    var row_id = row_no.indexOf("/");
+    if(row_id != -1) {
+      rate = '';
+      var row = (row_no).split("/");      // splits the values and stores in an array
+      if(row.length>2) alert("You cannot enter more than 2 nos. for division");
+      var id1 = cint(row[0].replace(/^\s+|\s+$/g,""));
+      var id2 = cint(row[1].replace(/^\s+|\s+$/g,""));
+      tax_amount = flt(tax[id1-1].total_amount) / flt(tax[id2-1].total_amount);
+    }
+    return tax_amount
+  }
+  else if(tax[t].charge_type == 'On Previous Row Total') {
+    if(flt(print_amt) == 1) {
+      doc.sales_tax_rate += flt(rate);
+      refresh_field('sales_tax_rate');
+      return
+    }
+    var row = cint(tax[t].row_id);
+    return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount)) / 100;
+  }
+}
+
+// ********************** Update values in table ******************************
+cur_frm.cscript.update_fname_table = function(doc , tname , fname , n) {
+  doc = locals[doc.doctype][doc.name] 
+  var net_total = 0
+  var cl = getchildren(tname, doc.name, fname);
+  for(var i=0;i<cl.length;i++) {
+    if(n == 1){
+      if(flt(cl[i].ref_rate) > 0)
+        set_multiple(tname, cl[i].name, {'export_rate': flt(flt(cl[i].ref_rate) * (100 - flt(cl[i].adj_rate)) / 100)}, fname);
+      set_multiple(tname, cl[i].name, {'export_amount': flt(flt(cl[i].qty) * flt(cl[i].export_rate)), 'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate)), 'amount': flt((flt(cl[i].export_rate) * flt(doc.conversion_rate)) * flt(cl[i].qty)) }, fname);
+    }
+    else if(n == 2){
+      if(flt(cl[i].ref_rate) > 0)
+        set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].basic_rate)  * 100 / (flt(cl[i].ref_rate) * flt(doc.conversion_rate)))}, fname);
+      set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(cl[i].basic_rate)), 'export_rate': flt(flt(cl[i].basic_rate) / flt(doc.conversion_rate)), 'export_amount': flt((flt(cl[i].basic_rate) / flt(doc.conversion_rate)) * flt(cl[i].qty)) }, fname);
+    }
+    else if(n == 3){
+      set_multiple(tname, cl[i].name, {'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate))}, fname);
+      set_multiple(tname, cl[i].name, {'amount' : flt(flt(cl[i].basic_rate) * flt(cl[i].qty)), 'export_amount': flt(flt(cl[i].export_rate) * flt(cl[i].qty))}, fname);
+      if(cl[i].ref_rate > 0)
+        set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].export_rate) * 100 / flt(cl[i].ref_rate)), 'base_ref_rate': flt(flt(cl[i].ref_rate) * flt(doc.conversion_rate)) }, fname);
+    }
+    net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
+  }
+  doc.net_total = net_total;
+  refresh_field('net_total');
+}
+
+cur_frm.cscript.get_item_wise_tax_detail = function( doc, rate, cl, i, tax, t) {
+  doc = locals[doc.doctype][doc.name];
+  var detail = '';
+  detail = cl[i].item_code + " : " + cstr(rate) + NEWLINE;
+  return detail;
+}
+
+// **************** RE-CALCULATE VALUES ***************************
+
+cur_frm.cscript['Re-Calculate Values'] = function(doc, cdt, cdn) {  
+  cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);
+}
+
+cur_frm.cscript['Calculate Charges'] = function(doc, cdt, cdn) {
+  var other_fname  = cur_frm.cscript.other_fname;
+
+  var cl = getchildren('RV Tax Detail', doc.name, other_fname, doc.doctype);
+  for(var i = 0; i<cl.length; i++){
+    cl[i].total_tax_amount = 0;
+    cl[i].total_amount = 0;
+    cl[i].tax_amount = 0;                    // this is done to calculate other charges
+    cl[i].total = 0;
+    if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
+      alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
+      validated = false;
+    }
+  }
+  cur_frm.cscript.recalc(doc, 1);
+}
+
+// Get Sales Partner Commission
+// =================================================================================
+cur_frm.cscript.sales_partner = function(doc, cdt, cdn){
+  if(doc.sales_partner){
+
+    get_server_fields('get_comm_rate', doc.sales_partner, '', doc, cdt, cdn, 1);
+  }
+}
+
+// *******Commission Rate Trigger (calculates total commission amount)*********
+cur_frm.cscript.commission_rate = function(doc, cdt, cdn) {
+  if(doc.commission_rate > 100){
+    alert("Commision rate cannot be greater than 100.");
+    doc.total_commission = 0;
+    doc.commission_rate = 0;
+  }
+  else
+    doc.total_commission = doc.net_total * doc.commission_rate / 100;
+  refresh_many(['total_commission','commission_rate']);
+
+}
+
+// *******Total Commission Trigger (calculates commission rate)*********
+cur_frm.cscript.total_commission = function(doc, cdt, cdn) {
+  if(doc.net_total){
+    if(doc.net_total < doc.total_commission){
+      alert("Total commission cannot be greater than net total.");
+      doc.total_commission = 0;
+      doc.commission_rate = 0;
+    }
+    else
+      doc.commission_rate = doc.total_commission * 100 / doc.net_total;
+    refresh_many(['total_commission','commission_rate']);
+  }
+}
+// Sales Person Allocated % trigger 
+// ==============================================================================
+cur_frm.cscript.allocated_percentage = function(doc, cdt, cdn) {
+  var fname = cur_frm.cscript.sales_team_fname;
+  var d = locals[cdt][cdn];
+  if (d.allocated_percentage) {
+    d.allocated_amount = flt(flt(doc.net_total)*flt(d.allocated_percentage)/100);
+    refresh_field('allocated_amount', d.name, fname);
+  }
+}
+
+// Client Side Validation
+// =================================================================================
+cur_frm.cscript.validate = function(doc, cdt, cdn) {
+  cur_frm.cscript.validate_items(doc);
+  var cl = getchildren('Other Charges', doc.name, 'other_charges');
+  for(var i =0;i<cl.length;i++) {
+    if(!cl[i].amount) {
+      alert("Please Enter Amount in Row no. "+cl[i].idx+" in Other Charges table");
+      validated = false;
+    }
+  }
+  cur_frm.cscript['Calculate Charges'] (doc, cdt, cdn);
+
+  if (cur_frm.cscript.calc_adjustment_amount) cur_frm.cscript.calc_adjustment_amount(doc);
+}
+
+
+// ************** Atleast one item in document ****************
+cur_frm.cscript.validate_items = function(doc) {
+  var cl = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
+  if(!cl.length){
+    alert("Please enter Items for " + doc.doctype);
+    validated = false;
+  }
+}
+
diff --git a/crm/doctype/sales_common/sales_common.py b/crm/doctype/sales_common/sales_common.py
new file mode 100644
index 0000000..f99853b
--- /dev/null
+++ b/crm/doctype/sales_common/sales_common.py
@@ -0,0 +1,759 @@
+# 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
+
+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.doctype_dict = {
+			'Sales Order'		: 'Sales Order Detail',
+			'Delivery Note'		: 'Delivery Note Detail',
+			'Receivable Voucher':'RV Detail',
+			'Installation Note' : 'Installed Item Details'
+		}
+												 
+		self.ref_doctype_dict= {}
+
+		self.next_dt_detail = {
+			'delivered_qty' : 'Delivery Note Detail',
+			'billed_qty'		: 'RV Detail',
+			'installed_qty' : 'Installed Item Details'}
+
+		self.msg = []
+
+
+	# Get Sales Person Details
+	# ==========================
+	def get_sales_person_details(self, obj):
+		if obj.doc.doctype != 'Quotation':
+			obj.doc.clear_table(obj.doclist,'sales_team')
+			idx = 0
+			for d in sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer):
+				ch = addchild(obj.doc, 'sales_team', 'Sales Team', 1, obj.doclist)
+				ch.sales_person = d and cstr(d[0]) or ''
+				ch.allocated_percentage = d and flt(d[1]) or 0
+				ch.allocated_amount = d and flt(d[2]) or 0
+				ch.incentives = d and flt(d[3]) or 0
+				ch.idx = idx
+				idx += 1
+
+
+	# Get customer's contact person details
+	# ==============================================================
+	def get_contact_details(self, obj = '', primary = 0):
+		cond = " and contact_name = '"+cstr(obj.doc.contact_person)+"'"
+		if primary: cond = " and is_primary_contact = 'Yes'"
+		contact = sql("select contact_name, contact_no, email_id, contact_address from `tabContact` where customer = '%s' and docstatus != 2 %s" %(obj.doc.customer, cond), as_dict = 1)
+		if not contact:
+			return
+		c = contact[0]
+		obj.doc.contact_person = c['contact_name'] or ''
+		obj.doc.contact_no = c['contact_no'] or ''
+		obj.doc.email_id = c['email_id'] or ''
+		obj.doc.customer_mobile_no = c['contact_no'] or ''
+		if c['contact_address']:
+			obj.doc.customer_address = c['contact_address']
+
+
+	# Get customer's primary shipping details
+	# ==============================================================
+	def get_shipping_details(self, obj = ''):
+		det = sql("select name, ship_to, shipping_address from `tabShipping Address` where customer = '%s' and docstatus != 2 and ifnull(is_primary_address, 'Yes') = 'Yes'" %(obj.doc.customer), as_dict = 1)
+		obj.doc.ship_det_no = det and det[0]['name'] or ''
+		obj.doc.ship_to = det and det[0]['ship_to'] or ''
+		obj.doc.shipping_address = det and det[0]['shipping_address'] or ''
+
+
+	# get invoice details
+	# ====================
+	def get_invoice_details(self, obj = ''):
+		if obj.doc.company:
+			acc_head = sql("select name from `tabAccount` where name = '%s' and docstatus != 2" % (cstr(obj.doc.customer) + " - " + get_value('Company', obj.doc.company, 'abbr')))
+			obj.doc.debit_to = acc_head and acc_head[0][0] or ''
+
+
+	# Get Customer Details along with its primary contact details
+	# ==============================================================
+	def get_customer_details(self, obj = '', inv_det_reqd = 1):
+		details = sql("select customer_name,address, territory, customer_group, default_sales_partner, default_commission_rate from `tabCustomer` where name = '%s' and docstatus != 2" %(obj.doc.customer), as_dict = 1)
+		obj.doc.customer_name = details and details[0]['customer_name'] or ''
+		obj.doc.customer_address =	details and details[0]['address'] or ''
+		obj.doc.territory = details and details[0]['territory'] or ''
+		obj.doc.customer_group	=	details and details[0]['customer_group'] or ''
+		obj.doc.sales_partner	 =	details and details[0]['default_sales_partner'] or ''
+		obj.doc.commission_rate =	details and flt(details[0]['default_commission_rate']) or ''
+		if obj.doc.doctype != 'Receivable Voucher':
+			obj.doc.delivery_address =	details and details[0]['address'] or ''
+			self.get_contact_details(obj,primary = 1) # get primary contact details
+		self.get_sales_person_details(obj) # get default sales person details
+
+		if obj.doc.doctype == 'Receivable Voucher' and inv_det_reqd:
+			self.get_invoice_details(obj) # get invoice details
+	
+	
+	# Get Item Details
+	# ===============================================================
+	def get_item_details(self, item_code, obj):
+		if not obj.doc.price_list_name:
+			msgprint("Please Select Price List before selecting Items")
+			raise Exception
+		item = sql("select description, item_name, brand, item_group, stock_uom, default_warehouse, default_income_account, default_sales_cost_center, description_html from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life >	now() or end_of_life = '0000-00-00') and (is_sales_item = 'Yes' or is_service_item = 'Yes')" %(item_code), as_dict=1)
+		tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
+		t = {}
+		for x in tax: t[x[0]] = flt(x[1])
+		ret = {
+			'description'								 : item and item[0]['description_html'] or item[0]['description'],
+			'item_group'									: item and item[0]['item_group'] or '',
+			'item_name'									 : item and item[0]['item_name'] or '',
+			'brand'											 : item and item[0]['brand'] or '',
+			'stock_uom'									 : item and item[0]['stock_uom'] or '',
+			'reserved_warehouse'					: item and item[0]['default_warehouse'] or '',
+			'warehouse'									 : item and item[0]['default_warehouse'] or '',
+			'income_account'							: item and item[0]['default_income_account'] or '',
+			'cost_center'								 : item and item[0]['default_sales_cost_center'] or '',
+			'qty'												 : 1.00,	 # this is done coz if item once fetched is fetched again thn its qty shld be reset to 1
+			'adj_rate'										: 0,
+			'amount'											: 0,
+			'export_amount'							 : 0,
+			'item_tax_rate'							 : str(t),
+			'batch_no'										: ''
+		}
+		if(obj.doc.price_list_name and item):	#this is done to fetch the changed BASIC RATE and REF RATE based on PRICE LIST
+			ref_rate =	self.get_ref_rate(item_code, obj.doc.price_list_name, obj.doc.currency)
+			ret['ref_rate'] = flt(ref_rate)
+			ret['export_rate'] = flt(ref_rate)
+			ret['base_ref_rate'] = flt(ref_rate) * flt(obj.doc.conversion_rate)
+			ret['basic_rate'] = flt(ref_rate) * flt(obj.doc.conversion_rate)
+			
+		if obj.doc.doctype == 'Receivable Voucher':
+			return ret
+		return str(ret)
+	
+	# ***************** Get Ref rate as entered in Item Master ********************
+	def get_ref_rate(self, item_code, price_list_name, currency):
+		ref_rate = sql("select ref_rate from `tabRef Rate Detail` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, currency))
+		return ref_rate and ref_rate[0][0] or 0
+
+		
+	# ****** Re-calculates Basic Rate & amount based on Price List Selected ******
+	def get_adj_percent(self, obj): 
+		for d in getlist(obj.doclist, obj.fname):
+			ref_rate = self.get_ref_rate(d.item_code,obj.doc.price_list_name,obj.doc.currency)
+			d.adj_rate = 0
+			d.ref_rate = flt(ref_rate)
+			d.basic_rate = flt(ref_rate) * flt(obj.doc.conversion_rate)
+			d.base_ref_rate = flt(ref_rate) * flt(obj.doc.conversion_rate)
+			d.export_rate = flt(ref_rate)
+
+
+	# Load Default Taxes
+	# ====================
+	def load_default_taxes(self, obj):
+		self.get_other_charges(obj,1)
+
+		
+	# Get other charges from Master
+	# =================================================================================
+	def get_other_charges(self,obj,default = 0):
+		obj.doc.clear_table(obj.doclist,'other_charges')
+		if not getlist(obj.doclist, 'other_charges'):
+			if default: add_cond = 'ifnull(t2.is_default,0) = 1'
+			else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
+			idx = 0
+			other_charge = sql("select t1.charge_type,t1.row_id,t1.description,t1.account_head,t1.rate,t1.tax_amount from `tabRV Tax Detail` t1, `tabOther Charges` t2 where t1.parent = t2.name and t2.company = '%s' and %s order by t1.idx" % (obj.doc.company, add_cond), as_dict = 1)
+			for other in other_charge:
+				d =	addchild(obj.doc, 'other_charges', 'RV Tax Detail', 1, obj.doclist)
+				d.charge_type = other['charge_type']
+				d.row_id = other['row_id']
+				d.description = other['description']
+				d.account_head = other['account_head']
+				d.rate = flt(other['rate'])
+				d.tax_amount = flt(other['tax_amount'])
+				d.idx = idx
+				idx += 1
+			
+			
+	# Get TERMS AND CONDITIONS
+	# =======================================================================================
+	def get_tc_details(self,obj):
+		r = sql("select terms from `tabTerm` where name = %s", obj.doc.tc_name)
+		if r: obj.doc.terms = r[0][0]
+
+#---------------------------------------- Get Tax Details -------------------------------#
+	def get_tax_details(self, item_code, obj):
+		tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
+		t = {}
+		for x in tax: t[x[0]] = flt(x[1])
+		ret = {
+			'item_tax_rate'		:	tax and str(t) or ''
+		}
+		return str(ret)
+
+	# Get Serial No Details
+	# ==========================================================================
+	def get_serial_details(self, serial_no, obj):
+		item = sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
+		tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
+		t = {}
+		for x in tax: t[x[0]] = flt(x[1])
+		ret = {
+			'item_code'				: item and item[0]['item_code'] or '',
+			'make'						 : item and item[0]['make'] or '',
+			'label'						: item and item[0]['label'] or '',
+			'brand'						: item and item[0]['brand'] or '',
+			'description'			: item and item[0]['description'] or '',
+			'item_tax_rate'		: str(t)
+		}
+		return str(ret)
+		
+	# Get Commission rate
+	# =======================================================================
+	def get_comm_rate(self, sales_partner, obj):
+
+		comm_rate = sql("select commission_rate from `tabSales Partner` where name = '%s' and docstatus != 2" %(sales_partner), as_dict=1)
+		if comm_rate:
+			total_comm = flt(comm_rate[0]['commission_rate']) * flt(obj.doc.net_total) / 100
+			ret = {
+				'commission_rate'		 :	comm_rate and flt(comm_rate[0]['commission_rate']) or 0,
+				'total_commission'		:	flt(total_comm)
+			}
+			return str(ret)
+		else:
+			msgprint("Business Associate : %s does not exist in the system." % (sales_partner))
+			raise Exception
+
+	
+	# To verify whether rate entered in details table does not exceed max discount %
+	# =======================================================================================
+	def validate_max_discount(self,obj, detail_table):
+		for d in getlist(obj.doclist, detail_table):
+			discount = sql("select max_discount from tabItem where name = '%s'" %(d.item_code),as_dict = 1)
+			if discount and discount[0]['max_discount'] and (flt(d.adj_rate)>flt(discount[0]['max_discount'])):
+				msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code))
+				raise Exception
+
+
+	# Get sum of allocated % of sales person (it should be 100%)
+	# ========================================================================
+	# it indicates % contribution of sales person in sales
+	def get_allocated_sum(self,obj):
+		sum = 0
+		for d in getlist(obj.doclist,'sales_team'):
+			sum += flt(d.allocated_percentage)
+		if (flt(sum) != 100) and getlist(obj.doclist,'sales_team'):
+			msgprint("Total Allocated % of Sales Persons should be 100%")
+			raise Exception
+			
+	# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
+	# ===========================================================================
+	def check_conversion_rate(self, obj):
+		default_currency = get_obj('Manage Account').doc.default_currency
+		company_currency = sql("select default_currency from `tabCompany` where name = '%s'" % obj.doc.company)
+		curr = company_currency and cstr(company_currency[0][0]) or default_currency
+		if (obj.doc.currency == curr and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != curr and flt(obj.doc.conversion_rate) == 1.00):
+			msgprint("Please Enter Appropriate Conversion Rate.")
+			raise Exception
+	
+
+	# Get Tax rate if account type is TAX
+	# =========================================================================
+	def get_rate(self, arg):
+		arg = eval(arg)
+		rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s' and docstatus != 2" %(arg['account_head']), as_dict=1)
+		ret = {'rate' : 0}
+		if arg['charge_type'] == 'Actual' and rate[0]['account_type'] == 'Tax':
+			msgprint("You cannot select ACCOUNT HEAD of type TAX as your CHARGE TYPE is 'ACTUAL'")
+			ret = {
+				'account_head'	:	''
+			}
+		elif rate[0]['account_type'] in ['Tax', 'Chargeable'] and not arg['charge_type'] == 'Actual':
+			ret = {
+				'rate'	:	rate and flt(rate[0]['tax_rate']) or 0
+			}
+		return cstr(ret)
+		
+
+	# Make Packing List from Sales BOM
+	# =======================================================================
+	def has_sales_bom(self, item_code):
+		return sql("select name from `tabSales BOM` where name=%s and docstatus != 2", item_code)
+	
+	def get_sales_bom_items(self, item_code):
+		return sql("select item_code, qty, uom from `tabSales BOM Detail` where parent=%s", item_code)
+
+
+	# --------------
+	# get item list
+	# --------------
+	def get_item_list(self, obj, is_stopped):
+		il = []
+		for d in getlist(obj.doclist,obj.fname):
+			reserved_qty = 0		# used for delivery note
+			qty = flt(d.qty)
+			if is_stopped:
+				qty = flt(d.qty) > flt(d.delivered_qty) and flt(flt(d.qty) - flt(d.delivered_qty)) or 0
+				
+			if d.prevdoc_doctype == 'Sales Order':			# used in delivery note to reduce reserved_qty 
+				# Eg.: if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
+				# But in this case reserved qty should only be reduced by 10 and not 12.
+
+				tot_qty, max_qty, tot_amt, max_amt = self.get_curr_and_ref_doc_details(d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'Sales Order Detail', obj.doc.name, obj.doc.doctype)
+				if((flt(tot_qty) + flt(qty) > flt(max_qty))):
+					reserved_qty = -(flt(max_qty)-flt(tot_qty))
+				else:	
+					reserved_qty = - flt(qty)
+			
+			warehouse = (obj.fname == "sales_order_details") and d.reserved_warehouse or d.warehouse
+			
+			if self.has_sales_bom(d.item_code):
+				for i in self.get_sales_bom_items(d.item_code):
+					il.append([warehouse, i[0], flt(flt(i[1])* qty), reserved_qty, i[2], d.batch_no, d.serial_no])
+			else:
+				il.append([warehouse, d.item_code, qty, reserved_qty, d.stock_uom, d.batch_no, d.serial_no])
+		return il
+
+
+	# -----------------------
+	# add packing list items
+	# -----------------------
+	def get_packing_item_details(self, item):
+		return sql("select item_name, description, stock_uom from `tabItem` where name = %s", item, as_dict = 1)[0]
+
+	def get_bin_qty(self, item, warehouse):
+		det = sql("select actual_qty, projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item, warehouse), as_dict = 1)
+		return det and det[0] or ''
+
+	def add_packing_list_item(self,obj, item_code, qty, warehouse, line):
+		bin = self.get_bin_qty(item_code, warehouse)
+		item = self.get_packing_item_details(item_code)
+		pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Detail', 1, obj.doclist)
+		pi.parent_item = item_code
+		pi.item_code = item_code
+		pi.item_name = item['item_name']
+		pi.parent_detail_docname = line.name
+		pi.description = item['description']
+		pi.uom = item['stock_uom']
+		pi.qty = flt(qty)
+		pi.actual_qty = bin and flt(bin['actual_qty']) or 0
+		pi.projected_qty = bin and flt(bin['projected_qty']) or 0
+		pi.warehouse = warehouse
+		pi.prevdoc_doctype = line.prevdoc_doctype
+		pi.serial_no = cstr(line.serial_no)
+		pi.idx = self.packing_list_idx
+		self.packing_list_idx += 1
+
+
+	# ------------------
+	# make packing list from sales bom if exists or directly copy item with balance
+	# ------------------ 
+	def make_packing_list(self, obj, fname):
+		obj.doc.clear_table(obj.doclist, 'packing_details')
+		self.packing_list_idx = 0
+		for d in getlist(obj.doclist, fname):
+			warehouse = fname == "sales_order_details" and d.reserved_warehouse or d.warehouse
+			if self.has_sales_bom(d.item_code):
+				for i in self.get_sales_bom_items(d.item_code):
+					self.add_packing_list_item(obj, i[0], flt(i[1])*flt(d.qty), warehouse, d)
+			else:
+				self.add_packing_list_item(obj, d.item_code, d.qty, warehouse, d)
+
+
+	# Get total in words
+	# ==================================================================	
+	def get_total_in_words(self, currency, amount):
+		from webnotes.utils import money_in_words
+		return money_in_words(amount, currency)
+		
+
+	# Get month based on date (required in sales person and sales partner)
+	# ========================================================================
+	def get_month(self,date):
+		month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
+		month_idx = cint(cstr(date).split('-')[1])-1
+		return month_list[month_idx]
+		
+		
+	# **** Check for Stop SO as no transactions can be made against Stopped SO. Need to unstop it. ***
+	def check_stop_sales_order(self,obj):
+		for d in getlist(obj.doclist,obj.fname):
+			ref_doc_name = ''
+			if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_doctype == 'Sales Order':
+				ref_doc_name = d.prevdoc_docname
+			elif d.fields.has_key('sales_order') and d.sales_order and not d.delivery_note:
+				ref_doc_name = d.sales_order
+			if ref_doc_name:
+				so_status = sql("select status from `tabSales Order` where name = %s",ref_doc_name)
+				so_status = so_status and so_status[0][0] or ''
+				if so_status == 'Stopped':
+					msgprint("You cannot do any transaction against Sales Order : '%s' as it is Stopped." %(ref_doc_name))
+					raise Exception
+					
+					
+	# ****** Check for Item.is_sales_item = 'Yes' and Item.docstatus != 2 *******
+	def check_active_sales_items(self,obj):
+		for d in getlist(obj.doclist, obj.fname):
+			if d.item_code:		# extra condn coz item_code is not mandatory in RV
+				valid_item = sql("select docstatus,is_sales_item, is_service_item from tabItem where name = %s",d.item_code)
+				if valid_item and valid_item[0][0] == 2:
+					msgprint("Item : '%s' does not exist in system." %(d.item_code))
+					raise Exception
+				sales_item = valid_item and valid_item[0][1] or 'No'
+				service_item = valid_item and valid_item[0][2] or 'No'
+				if sales_item == 'No' and service_item == 'No':
+					msgprint("Item : '%s' is neither Sales nor Service Item"%(d.item_code))
+					raise Exception
+
+
+# **************************************************************************************************************************************************
+
+	def check_credit(self,obj,grand_total):
+		acc_head = sql("select name from `tabAccount` where company = '%s' and master_name = '%s'"%(obj.doc.company, obj.doc.customer))
+		if acc_head:
+			tot_outstanding = 0
+			dbcr = sql("select sum(debit), sum(credit) from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No')='No'" % acc_head[0][0])
+			if dbcr:
+				tot_outstanding = flt(dbcr[0][0])-flt(dbcr[0][1])
+
+			exact_outstanding = flt(tot_outstanding) + flt(grand_total)
+			get_obj('Account',acc_head[0][0]).check_credit_limit(acc_head[0][0], obj.doc.company, exact_outstanding)
+
+	def validate_fiscal_year(self,fiscal_year,transaction_date,dn):
+		fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%fiscal_year)
+		ysd=fy and fy[0][0] or ""
+		yed=add_days(str(ysd),365)
+		if str(transaction_date) < str(ysd) or str(transaction_date) > str(yed):
+			msgprint("%s not within the fiscal year"%(dn))
+			raise Exception
+
+	# Check Approving Authority
+	# -------------------------
+	def check_approving_authority(self, doctype_name, grand_total):
+		det = sql("select amount from `tabApproval Structure` where doctype_name = '%s' and parent = 'Authorization Rules' and amount <= '%s'" % (doctype_name, grand_total))
+		amt_list, auth_users = [], []
+		if det:
+			for x in det:
+				amt_list.append(flt(x[0]))
+			max_amount = max(amt_list)
+			# Get names of all approving authority with max amount
+			for d in sql("select approving_authority from `tabApproval Structure` where doctype_name = '%s' and parent = 'Authorization Rules' and amount = '%s'" % (doctype_name, flt(max_amount))): auth_users.append(d[0])
+			for x in sql("select approving_authority from `tabApproval Structure` where doctype_name = '%s' and parent = 'Authorization Rules' and amount > '%s'" % (doctype_name, grand_total)): auth_users.append(x[0])
+			if not has_common(auth_users, session['data']['profile']['roles']):
+				msgprint("You do not have an authority to submit this %s. Only %s can submit since amount exceeds %s. %s" % (doctype_name, auth_users, get_defaults()['currency'], flt(max_amount)))
+				raise Exception
+
+	# get against document date	self.prevdoc_date_field
+	#-----------------------------
+	def get_prevdoc_date(self, obj):
+		import datetime
+		for d in getlist(obj.doclist, obj.fname):
+			if d.prevdoc_doctype and d.prevdoc_docname:
+				if d.prevdoc_doctype == 'Receivable Voucher':
+					dt = sql("select posting_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
+				else:
+					dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
+				d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''
+
+	def update_prevdoc_detail(self, is_submit, obj):
+		StatusUpdater(obj, is_submit).update()
+
+	# ---------------------------------------------------------------------------------------------
+	# get qty, amount already billed or delivered against curr line item for current doctype
+	# For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV
+	# ---------------------------------------------------------------------------------------------
+	def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype):
+		# Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction
+		if curr_parent_doctype == 'Installation Note':
+			curr_det = sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
+			qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0
+		else:
+			curr_det = sql("select sum(qty), sum(amount) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
+			qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0
+
+		# get total qty of ref doctype
+		ref_det = sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
+		max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0
+
+		return qty, max_qty, amt, max_amt
+
+
+
+
+
+#
+# make item code readonly if (detail no is set)
+#
+
+
+class StatusUpdater:
+	"""
+		Updates the status of the calling records
+		
+		From Delivery Note 
+			- Update Delivered Qty
+			- Update Percent
+			- Validate over delivery
+			
+		From Receivable Voucher 
+			- Update Billed Qty
+			- Update Percent
+			- Validate over billing
+			
+		From Installation Note
+			- Update Installed Qty
+			- Update Percent Qty
+			- Validate over installation
+	"""
+	def __init__(self, obj, is_submit):
+		self.obj = obj # caller object
+		self.is_submit = is_submit
+		self.tolerance = {}
+		self.global_tolerance = None
+	
+	def update(self):
+		self.update_all_qty()
+		self.validate_all_qty()
+	
+	def validate_all_qty(self):
+		"""
+			Validates over-billing / delivery / installation in Delivery Note, Receivable Voucher, Installation Note
+			To called after update_all_qty
+		"""
+		if self.obj.doc.doctype=='Delivery Note':
+			self.validate_qty({
+				'source_dt'		:'Delivery Note Detail',
+				'compare_field'	:'delivered_qty',
+				'target_dt'		:'Sales Order Detail',
+				'join_field'	:'prevdoc_detail_docname'
+			})
+		elif self.obj.doc.doctype=='Receivable Voucher':
+			self.validate_qty({
+				'source_dt'		:'RV Detail',
+				'compare_field'	:'billed_qty',
+				'target_dt'		:'Sales Order Detail',
+				'join_field'	:'so_detail'
+			})
+		elif self.obj.doc.doctype=='Installation Note':
+			self.validate_qty({
+				'source_dt'		:'Installation Item Details',
+				'compare_field'	:'installed_qty',
+				'target_dt'		:'Delivery Note Detail',
+				'join_field'	:'dn_detail'
+			}, no_tolerance =1);
+
+	
+	def get_tolerance_for(self, item_code):
+		"""
+			Returns the tolerance for the item, if not set, returns global tolerance
+		"""
+		if self.tolerance.get(item_code):
+			return self.tolerance[item_code]
+		
+		tolerance = flt(get_value('Item',item_code,'tolerance') or 0)
+
+		if not(tolerance):
+			if self.global_tolerance == None:
+				self.global_tolerance = flt(get_value('Manage Account',None,'tolerance') or 0)
+			tolerance = self.global_tolerance
+		
+		self.tolerance[item_code] = tolerance
+		return tolerance
+		
+	def check_overflow_with_tolerance(self, item, args):
+		"""
+			Checks if there is overflow condering a relaxation tolerance
+		"""
+		
+		# check if overflow is within tolerance
+		tolerance = self.get_tolerance_for(item['item_code'])
+		overflow_percent = ((item[args['compare_field']] - item['qty']) / item['qty'] * 100)
+	
+		if overflow_percent - tolerance > 0.0001:
+			item['max_allowed'] = flt(item['qty'] * (100+tolerance)/100)
+			item['reduce_by'] = cint(item[args['compare_field']] - item['max_allowed'])
+		
+			msgprint("""
+				Row #%(idx)s: Max qty allowed for <b>Item %(item_code)s</b> against <b>%(parenttype)s %(parent)s</b> is <b>%(max_allowed)s</b>. 
+				
+				If you want to increase your overflow tolerance, please increase tolerance %% in Global Defaults or Item master. 
+				
+				Or, you must reduce the qty by %(reduce_by)s""" % item, raise_exception=1)
+
+	def validate_qty(self, args, no_tolerance=None):
+		"""
+			Updates qty at row level
+		"""
+		# get unique transactions to update
+		for d in self.obj.doclist:
+			if d.doctype == args['source_dt']:
+				args['name'] = d.fields[args['join_field']]
+
+				# get all qty where qty > compare_field
+				item = sql("""
+					select item_code, qty, `%(compare_field)s`, parenttype, parent from `tab%(target_dt)s` 
+					where qty < `%(compare_field)s` and name="%(name)s" and docstatus=1
+					""" % args, as_dict=1)
+				
+				if item:
+					item = item[0]
+					item['idx'] = d.idx
+					
+					if no_tolerance:
+						item['reduce_by'] = item[args['compare_field']] - item['qty']
+						msgprint("""
+							Row #%(idx)s: Max qty allowed for <b>Item %(item_code)s</b> against 
+							<b>%(parenttype)s %(parent)s</b> is <b>%(qty)s</b>. 
+							
+							You must reduce the qty by %(reduce_by)s""" % item, raise_exception=1)
+						
+					else:
+						self.check_overflow_with_tolerance(item, args)
+						
+	
+	def update_all_qty(self):
+		"""
+			Updates delivered / billed / installed qty in Sales Order & Delivery Note
+		"""
+		if self.obj.doc.doctype=='Delivery Note':
+			self.update_qty({
+				'target_field'			:'delivered_qty',
+				'target_dt'				:'Sales Order Detail',
+				'target_parent_dt'		:'Sales Order',
+				'target_parent_field'	:'per_delivered',
+				'source_dt'				:'Delivery Note Detail',
+				'source_field'			:'qty',
+				'join_field'			:'prevdoc_detail_docname',
+				'percent_join_field'	:'prevdoc_docname',
+				'status_field'			:'delivery_status',
+				'keyword'				:'Delivered'
+			})
+			
+		elif self.obj.doc.doctype=='Receivable Voucher':
+			self.update_qty({
+				'target_field'			:'billed_qty',
+				'target_dt'				:'Sales Order Detail',
+				'target_parent_dt'		:'Sales Order',
+				'target_parent_field'	:'per_billed',
+				'source_dt'				:'RV Detail',
+				'source_field'			:'qty',
+				'join_field'			:'so_detail',
+				'percent_join_field'	:'sales_order',
+				'status_field'			:'billing_status',
+				'keyword'				:'Billed'
+			})
+
+			self.update_qty({
+				'target_field'			:'billed_qty',
+				'target_dt'				:'Delivery Note Detail',
+				'target_parent_dt'		:'Delivery Note',
+				'target_parent_field'	:'per_billed',
+				'source_dt'				:'RV Detail',
+				'source_field'			:'qty',
+				'join_field'			:'dn_detail',
+				'percent_join_field'	:'delivery_note',
+				'status_field'			:'billing_status',
+				'keyword'				:'Billed'
+			})
+
+		if self.obj.doc.doctype=='Installation Note':
+			self.update_qty({
+				'target_field'			:'installed_qty',
+				'target_dt'				:'Delivery Note Detail',
+				'target_parent_dt'		:'Delivery Note',
+				'target_parent_field'	:'per_installed',
+				'source_dt'				:'Installed Item Details',
+				'source_field'			:'qty',
+				'join_field'			:'prevdoc_detail_docname',
+				'percent_join_field'	:'prevdoc_docname',
+				'status_field'			:'installation_status',
+				'keyword'				:'Installed'
+			})
+
+
+	def update_qty(self, args):
+		"""
+			Updates qty at row level
+		"""
+		# condition to include current record (if submit or no if cancel)
+		if self.is_submit:
+			args['cond'] = ' or parent="%s"' % self.obj.doc.name
+		else:
+			args['cond'] = ' and parent!="%s"' % self.obj.doc.name
+		
+		# update quantities in child table
+		for d in self.obj.doclist:
+			if d.doctype == args['source_dt']:
+				# updates qty in the child table
+				args['detail_id'] = d.fields.get(args['join_field'])
+			
+				if args['detail_id']:
+					sql("""
+						update 
+							`tab%(target_dt)s` 
+						set 
+							%(target_field)s = (select sum(qty) from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s" and (docstatus=1 %(cond)s))
+						where
+							name="%(detail_id)s"
+					""" % args)			
+		
+		# get unique transactions to update
+		for name in set([d.fields.get(args['percent_join_field']) for d in self.obj.doclist if d.doctype == args['source_dt']]):
+			if name:
+				args['name'] = name
+				
+				# update percent complete in the parent table
+				if args.get('source_dt')!='Installed Item Details':
+					sql("""
+						update 
+							`tab%(target_parent_dt)s` 
+						set 
+							%(target_parent_field)s = (
+								(select sum(amount) from `tab%(source_dt)s` where `%(percent_join_field)s`="%(name)s" and (docstatus=1 %(cond)s)) 
+								/ net_total
+								* 100
+							)
+							where
+								name="%(name)s"
+						""" % args)
+				else:
+					sql("""
+						update 
+							`tab%(target_parent_dt)s` 
+						set 
+							%(target_parent_field)s = (
+								(select sum(qty) from `tab%(source_dt)s` where `%(percent_join_field)s`="%(name)s" and (docstatus=1 %(cond)s)) 
+								/ (select sum(qty) from `tab%(target_dt)s` where parent="%(name)s" and docstatus=1) 
+								* 100
+							)
+							where
+								name="%(name)s"
+						""" % args)
+					
+
+				# update field
+				if args['status_field']:
+					sql("""
+						update
+							`tab%(target_parent_dt)s` 
+						set
+							%(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001, 'Not %(keyword)s', 
+									if(%(target_parent_field)s>=99.99, 'Fully %(keyword)s', 'Partly %(keyword)s')
+								)
+						where
+							name="%(name)s"
+					""" % args)
+
diff --git a/crm/doctype/sales_common/sales_common.txt b/crm/doctype/sales_common/sales_common.txt
new file mode 100644
index 0000000..df360cb
--- /dev/null
+++ b/crm/doctype/sales_common/sales_common.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-12-09 15:26:59', 'search_fields': None, 'module': 'CRM', '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': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 342, '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': '', 'name': 'Sales Common', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-30 22:12:20', '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/crm/doctype/sales_order/__init__.py b/crm/doctype/sales_order/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/sales_order/__init__.py
diff --git a/crm/doctype/sales_order/sales_order.js b/crm/doctype/sales_order/sales_order.js
new file mode 100644
index 0000000..48da9ca
--- /dev/null
+++ b/crm/doctype/sales_order/sales_order.js
@@ -0,0 +1,353 @@
+// Module CRM
+
+cur_frm.cscript.tname = "Sales Order Detail";
+cur_frm.cscript.fname = "sales_order_details";
+cur_frm.cscript.other_fname = "other_charges";
+cur_frm.cscript.sales_team_fname = "sales_team";
+
+
+$import(Sales Common)
+$import(Other Charges)
+$import(SMS Control)
+
+
+// ONLOAD
+// ================================================================================================
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
+  if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
+  // load default charges
+  
+  if(doc.__islocal){
+    hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
+  }   
+  
+
+}
+
+cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
+  if(doc.__islocal) {
+    if(doc.quotation) cur_frm.cscript['Pull Quotation Details'](doc,cdt,cdn);
+  } else {
+	cur_frm.cscript.load_taxes(doc, cdt, cdn);
+  } 
+}
+
+// REFRESH
+// ================================================================================================
+cur_frm.cscript.get_open_status = function(doc) {
+  var open_delivery = 0; var open_invoicing=0;
+  var ch = getchildren('Sales Order Detail',doc.name,'sales_order_details');
+  for(var i in ch){
+  	if(ch[i].qty > ch[i].delivered_qty) open_delivery = 1;
+  	if(ch[i].qty > ch[i].billed_qty) open_invoicing = 1;
+    if(ch[i].amount > ch[i].billed_amt) open_invoicing = 1;
+  }	
+  return [open_delivery, open_invoicing];
+}
+
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.clear_custom_buttons();
+  
+  var open_status = cur_frm.cscript.get_open_status(doc);
+  if(doc.docstatus==1) {
+  	if(doc.status != 'Stopped') {
+	    cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+  	  // delivery note
+  	  if(open_status[0] && doc.order_type!='Maintenance')
+        cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
+  	  
+  	  // maintenance
+  	  if(open_status[0] && doc.order_type=='Maintenance') {
+        cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript['Make Maintenance Visit']);
+        cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
+  	  }
+
+      // indent
+      if(doc.order_type != 'Maintenance')
+        cur_frm.add_custom_button('Make Indent', cur_frm.cscript['Make Indent']);
+  	  
+      // sales invoice
+  	  if(open_status[1])
+        cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
+      
+      // stop
+      if(open_status[0] || open_status[1])
+        cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
+  } else {
+  	
+  	  // un-stop
+  	  cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
+  }
+  	
+    unhide_field(['Repair Sales Order', 'Send SMS', 'message', 'customer_mobile_no'])
+  } else {
+  	hide_field(['Repair Sales Order', 'Send SMS', 'message', 'customer_mobile_no'])
+  }
+
+}
+
+//customer
+cur_frm.cscript.customer = function(doc,dt,dn) {
+  var callback = function(r,rt) {
+      var doc = locals[cur_frm.doctype][cur_frm.docname];
+      get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0);
+      cur_frm.refresh();
+  }   
+
+  if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
+  if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
+}
+
+cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {    
+  if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+}
+
+cur_frm.fields_dict.customer_address.on_new = function(dn) {
+  locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+}
+
+cur_frm.fields_dict.contact_person.on_new = function(dn) {
+  locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+  locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+}
+
+cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+cur_frm.cscript['Pull Quotation Details'] = function(doc,dt,dn) {
+  var callback = function(r,rt){
+    var doc = locals[cur_frm.doctype][cur_frm.docname];          
+    if(r.message){              
+      doc.quotation_no = r.message;      
+		  if(doc.quotation_no) {		      
+  			  unhide_field(['quotation_date','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);			    			  
+  			  if(doc.customer) get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0);
+		  }		  
+		  cur_frm.refresh();
+    }
+  } 
+
+ $c_obj(make_doclist(doc.doctype, doc.name),'pull_quotation_details','',callback);
+}
+
+
+//================ create new contact ============================================================================
+cur_frm.cscript.new_contact = function(){
+  tn = createLocal('Contact');
+  locals['Contact'][tn].is_customer = 1;
+  if(doc.customer) locals['Contact'][tn].customer = doc.customer;
+  loaddoc('Contact', tn);
+}
+
+// DOCTYPE TRIGGERS
+// ================================================================================================
+
+/*
+// ***************** get shipping address based on customer selected *****************
+cur_frm.fields_dict['ship_det_no'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabShipping Address`.`name`, `tabShipping Address`.`ship_to`, `tabShipping Address`.`shipping_address` FROM `tabShipping Address` WHERE `tabShipping Address`.customer = "'+ doc.customer+'" AND `tabShipping Address`.`docstatus` != 2 AND `tabShipping Address`.`name` LIKE "%s" ORDER BY `tabShipping Address`.name ASC LIMIT 50';
+}
+*/
+
+
+// ***************** Get project name *****************
+cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
+  var cond = '';
+  if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
+  return repl('SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND %(cond)s `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
+}
+
+//---- get customer details ----------------------------
+cur_frm.cscript.project_name = function(doc,cdt,cdn){
+  $c_obj(make_doclist(doc.doctype, doc.name),'pull_project_customer','', function(r,rt){
+    refresh_many(['customer','customer_name', 'customer_address', 'contact_person', 'territory', 'contact_no', 'email_id', 'customer_group']);
+  });
+  
+}
+
+
+
+// *************** Customized link query for QUOTATION ***************************** 
+cur_frm.fields_dict['quotation_no'].get_query = function(doc) {
+  var cond='';
+  if(doc.order_type) cond = ' ifnull(`tabQuotation`.order_type, "") = "'+doc.order_type+'" and';
+  if(doc.customer) cond += ' ifnull(`tabQuotation`.customer, "") = "'+doc.customer+'" and';
+  
+  return repl('SELECT DISTINCT name, customer, transaction_date  FROM `tabQuotation` WHERE `tabQuotation`.company = "' + doc.company + '" and `tabQuotation`.`docstatus` = 1 and `tabQuotation`.status != "Order Lost" and %(cond)s `tabQuotation`.%(key)s LIKE "%s" ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
+}
+
+
+// SALES ORDER DETAILS TRIGGERS
+// ================================================================================================
+
+// ***************** Get available qty in warehouse of item selected **************** 
+cur_frm.cscript.reserved_warehouse = function(doc, cdt , cdn) {
+  var d = locals[cdt][cdn];
+  if (d.reserved_warehouse) {
+    arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.reserved_warehouse +"'}";
+    get_server_fields('get_available_qty',arg,'sales_order_details',doc,cdt,cdn,1);
+  }
+}
+
+//----------- make maintenance schedule----------
+cur_frm.cscript['Make Maintenance Schedule'] = function() {
+  var doc = cur_frm.doc;
+
+  if (doc.docstatus == 1) { 
+    $c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_schedule','',
+      function(r,rt){
+        if(r.message == 'No'){
+          n = createLocal("Maintenance Schedule");
+          $c('dt_map', args={
+                  'docs':compress_doclist([locals["Maintenance Schedule"][n]]),
+                  'from_doctype':'Sales Order',
+                  'to_doctype':'Maintenance Schedule',
+                  'from_docname':doc.name,
+            'from_to_list':"[['Sales Order', 'Maintenance Schedule'], ['Sales Order Detail', 'Item Maintenance Detail']]"
+          }
+          , function(r,rt) {
+            loaddoc("Maintenance Schedule", n);
+          }
+          );
+        }
+        else{
+          msgprint("You have already created Maintenance Schedule against this Sales Order");
+        }
+      }
+    );
+  }
+}
+
+//------------ make maintenance visit ------------
+cur_frm.cscript['Make Maintenance Visit'] = function() {
+  var doc = cur_frm.doc;
+
+  if (doc.docstatus == 1) { 
+    $c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_visit','',
+      function(r,rt){
+        if(r.message == 'No'){
+          n = createLocal("Maintenance Visit");
+          $c('dt_map', args={
+                  'docs':compress_doclist([locals["Maintenance Visit"][n]]),
+                  'from_doctype':'Sales Order',
+                  'to_doctype':'Maintenance Visit',
+                  'from_docname':doc.name,
+            'from_to_list':"[['Sales Order', 'Maintenance Visit'], ['Sales Order Detail', 'Maintenance Visit Detail']]"
+          }
+          , function(r,rt) {
+            loaddoc("Maintenance Visit", n);
+          }
+          );
+        }
+        else{
+          msgprint("You have already completed maintenance against this Sales Order");
+        }
+      }
+    );
+  }
+}
+
+// make indent
+// ================================================================================================
+cur_frm.cscript['Make Indent'] = function() {
+  var doc = cur_frm.doc;
+  if (doc.docstatus == 1) { 
+  n = createLocal("Indent");
+  $c('dt_map', args={
+          'docs':compress_doclist([locals["Indent"][n]]),
+          'from_doctype':'Sales Order',
+          'to_doctype':'Indent',
+          'from_docname':doc.name,
+    'from_to_list':"[['Sales Order', 'Indent'], ['Sales Order Detail', 'Indent Detail']]"
+  }
+  , function(r,rt) {
+    loaddoc("Indent", n);
+    }
+    );
+  }
+}
+
+
+// MAKE DELIVERY NOTE
+// ================================================================================================
+cur_frm.cscript['Make Delivery Note'] = function() {
+  var doc = cur_frm.doc;
+  if (doc.docstatus == 1) { 
+  n = createLocal("Delivery Note");
+  $c('dt_map', args={
+          'docs':compress_doclist([locals["Delivery Note"][n]]),
+          'from_doctype':'Sales Order',
+          'to_doctype':'Delivery Note',
+          'from_docname':doc.name,
+    'from_to_list':"[['Sales Order', 'Delivery Note'], ['Sales Order Detail', 'Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
+  }
+  , function(r,rt) {
+    loaddoc("Delivery Note", n);
+    }
+    );
+  }
+}
+
+
+// MAKE SALES INVOICE
+// ================================================================================================
+cur_frm.cscript['Make Sales Invoice'] = function() {
+  var doc = cur_frm.doc;
+
+  n = createLocal('Receivable Voucher');
+  $c('dt_map', args={
+    'docs':compress_doclist([locals['Receivable Voucher'][n]]),
+    'from_doctype':doc.doctype,
+    'to_doctype':'Receivable Voucher',
+    'from_docname':doc.name,
+    'from_to_list':"[['Sales Order','Receivable Voucher'],['Sales Order Detail','RV Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
+    }, function(r,rt) {
+       loaddoc('Receivable Voucher', n);
+    }
+  );
+}
+
+
+// STOP SALES ORDER
+// ==================================================================================================
+cur_frm.cscript['Stop Sales Order'] = function() {
+  var doc = cur_frm.doc;
+
+  var check = confirm("Are you sure you want to STOP " + doc.name);
+
+  if (check) {
+    $c('runserverobj', args={'method':'stop_sales_order', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
+      cur_frm.refresh();
+    });
+  }
+}
+
+// UNSTOP SALES ORDER
+// ==================================================================================================
+cur_frm.cscript['Unstop Sales Order'] = function() {
+  var doc = cur_frm.doc;
+
+  var check = confirm("Are you sure you want to UNSTOP " + doc.name);
+
+  if (check) {
+    $c('runserverobj', args={'method':'unstop_sales_order', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
+      cur_frm.refresh();
+    });
+  }
+}
+
+//get query select Territory
+//=======================================================================================================================
+cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
+  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';
+}
+
+
diff --git a/crm/doctype/sales_order/sales_order.py b/crm/doctype/sales_order/sales_order.py
new file mode 100644
index 0000000..e1e15f1
--- /dev/null
+++ b/crm/doctype/sales_order/sales_order.py
@@ -0,0 +1,487 @@
+# 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
+	
+# -----------------------------------------------------------------------------------------
+
+from utilities.transaction_base import TransactionBase
+
+class DocType(TransactionBase):
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    self.tname = 'Sales Order Detail'
+    self.fname = 'sales_order_details'
+    self.person_tname = 'Target Detail'
+    self.partner_tname = 'Partner Target Detail'
+    self.territory_tname = 'Territory Target Detail'
+
+# Autoname
+# ===============
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+
+    
+# DOCTYPE TRIGGER FUNCTIONS
+# =============================
+  # Pull Quotation Details
+  # -----------------------
+  def pull_quotation_details(self):
+    self.doc.clear_table(self.doclist, 'other_charges')
+    self.doc.clear_table(self.doclist, 'sales_order_details')
+    self.doc.clear_table(self.doclist, 'sales_team')
+    self.doc.clear_table(self.doclist, 'tc_details')
+    if self.doc.quotation_no:        
+      get_obj('DocType Mapper', 'Quotation-Sales Order').dt_map('Quotation', 'Sales Order', self.doc.quotation_no, self.doc, self.doclist, "[['Quotation', 'Sales Order'],['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team'],['TC Detail','TC Detail']]")      
+    else:
+      msgprint("Please select Quotation whose details need to pull")    
+
+    return cstr(self.doc.quotation_no)
+  
+  #pull project customer
+  #-------------------------
+  def pull_project_customer(self):
+    res = sql("select customer from `tabProject` where name = '%s'"%self.doc.project_name)
+    if res:
+      get_obj('DocType Mapper', 'Project-Sales Order').dt_map('Project', 'Sales Order', self.doc.project_name, self.doc, self.doclist, "[['Project', 'Sales Order']]")
+      
+  
+  # Get Customer Details
+  # ---------------------
+  #def get_customer_details(self):
+  #  sales_com_obj = get_obj('Sales Common')
+  #  sales_com_obj.get_customer_details(self)
+  #  sales_com_obj.get_shipping_details(self)
+
+  # Get contact person details based on customer selected
+  # ------------------------------------------------------
+  def get_contact_details(self):
+    get_obj('Sales Common').get_contact_details(self,0)
+
+  # Get Commission rate of Sales Partner
+  # -------------------------------------
+  def get_comm_rate(self, sales_partner):
+    return get_obj('Sales Common').get_comm_rate(sales_partner, self)
+
+  # Clear Sales Order Details Table
+  # --------------------------------
+  def clear_sales_order_details(self):
+    self.doc.clear_table(self.doclist, 'sales_order_details')
+    
+
+# SALES ORDER DETAILS TRIGGER FUNCTIONS
+# ================================================================================
+  # Get Item Details
+  # ----------------
+  def get_item_details(self, item_code):
+    return get_obj('Sales Common').get_item_details(item_code, self)
+
+  # Re-calculates Basic Rate & amount based on Price List Selected
+  # --------------------------------------------------------------
+  def get_adj_percent(self, arg=''):
+    get_obj('Sales Common').get_adj_percent(self)
+
+  # Get projected qty of item based on warehouse selected
+  # -----------------------------------------------------
+  def get_available_qty(self,args):
+    args = eval(args)
+    tot_avail_qty = sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
+    ret = {
+       'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
+       'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
+    }
+    return cstr(ret)
+  
+  
+# OTHER CHARGES TRIGGER FUNCTIONS
+# ====================================================================================
+  
+  # Get Tax rate if account type is TAX
+  # ------------------------------------
+  def get_rate(self,arg):
+    return get_obj('Sales Common').get_rate(arg)
+
+  # Load Default Charges
+  # ----------------------------------------------------------
+  def load_default_taxes(self):
+    return get_obj('Sales Common').load_default_taxes(self)
+
+  # Pull details from other charges master (Get Other Charges)
+  # ----------------------------------------------------------
+  def get_other_charges(self):
+    return get_obj('Sales Common').get_other_charges(self)
+ 
+ 
+# GET TERMS & CONDITIONS
+# =====================================================================================
+  def get_tc_details(self):
+    return get_obj('Sales Common').get_tc_details(self)
+
+#check if maintenance schedule already generated
+#============================================
+  def check_maintenance_schedule(self):
+    nm = sql("select t1.name from `tabMaintenance Schedule` t1, `tabItem Maintenance Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1", self.doc.name)
+    nm = nm and nm[0][0] or ''
+    
+    if not nm:
+      return cstr('No')
+
+#check if maintenance visit already generated
+#============================================
+  def check_maintenance_visit(self):
+    nm = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1 and t1.completion_status='Fully Completed'", self.doc.name)
+    nm = nm and nm[0][0] or ''
+    
+    if not nm:
+      return cstr('No')
+
+# VALIDATE
+# =====================================================================================
+  # Fiscal Year Validation
+  # ----------------------
+  def validate_fiscal_year(self):
+    get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Sales Order Date')
+  
+  # Validate values with reference document
+  #----------------------------------------
+  def validate_reference_value(self):
+    get_obj('DocType Mapper', 'Quotation-Sales Order', with_children = 1).validate_reference_value(self, self.doc.name)
+
+  # Validate Mandatory
+  # -------------------
+  def validate_mandatory(self):
+    # validate transaction date v/s delivery date
+    if self.doc.delivery_date:
+      if getdate(self.doc.transaction_date) > getdate(self.doc.delivery_date):
+        msgprint("Expected Delivery Date cannot be before Sales Order Date")
+        raise Exception
+
+  # Validate P.O Date
+  # ------------------
+  def validate_po_date(self):
+    # validate p.o date v/s delivery date
+    if self.doc.po_date and self.doc.delivery_date and getdate(self.doc.po_date) >= getdate(self.doc.delivery_date):
+      msgprint("Expected Delivery Date cannot be before Purchase Order Date")
+      raise Exception  
+    # amendment date is necessary if document is amended
+    if self.doc.amended_from and not self.doc.amendment_date:
+      msgprint("Please Enter Amendment Date")
+      raise Exception
+  
+  # Validations of Details Table
+  # -----------------------------
+  def validate_for_items(self):
+    check_list,flag = [],0
+    chk_dupl_itm = []
+    # Sales Order Details Validations
+    for d in getlist(self.doclist, 'sales_order_details'):
+      if cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname):
+        flag = 1
+      if d.prevdoc_docname:
+        if self.doc.quotation_date and getdate(self.doc.quotation_date) > getdate(self.doc.transaction_date):
+          msgprint("Sales Order Date cannot be before Quotation Date")
+          raise Exception
+        # validates whether quotation no in doctype and in table is same
+        if not cstr(d.prevdoc_docname) == cstr(self.doc.quotation_no):
+          msgprint("Items in table does not belong to the Quotation No mentioned.")
+          raise Exception
+
+      # validates whether item is not entered twice
+      e = [d.item_code, d.description, d.reserved_warehouse, d.prevdoc_docname or '']
+      f = [d.item_code, d.description]
+
+      #check item is stock item
+      st_itm = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
+
+      if st_itm and st_itm[0][0] == 'Yes':
+        if e in check_list:
+          msgprint("Item %s has been entered twice." % d.item_code)
+        else:
+          check_list.append(e)
+      elif st_itm and st_itm[0][0]== 'No':
+        if f in chk_dupl_itm:
+          msgprint("Item %s has been entered twice." % d.item_code)
+        else:
+          chk_dupl_itm.append(f)
+
+      # used for production plan
+      d.transaction_date = self.doc.transaction_date
+      d.delivery_date = self.doc.delivery_date
+
+      # gets total projected qty of item in warehouse selected (this case arises when warehouse is selected b4 item)
+      tot_avail_qty = sql("select projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
+      d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
+    
+    if flag == 0:
+      msgprint("There are no items of the quotation selected.")
+      raise Exception
+
+  # validate sales/ service item against order type
+  #----------------------------------------------------
+  def validate_sales_mntc_item(self):
+    if self.doc.order_type == 'Maintenance':
+      item_field = 'is_service_item'
+      order_type = 'Maintenance Order'
+      item_type = 'service item'
+    else :
+      item_field = 'is_sales_item'
+      order_type = 'Sales Order'
+      item_type = 'sales item'
+    
+    for d in getlist(self.doclist, 'sales_order_details'):
+      res = sql("select %s from `tabItem` where name='%s'"% (item_field,d.item_code))
+      res = res and res[0][0] or 'No'
+      
+      if res == 'No':
+        msgprint("You can not select non "+item_type+" "+d.item_code+" in "+order_type)
+        raise Exception
+  
+  # validate sales/ maintenance quotation against order type
+  #------------------------------------------------------------------
+  def validate_sales_mntc_quotation(self):
+    for d in getlist(self.doclist, 'sales_order_details'):
+      if d.prevdoc_docname:
+        res = sql("select order_type from `tabQuotation` where name=%s", (d.prevdoc_docname))
+        res = res and res[0][0] or ''
+        
+        if self.doc.order_type== 'Maintenance' and res != 'Maintenance':
+          msgprint("You can not select non Maintenance Quotation against Maintenance Order")
+          raise Exception
+        elif self.doc.order_type != 'Maintenance' and res == 'Maintenance':
+          msgprint("You can not select non Sales Quotation against Sales Order")
+          raise Exception
+
+  #do not allow sales item/quotation in maintenance order and service item/quotation in sales order
+  #-----------------------------------------------------------------------------------------------
+  def validate_order_type(self):
+    #validate delivery date
+    if self.doc.order_type != 'Maintenance' and not self.doc.delivery_date:
+      msgprint("Please enter 'Expected Delivery Date'")
+      raise Exception
+    
+    self.validate_sales_mntc_quotation()
+    self.validate_sales_mntc_item()
+
+  #check for does customer belong to same project as entered..
+  #-------------------------------------------------------------------------------------------------
+  def validate_proj_cust(self):
+    if self.doc.project_name and self.doc.customer_name:
+      res = sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, self.doc.customer))
+      if not res:
+        msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.doc.customer,self.doc.project_name,self.doc.project_name))
+        raise Exception
+       
+
+  # Validate
+  # ---------
+  def validate(self):
+    self.validate_fiscal_year()
+    self.validate_order_type()
+    self.validate_mandatory()
+    self.validate_proj_cust()
+    self.validate_po_date()
+    #self.validate_reference_value()
+    self.validate_for_items()
+    sales_com_obj = get_obj(dt = 'Sales Common')
+    sales_com_obj.check_active_sales_items(self)
+    sales_com_obj.check_conversion_rate(self)
+
+        # verify whether rate is not greater than max_discount
+    sales_com_obj.validate_max_discount(self,'sales_order_details')
+        # this is to verify that the allocated % of sales persons is 100%
+    sales_com_obj.get_allocated_sum(self)
+    sales_com_obj.make_packing_list(self,'sales_order_details')
+    
+        # get total in words
+    self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
+    self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
+    
+    # set SO status
+    self.doc.status='Draft'
+    if not self.doc.billing_status: self.doc.billing_status = 'Not Billed'
+    if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered'
+    
+
+# ON SUBMIT
+# ===============================================================================================
+  # Checks Quotation Status
+  # ------------------------
+  def check_prev_docstatus(self):
+    for d in getlist(self.doclist, 'sales_order_details'):
+      cancel_quo = sql("select name from `tabQuotation` where docstatus = 2 and name = '%s'" % d.prevdoc_docname)
+      if cancel_quo:
+        msgprint("Quotation :" + cstr(cancel_quo[0][0]) + " is already cancelled !")
+        raise Exception , "Validation Error. "
+  
+  def update_enquiry_status(self, prevdoc, flag):
+    enq = sql("select t2.prevdoc_docname from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.name=%s", prevdoc)
+    if enq:
+      sql("update `tabEnquiry` set status = %s where name=%s",(flag,enq[0][0]))
+
+  #update status of quotation, enquiry
+  #----------------------------------------
+  def update_prevdoc_status(self, flag):
+    for d in getlist(self.doclist, 'sales_order_details'):
+      if d.prevdoc_docname:
+        if flag=='submit':
+          sql("update `tabQuotation` set status = 'Order Confirmed' where name=%s",d.prevdoc_docname)
+          
+          #update enquiry
+          self.update_enquiry_status(d.prevdoc_docname, 'Order Confirmed')
+        elif flag == 'cancel':
+          chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Detail` t2 where t2.parent = t1.name and t2.prevdoc_docname=%s and t1.name!=%s and t1.docstatus=1", (d.prevdoc_docname,self.doc.name))
+          if not chk:
+            sql("update `tabQuotation` set status = 'Submitted' where name=%s",d.prevdoc_docname)
+            
+            #update enquiry
+            self.update_enquiry_status(d.prevdoc_docname, 'Quotation Sent')
+  
+  # Submit
+  # -------
+  def on_submit(self):
+    self.check_prev_docstatus()    
+    self.update_stock_ledger(update_stock = 1)
+    self.set_sms_msg(1)
+    # update customer's last sales order no.
+    update_customer = sql("update `tabCustomer` set last_sales_order = '%s', modified = '%s' where name = '%s'" %(self.doc.name, self.doc.modified, self.doc.customer))
+    get_obj('Sales Common').check_credit(self,self.doc.grand_total)
+    
+    # Check for Approving Authority
+    get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.grand_total, self)
+    
+    #update prevdoc status
+    self.update_prevdoc_status('submit')
+    # set SO status
+    set(self.doc, 'status', 'Submitted')
+  
+    # on submit notification    
+    if self.doc.email_id:
+      get_obj('Notification Control').notify_contact('Sales Order',self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
+        
+ 
+# ON CANCEL
+# ===============================================================================================
+  def on_cancel(self):
+    # Cannot cancel stopped SO
+    if self.doc.status == 'Stopped':
+      msgprint("Sales Order : '%s' cannot be cancelled as it is Stopped. Unstop it for any further transactions" %(self.doc.name))
+      raise Exception
+    self.check_nextdoc_docstatus()
+    self.update_stock_ledger(update_stock = -1)
+    self.set_sms_msg()
+    
+    #update prevdoc status
+    self.update_prevdoc_status('cancel')
+    
+    # ::::::::: SET SO STATUS ::::::::::
+    set(self.doc, 'status', 'Cancelled')
+    
+  # CHECK NEXT DOCSTATUS
+  # does not allow to cancel document if DN or RV made against it is SUBMITTED 
+  # ----------------------------------------------------------------------------
+  def check_nextdoc_docstatus(self):
+    # Checks Delivery Note
+    submit_dn = sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Detail` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name))
+    if submit_dn:
+      msgprint("Delivery Note : " + cstr(submit_dn[0][0]) + " has been submitted against " + cstr(self.doc.doctype) + ". Please cancel Delivery Note : " + cstr(submit_dn[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
+    # Checks Receivable Voucher
+    submit_rv = sql("select t1.name from `tabReceivable Voucher` t1,`tabRV Detail` t2 where t1.name = t2.parent and t2.sales_order = '%s' and t1.docstatus = 1" % (self.doc.name))
+    if submit_rv:
+      msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Sales Invoice : "+ cstr(submit_rv[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
+    #check maintenance schedule
+    submit_ms = sql("select t1.name from `tabMaintenance Schedule` t1, `tabItem Maintenance Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.doc.name)
+    if submit_ms:
+      msgprint("Maintenance Schedule : " + cstr(submit_ms[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Maintenance Schedule : "+ cstr(submit_ms[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
+    submit_mv = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.doc.name)
+    if submit_mv:
+      msgprint("Maintenance Visit : " + cstr(submit_mv[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Maintenance Visit : " + cstr(submit_mv[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
+
+
+  def check_modified_date(self):
+    mod_db = sql("select modified from `tabSales Order` where name = '%s'" % self.doc.name)
+    date_diff = sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
+    
+    if date_diff and date_diff[0][0]:
+      msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
+      raise Exception
+
+  # STOP SALES ORDER
+  # ==============================================================================================      
+  # Stops Sales Order & no more transactions will be created against this Sales Order
+  def stop_sales_order(self):
+    self.check_modified_date()
+    self.update_stock_ledger(update_stock = -1,clear = 1)
+    # ::::::::: SET SO STATUS ::::::::::
+    set(self.doc, 'status', 'Stopped')
+    msgprint(self.doc.doctype + ": " + self.doc.name + " has been Stopped. To make transactions against this Sales Order you need to Unstop it.")
+
+  # UNSTOP SALES ORDER
+  # ==============================================================================================      
+  # Unstops Sales Order & now transactions can be continued against this Sales Order
+  def unstop_sales_order(self):
+    self.check_modified_date()
+    self.update_stock_ledger(update_stock = 1,clear = 1)
+    # ::::::::: SET SO STATUS ::::::::::
+    set(self.doc, 'status', 'Submitted')
+    msgprint(self.doc.doctype + ": " + self.doc.name + " has been Unstopped.")
+
+  # UPDATE STOCK LEDGER
+  # ===============================================================================================
+  def update_stock_ledger(self, update_stock, clear = 0):
+    for d in self.get_item_list(clear):
+      stock_item = sql("SELECT is_stock_item FROM tabItem where name = '%s'"%(d[1]),as_dict = 1)       # stock ledger will be updated only if it is a stock item
+      if stock_item and stock_item[0]['is_stock_item'] == "Yes":
+        if not d[0]:
+          msgprint("Message: Please enter Reserved Warehouse for item %s as it is stock item."% d[1])
+          raise Exception
+        bin = get_obj('Warehouse', d[0]).update_bin( 0, flt(update_stock) * flt(d[2]), 0, 0, 0, d[1], self.doc.transaction_date)
+
+  # Gets Items from packing list
+  #=================================
+  def get_item_list(self, clear):
+    return get_obj('Sales Common').get_item_list( self, clear)
+    
+  # SET MESSAGE FOR SMS
+  #======================
+  def set_sms_msg(self, is_submitted = 0):
+    if is_submitted:
+      if not self.doc.amended_from:
+        msg = 'Sales Order: '+self.doc.name+' has been made against PO no: '+cstr(self.doc.po_no)
+        set(self.doc, 'message', msg)
+      else:
+        msg = 'Sales Order has been amended. New SO no:'+self.doc.name
+        set(self.doc, 'message', msg)
+    else:
+      msg = 'Sales Order: '+self.doc.name+' has been cancelled.'
+      set(self.doc, 'message', msg)
+    
+  # SEND SMS
+  # =========
+  def send_sms(self):
+    if not self.doc.customer_mobile_no:
+      msgprint("Please enter customer mobile no")
+    elif not self.doc.message:
+      msgprint("Please enter the message you want to send")
+    else:
+      msgprint(get_obj("SMS Control", "SMS Control").send_sms([self.doc.customer_mobile_no,], self.doc.message))
+
+  # on update
+  def on_update(self):
+    pass
+
+  # Repair Sales Order
+  # ===========================================
+  def repair_sales_order(self):
+    get_obj('Sales Common', 'Sales Common').repair_curr_doctype_details(self)
diff --git a/crm/doctype/sales_order/sales_order.txt b/crm/doctype/sales_order/sales_order.txt
new file mode 100644
index 0000000..f9d2aa4
--- /dev/null
+++ b/crm/doctype/sales_order/sales_order.txt
@@ -0,0 +1,3276 @@
+[
+	{
+		'_last_update': '1306899441',
+		'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': "cur_frm.add_fetch('customer','sales_person','sales_person');",
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': 'Transaction',
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': None,
+		'in_dialog': None,
+		'is_transaction_doc': 1,
+		'issingle': 0,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'Sales Order',
+		'name_case': None,
+		'owner': 'Administrator',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'print_outline': None,
+		'read_only': None,
+		'read_only_onload': 1,
+		'search_fields': 'status,transaction_date,customer,customer_name, territory,order_type,company',
+		'section_style': 'Tabbed',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'subject': 'From %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s | %(per_delivered)s% delivered | %(per_billed)s% billed',
+		'tag_fields': 'delivery_status,billing_status',
+		'use_template': None,
+		'version': 592
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00494',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00495',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 3,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00496',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 4,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00497',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 5,
+		'match': 'customer_name',
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00498',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Customer',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 6,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00499',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 2,
+		'read': 1,
+		'role': 'Accounts User',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 7,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00500',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Maintenance Manager',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 8,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00501',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Maintenance Manager',
+		'submit': None,
+		'write': None
+	},
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 9,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00502',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Maintenance User',
+		'submit': 1,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': None,
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 10,
+		'match': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'PERM00503',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Maintenance User',
+		'submit': None,
+		'write': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-24 10:32:34',
+		'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': 'Basic Info',
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'FL05100',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': 0,
+		'label': None,
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'FL05101',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Series',
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'FL03010',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'SO\nSO/10-11/\nSO/11-12/',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-09-01 15:47:53',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select Customer',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Customer',
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'FL03778',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Customer Address',
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'FL03013',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Address',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_person',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': 1,
+		'label': 'Contact Person',
+		'modified': '2011-06-02 09:56:17',
+		'modified_by': 'Administrator',
+		'name': 'FL03014',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Contact',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Name',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03012',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Address',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05089',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_display',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Contact',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05090',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_mobile',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Mobile No',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05091',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'contact_email',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Contact Email',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05092',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'Territory',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03015',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Territory',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'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': 'Category of customer as entered in Customer master',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': 1,
+		'label': 'Customer Group',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03060',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Customer Group',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': 'Purchase Order sent by customer',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'po_no',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'P.O. No',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03016',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'po_no',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'po_date',
+		'fieldtype': 'Date',
+		'hidden': 0,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'P.O. Date',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03017',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'po_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 16,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05102',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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:21',
+		'default': 'Today',
+		'depends_on': None,
+		'description': 'The date at which current entry is made in system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': 1,
+		'label': 'Sales Order Date',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03019',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': '160px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'order_type',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': 'Order Type',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03009',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'order_type',
+		'oldfieldtype': 'Select',
+		'options': '\nSales\nMaintenance',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Sales Order',
+		'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:21',
+		'default': 'Draft',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 19,
+		'in_filter': 1,
+		'label': 'Status',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03011',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nDraft\nSubmitted\nStopped\nCancelled',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'delivery_date',
+		'fieldtype': 'Date',
+		'hidden': 0,
+		'icon': None,
+		'idx': 20,
+		'in_filter': 1,
+		'label': 'Expected Delivery Date',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03020',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'delivery_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': None,
+		'width': '160px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-09-01 15:47:53',
+		'default': None,
+		'depends_on': None,
+		'description': 'Track this Sales Order against any Project',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'project_name',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': 1,
+		'label': 'Project Name',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03777',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'project_name',
+		'oldfieldtype': 'Link',
+		'options': 'Project',
+		'owner': 'ashwini@webnotestech.com',
+		'parent': 'Sales Order',
+		'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': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': '% of materials delivered against this Sales Order',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'per_delivered',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': 1,
+		'label': '%  Delivered',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03021',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'per_delivered',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': '% of materials billed against this Sales Order',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'per_billed',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 23,
+		'in_filter': 1,
+		'label': '% Qty Billed',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03022',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'per_billed',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'Amended From',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03025',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': 'The date at which current entry is corrected in the system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': 'Amendment Date',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03026',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:33',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'shipping_address_name',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'icon': None,
+		'idx': 26,
+		'in_filter': 1,
+		'label': 'Shipping Address Name',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05094',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Address',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-24 17:00:43',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'shipping_address',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 27,
+		'in_filter': 0,
+		'label': 'Shipping Address',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': '000000170',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'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-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 28,
+		'in_filter': None,
+		'label': 'Items',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05103',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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:21',
+		'default': None,
+		'depends_on': None,
+		'description': 'Quotation no against which this Sales Order is made ',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'quotation_no',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 29,
+		'in_filter': 1,
+		'label': 'Quotation No',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03028',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'quotation_no',
+		'oldfieldtype': 'Link',
+		'options': 'Quotation',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'quotation_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'icon': None,
+		'idx': 30,
+		'in_filter': None,
+		'label': 'Quotation Date',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03029',
+		'no_column': None,
+		'no_copy': 0,
+		'oldfieldname': 'quotation_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 31,
+		'in_filter': None,
+		'label': 'Pull Quotation Details',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03030',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'pull_quotation_details',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select the price list as entered in "Price List" master. This will pull the reference rates of items against this price list as specified in "Item" master.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'price_list_name',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 32,
+		'in_filter': None,
+		'label': 'Price List',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03031',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'price_list_name',
+		'oldfieldtype': 'Select',
+		'options': 'link:Price List',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 33,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05104',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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:21',
+		'default': None,
+		'depends_on': None,
+		'description': "Customer's currency",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'currency',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 34,
+		'in_filter': None,
+		'label': 'Currency',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03023',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'currency',
+		'oldfieldtype': 'Select',
+		'options': 'link:Currency',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': '1.00',
+		'depends_on': None,
+		'description': "Rate at which customer's currency is converted to your currency",
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'conversion_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 35,
+		'in_filter': None,
+		'label': 'Conversion Rate',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03024',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'conversion_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 36,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05105',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'sales_order_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 37,
+		'in_filter': None,
+		'label': 'Sales Order Details',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03032',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'sales_order_details',
+		'oldfieldtype': 'Table',
+		'options': 'Sales Order Detail',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '40px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 38,
+		'in_filter': None,
+		'label': 'Clear Table',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03033',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'clear_sales_order_details',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 39,
+		'in_filter': None,
+		'label': 'Re-Calculate Values',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03035',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': 'Client',
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'net_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 40,
+		'in_filter': None,
+		'label': 'Net Total*',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03034',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'net_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 41,
+		'in_filter': None,
+		'label': 'Note1',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05106',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': '<b>NOTE :</b> * In Base Currency',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'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-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 42,
+		'in_filter': None,
+		'label': 'Taxes',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05107',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'charge',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 43,
+		'in_filter': None,
+		'label': 'Select Charges Master',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03038',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'charge',
+		'oldfieldtype': 'Link',
+		'options': 'Other Charges',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-08-08 17:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 44,
+		'in_filter': None,
+		'label': 'Get Charges',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03039',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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:09:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'other_charges',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 45,
+		'in_filter': None,
+		'label': 'Other Charges',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03040',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'other_charges',
+		'oldfieldtype': 'Table',
+		'options': 'RV Tax Detail',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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:21',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 46,
+		'in_filter': None,
+		'label': 'Calculate Charges',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03041',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'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': 'other_charges_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 47,
+		'in_filter': None,
+		'label': 'Charges Total*',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03042',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'other_charges_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'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': 'grand_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 48,
+		'in_filter': None,
+		'label': 'Grand Total*',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03043',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'grand_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 49,
+		'in_filter': None,
+		'label': 'OT Notes',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05108',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': '<b>NOTE :</b> * In Base Currency',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 50,
+		'in_filter': None,
+		'label': 'Other Charges Calculation',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05109',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 51,
+		'in_filter': None,
+		'label': 'Totals',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05110',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'rounded_total',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 52,
+		'in_filter': None,
+		'label': 'Rounded Total',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03068',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'rounded_total',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': 'In Words will be visible once you save the Sales Order.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'in_words',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 53,
+		'in_filter': None,
+		'label': 'In Words',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03069',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'in_words',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 54,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05111',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'sneha@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'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': 'grand_total_export',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 55,
+		'in_filter': None,
+		'label': 'Grand Total (Export)',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03071',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'grand_total_export',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'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': 'rounded_total_export',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 56,
+		'in_filter': None,
+		'label': 'Rounded Total (Export)',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03072',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'rounded_total_export',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': 'In Words (Export) will be visible once you save the Sales Order.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'in_words_export',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 57,
+		'in_filter': None,
+		'label': 'In Words (Export)',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03073',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'in_words_export',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '200px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 58,
+		'in_filter': None,
+		'label': 'Terms',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05112',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'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': 'tc_name',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 59,
+		'in_filter': None,
+		'label': 'Select Terms',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03047',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'tc_name',
+		'oldfieldtype': 'Link',
+		'options': 'Term',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 0,
+		'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': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 60,
+		'in_filter': None,
+		'label': 'Get Terms',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03048',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'get_tc_details',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'HTML',
+		'hidden': None,
+		'icon': None,
+		'idx': 61,
+		'in_filter': None,
+		'label': 'Terms HTML',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05113',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'HTML',
+		'options': 'You can add Terms and Notes that will be printed in the Transaction',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Order',
+		'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-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'terms',
+		'fieldtype': 'Text Editor',
+		'hidden': None,
+		'icon': None,
+		'idx': 62,
+		'in_filter': None,
+		'label': 'Term Details',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03050',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'terms',
+		'oldfieldtype': 'Text Editor',
+		'options': None,
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': 'Filling in additional information about the Sales Order will help you analyze your data better.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 63,
+		'in_filter': None,
+		'label': 'More Info',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05114',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 64,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05115',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50%'
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-12-14 10:33:04',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'letter_head',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 65,
+		'in_filter': None,
+		'label': 'Letter Head',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL04196',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'letter_head',
+		'oldfieldtype': 'Select',
+		'options': 'link:Letter Head',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': 'Select the relevant company name if you have multiple companies.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 66,
+		'in_filter': 1,
+		'label': 'Company',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03053',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+	{
+		'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': 'fiscal_year',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 67,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03054',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'select_print_heading',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 68,
+		'in_filter': None,
+		'label': 'Select Print Heading',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03057',
+		'no_column': None,
+		'no_copy': 1,
+		'oldfieldname': 'select_print_heading',
+		'oldfieldtype': 'Link',
+		'options': 'Print Heading',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 69,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05116',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Column Break',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'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:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'source',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 70,
+		'in_filter': None,
+		'label': 'Source',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03055',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'source',
+		'oldfieldtype': 'Select',
+		'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign",
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': "eval:doc.source == 'Campaign'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'campaign',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 71,
+		'in_filter': None,
+		'label': 'Campaign',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03056',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'campaign',
+		'oldfieldtype': 'Link',
+		'options': 'Campaign',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'note',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 72,
+		'in_filter': None,
+		'label': 'Note',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03065',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'note',
+		'oldfieldtype': 'Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': 'eval:!doc.__islocal',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 73,
+		'in_filter': None,
+		'label': 'Cancel Reason',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03063',
+		'no_column': 0,
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-06-01 09:07:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'delivery_status',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'icon': None,
+		'idx': 74,
+		'in_filter': None,
+		'label': 'Delivery Status',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05197',
+		'no_column': 0,
+		'no_copy': 1,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '\nBilled\nNot Billed\nPartly Billed\nClosed',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-06-01 09:07:18',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'billing_status',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'icon': None,
+		'idx': 75,
+		'in_filter': None,
+		'label': 'Billing Status',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05196',
+		'no_column': 0,
+		'no_copy': 1,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '\nDelivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'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-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': 'Display all the individual items delivered with the main items',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': 0,
+		'icon': None,
+		'idx': 76,
+		'in_filter': None,
+		'label': 'Packing List',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05117',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'packing_details',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 77,
+		'in_filter': None,
+		'label': 'Packing Details',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03075',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'packing_details',
+		'oldfieldtype': 'Table',
+		'options': 'Delivery Note Packing Detail',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-24 10:32:34',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Section Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 78,
+		'in_filter': None,
+		'label': 'Sales Team',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL05118',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Section Break',
+		'options': None,
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order',
+		'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': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': 'Name as entered in Sales Partner master',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'sales_partner',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 79,
+		'in_filter': 1,
+		'label': 'Sales Partner',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03077',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'sales_partner',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Partner',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+	{
+		'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': 80,
+		'in_filter': None,
+		'label': 'Commission Rate',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03078',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'commission_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'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': 'total_commission',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 81,
+		'in_filter': None,
+		'label': 'Total Commission',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03079',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'total_commission',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'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': 'sales_team',
+		'fieldtype': 'Table',
+		'hidden': None,
+		'icon': None,
+		'idx': 82,
+		'in_filter': None,
+		'label': 'Sales Team1',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03080',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': 'sales_team',
+		'oldfieldtype': 'Table',
+		'options': 'Sales Team',
+		'owner': 'Administrator',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 83,
+		'in_filter': None,
+		'label': 'Repair Sales Order',
+		'modified': '2011-06-02 09:56:18',
+		'modified_by': 'Administrator',
+		'name': 'FL03093',
+		'no_column': None,
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': 'Button',
+		'options': 'repair_sales_order',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Sales Order',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/crm/doctype/sales_order_detail/__init__.py b/crm/doctype/sales_order_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/sales_order_detail/__init__.py
diff --git a/crm/doctype/sales_order_detail/sales_order_detail.txt b/crm/doctype/sales_order_detail/sales_order_detail.txt
new file mode 100644
index 0000000..1eda61a
--- /dev/null
+++ b/crm/doctype/sales_order_detail/sales_order_detail.txt
@@ -0,0 +1,1037 @@
+[
+	{
+		'_last_update': '1304676470',
+		'_user_tags': None,
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': None,
+		'autoname': 'SOD/.#####',
+		'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': None,
+		'dt_template': None,
+		'hide_heading': None,
+		'hide_toolbar': None,
+		'idx': None,
+		'in_create': None,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': None,
+		'istable': 1,
+		'max_attachments': None,
+		'menu_index': None,
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'Sales Order Detail',
+		'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': 'Tray',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'smallicon': None,
+		'use_template': None,
+		'version': 51
+	},
+	{
+		'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': 'item_code',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03098',
+		'no_copy': None,
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Item Name',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03099',
+		'no_copy': None,
+		'oldfieldname': 'item_name',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': None,
+		'width': '150'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': 0,
+		'label': 'Description',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03100',
+		'no_copy': None,
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': None,
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': 'White:FFF',
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Quantity',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03102',
+		'no_copy': None,
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 1,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'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': 'stock_uom',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'UOM',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03101',
+		'no_copy': None,
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Data',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '70px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'ref_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Ref Rate',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03103',
+		'no_copy': None,
+		'oldfieldname': 'ref_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '70px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'adj_rate',
+		'fieldtype': 'Float',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Discount(%)',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03104',
+		'no_copy': None,
+		'oldfieldname': 'adj_rate',
+		'oldfieldtype': 'Float',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '70px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'export_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Rate',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03105',
+		'no_copy': None,
+		'oldfieldname': 'export_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'export_amount',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Amount',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03106',
+		'no_copy': 0,
+		'oldfieldname': 'export_amount',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': None,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'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': 'base_ref_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Ref Rate*',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03107',
+		'no_copy': None,
+		'oldfieldname': 'base_ref_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'basic_rate',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Basic Rate*',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03108',
+		'no_copy': None,
+		'oldfieldname': 'basic_rate',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amount',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 12,
+		'in_filter': None,
+		'label': 'Amount*',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03109',
+		'no_copy': 0,
+		'oldfieldname': 'amount',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'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': 'reserved_warehouse',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 13,
+		'in_filter': None,
+		'label': 'Reserved Warehouse',
+		'modified': '2011-05-06 15:38:39',
+		'modified_by': 'Administrator',
+		'name': 'FL03110',
+		'no_copy': 1,
+		'oldfieldname': 'reserved_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': 0,
+		'search_index': None,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'projected_qty',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 14,
+		'in_filter': None,
+		'label': 'Projected Qty',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03111',
+		'no_copy': 1,
+		'oldfieldname': 'projected_qty',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '70px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-01-28 11:15:20',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'actual_qty',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 15,
+		'in_filter': None,
+		'label': 'Actual Qty',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL04493',
+		'no_copy': 1,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '70px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': '0.00',
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'delivered_qty',
+		'fieldtype': 'Currency',
+		'hidden': 0,
+		'icon': None,
+		'idx': 16,
+		'in_filter': 0,
+		'label': 'Delivered Qty',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03112',
+		'no_copy': 1,
+		'oldfieldname': 'delivered_qty',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'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': 'billed_qty',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 17,
+		'in_filter': 0,
+		'label': 'Billed Qty',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03113',
+		'no_copy': 1,
+		'oldfieldname': 'billed_qty',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': None,
+		'width': '100px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-03-05 17:16:48',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'billed_amt',
+		'fieldtype': 'Currency',
+		'hidden': None,
+		'icon': None,
+		'idx': 18,
+		'in_filter': None,
+		'label': 'Billed Amt',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL04748',
+		'no_copy': 1,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'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': 'For Production',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'planned_qty',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'icon': None,
+		'idx': 19,
+		'in_filter': None,
+		'label': 'Planned Quantity',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03114',
+		'no_copy': 1,
+		'oldfieldname': 'planned_qty',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50px'
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': 'For Production',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'produced_qty',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'icon': None,
+		'idx': 20,
+		'in_filter': None,
+		'label': 'Produced Quantity',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03115',
+		'no_copy': None,
+		'oldfieldname': 'produced_qty',
+		'oldfieldtype': 'Currency',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': '50px'
+	},
+	{
+		'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': 'brand',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 21,
+		'in_filter': 1,
+		'label': 'Brand Name',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03116',
+		'no_copy': None,
+		'oldfieldname': 'brand',
+		'oldfieldtype': 'Link',
+		'options': 'Brand',
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'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': 'item_group',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 22,
+		'in_filter': 1,
+		'label': 'Item Group',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03117',
+		'no_copy': None,
+		'oldfieldname': 'item_group',
+		'oldfieldtype': 'Link',
+		'options': 'Item Group',
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'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': 'prevdoc_docname',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'icon': None,
+		'idx': 23,
+		'in_filter': 1,
+		'label': 'Quotation No.',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03118',
+		'no_copy': None,
+		'oldfieldname': 'prevdoc_docname',
+		'oldfieldtype': 'Link',
+		'options': 'Quotation',
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': None,
+		'reqd': None,
+		'search_index': 1,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'page_break',
+		'fieldtype': 'Check',
+		'hidden': None,
+		'icon': None,
+		'idx': 24,
+		'in_filter': None,
+		'label': 'Page Break',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03120',
+		'no_copy': None,
+		'oldfieldname': 'page_break',
+		'oldfieldtype': 'Check',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'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': 'required for production. will be used later.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'delivery_date',
+		'fieldtype': 'Date',
+		'hidden': 0,
+		'icon': None,
+		'idx': 25,
+		'in_filter': None,
+		'label': 'Expected Delivery Date',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03122',
+		'no_copy': None,
+		'oldfieldname': 'delivery_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': None,
+		'trigger': None,
+		'width': None
+	},
+	{
+		'allow_on_submit': 1,
+		'colour': None,
+		'creation': '2010-08-08 17:09:22',
+		'default': None,
+		'depends_on': None,
+		'description': 'required for production. will be used later.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'confirmation_date',
+		'fieldtype': 'Date',
+		'hidden': 0,
+		'icon': None,
+		'idx': 26,
+		'in_filter': 1,
+		'label': 'Confirmed Delivery Date',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03123',
+		'no_copy': None,
+		'oldfieldname': 'confirmation_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': 0,
+		'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': 'item_tax_rate',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'icon': None,
+		'idx': 27,
+		'in_filter': None,
+		'label': 'Item Tax Rate',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03119',
+		'no_copy': None,
+		'oldfieldname': 'item_tax_rate',
+		'oldfieldtype': 'Small Text',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1,
+		'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': 'The date at which current entry is made in system.',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'icon': None,
+		'idx': 28,
+		'in_filter': 0,
+		'label': 'Sales Order Date',
+		'modified': '2011-05-06 15:38:40',
+		'modified_by': 'Administrator',
+		'name': 'FL03121',
+		'no_copy': None,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Sales Order Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': None,
+		'search_index': 0,
+		'trigger': None,
+		'width': None
+	}
+]
\ No newline at end of file
diff --git a/crm/doctype/sales_team/__init__.py b/crm/doctype/sales_team/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/sales_team/__init__.py
diff --git a/crm/doctype/sales_team/sales_team.txt b/crm/doctype/sales_team/sales_team.txt
new file mode 100644
index 0000000..0ae2eb6
--- /dev/null
+++ b/crm/doctype/sales_team/sales_team.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-16 18:21:56', 'search_fields': None, 'module': 'CRM', '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': 7, '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': '', 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': '', 'name': 'Sales Team', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-24 09:09:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-03-16 18:21:56', 'doctype': 'DocField', 'oldfieldname': 'sales_person', 'owner': 'Administrator', 'reqd': 1, 'in_filter': 1, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Sales Person', 'width': '200px', 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Sales Team', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL01421', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-11-24 09:09:57', 'parenttype': 'DocType', 'fieldname': 'sales_person', 'fieldtype': 'Link', 'options': 'Sales Person', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-01-27 09:44:18', 'doctype': 'DocField', 'oldfieldname': 'contact_no', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Contact No.', 'width': '100px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Sales Team', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03680', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-11-24 09:09:57', 'parenttype': 'DocType', 'fieldname': 'contact_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-16 18:21:56', 'doctype': 'DocField', 'oldfieldname': 'allocated_percentage', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Allocated (%)', 'width': '100px', 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Sales Team', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01422', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-11-24 09:09:57', 'parenttype': 'DocType', 'fieldname': 'allocated_percentage', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2009-03-16 18:21:56', 'doctype': 'DocField', 'oldfieldname': 'allocated_amount', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Allocated Amount', 'width': '120px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Sales Team', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01423', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-11-24 09:09:57', 'parenttype': 'DocType', 'fieldname': 'allocated_amount', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-26 17:32:54', 'doctype': 'DocField', 'oldfieldname': 'parenttype', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': 1, 'modified_by': 'saumil@webnotestech.com', 'label': 'Parenttype', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Sales Team', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL02191', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-11-24 09:09:57', 'parenttype': 'DocType', 'fieldname': 'parenttype', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Currency', 'creation': '2010-07-20 13:14:29', 'doctype': 'DocField', 'oldfieldname': 'incentives', 'owner': 'harshada@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Incentives', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Sales Team', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05663', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-11-24 09:09:57', 'parenttype': 'DocType', 'fieldname': 'incentives', 'fieldtype': 'Currency', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/crm/doctype/shipping_address/__init__.py b/crm/doctype/shipping_address/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/shipping_address/__init__.py
diff --git a/crm/doctype/shipping_address/shipping_address.comp.js b/crm/doctype/shipping_address/shipping_address.comp.js
new file mode 100755
index 0000000..c3deecf
--- /dev/null
+++ b/crm/doctype/shipping_address/shipping_address.comp.js
@@ -0,0 +1,2 @@
+
+cur_frm.add_fetch('customer','customer_name','customer_name');cur_frm.add_fetch('customer','address','customer_address');
\ No newline at end of file
diff --git a/crm/doctype/shipping_address/shipping_address.js b/crm/doctype/shipping_address/shipping_address.js
new file mode 100755
index 0000000..77c0d35
--- /dev/null
+++ b/crm/doctype/shipping_address/shipping_address.js
@@ -0,0 +1,4 @@
+// Get Customer Details
+// =====================================================================
+cur_frm.add_fetch('customer','customer_name','customer_name');
+cur_frm.add_fetch('customer','address','customer_address');
diff --git a/crm/doctype/shipping_address/shipping_address.py b/crm/doctype/shipping_address/shipping_address.py
new file mode 100755
index 0000000..76d3749
--- /dev/null
+++ b/crm/doctype/shipping_address/shipping_address.py
@@ -0,0 +1,25 @@
+import webnotes
+sql = webnotes.conn.sql
+
+class DocType:
+  def __init__(self, d, dl):
+    self.doc, self.doclist = d, dl
+
+  # on update
+  # ---------- 
+  def on_update(self):
+    self.update_primary_shipping_address()
+    self.get_customer_details()
+
+  # set is_primary_address for other shipping addresses belonging to same customer
+  # -------------------------------------------------------------------------------
+  def update_primary_shipping_address(self):
+    if self.doc.is_primary_address == 'Yes':
+      sql("update `tabShipping Address` set is_primary_address = 'No' where customer = %s and is_primary_address = 'Yes' and name != %s",(self.doc.customer, self.doc.name))
+
+  # Get Customer Details
+  # ---------------------
+  def get_customer_details(self):
+    det = sql("select customer_name, address from tabCustomer where name = '%s'" % (self.doc.customer))
+    self.doc.customer_name = det and det[0][0] or ''
+    self.doc.customer_address = det and det[0][1] or ''
diff --git a/crm/doctype/shipping_address/shipping_address.txt b/crm/doctype/shipping_address/shipping_address.txt
new file mode 100755
index 0000000..c059bbd
--- /dev/null
+++ b/crm/doctype/shipping_address/shipping_address.txt
@@ -0,0 +1,406 @@
+[
+	{
+		'_last_update': None,
+		'allow_attach': None,
+		'allow_copy': None,
+		'allow_email': None,
+		'allow_print': None,
+		'allow_rename': None,
+		'allow_trash': 1,
+		'autoname': 'SA.#####',
+		'change_log': None,
+		'client_script': None,
+		'client_script_core': None,
+		'client_string': None,
+		'colour': 'White:FFF',
+		'creation': '2011-05-09 11:01:06',
+		'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-03-24 10:39:09',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'Shipping Address',
+		'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': 'customer, ship_to, shipping_address',
+		'section_style': 'Simple',
+		'server_code': None,
+		'server_code_compiled': None,
+		'server_code_core': None,
+		'server_code_error': None,
+		'show_in_menu': 0,
+		'smallicon': None,
+		'use_template': None,
+		'version': 8
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-05-09 11:01:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-09 11:01:06',
+		'modified_by': 'Administrator',
+		'name': '000000259',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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': '2011-05-09 11:01:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Customer',
+		'modified': '2011-05-09 11:01:06',
+		'modified_by': 'Administrator',
+		'name': '000000260',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Customer',
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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:01:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Customer Name',
+		'modified': '2011-05-09 11:01:06',
+		'modified_by': 'Administrator',
+		'name': '000000261',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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-09 11:01:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Customer Address',
+		'modified': '2011-05-09 11:01:06',
+		'modified_by': 'Administrator',
+		'name': '000000262',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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-09 11:01:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'ship_to',
+		'fieldtype': 'Data',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Ship To',
+		'modified': '2011-05-09 11:01:06',
+		'modified_by': 'Administrator',
+		'name': '000000263',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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:01:06',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'shipping_address',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Shipping Address',
+		'modified': '2011-05-09 11:01:06',
+		'modified_by': 'Administrator',
+		'name': '000000264',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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:01:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-05-09 11:01:07',
+		'modified_by': 'Administrator',
+		'name': '000000265',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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': '2011-05-09 11:01:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'is_primary_address',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Is Primary Address',
+		'modified': '2011-05-09 11:01:07',
+		'modified_by': 'Administrator',
+		'name': '000000266',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Yes\nNo',
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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:01:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'shipping_details',
+		'fieldtype': 'Text Editor',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': 'Shipping Details',
+		'modified': '2011-05-09 11:01:07',
+		'modified_by': 'Administrator',
+		'name': '000000267',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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:01:07',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Trash Reason',
+		'modified': '2011-05-09 11:01:07',
+		'modified_by': 'Administrator',
+		'name': '000000268',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'Shipping Address',
+		'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/crm/doctype/sms_center/__init__.py b/crm/doctype/sms_center/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/sms_center/__init__.py
diff --git a/crm/doctype/sms_center/sms_center.js b/crm/doctype/sms_center/sms_center.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/doctype/sms_center/sms_center.js
diff --git a/crm/doctype/sms_center/sms_center.py b/crm/doctype/sms_center/sms_center.py
new file mode 100644
index 0000000..5564347
--- /dev/null
+++ b/crm/doctype/sms_center/sms_center.py
@@ -0,0 +1,67 @@
+# 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 create_receiver_list(self):
+    rec, where_clause = '', ''
+    if self.doc.send_to == 'All Customer Contact':
+      where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(is_customer, 0) = 1"
+    if self.doc.send_to == 'All Supplier Contact':
+      where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(is_supplier, 0) = 1"
+    if self.doc.send_to == 'All Sales Partner Contact':
+      where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_aprtner = '%s'" % self.doc.sales_partner or " and ifnull(is_sales_partner, 0) = 1"
+    msgprint(1)
+    if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
+      msgprint("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
+      rec = sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
+    elif self.doc.send_to == 'All Lead (Open)':
+      rec = sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
+    elif self.doc.send_to == 'All Employee (Active)':
+      where_clause = self.doc.department and " and t1.department = '%s'" % self.doc.department or ""
+      where_clause += self.doc.branch and " and t1.branch = '%s'" % self.doc.branch or ""
+      rec = sql("select t1.employee_name, t2.cell_number from `tabEmployee` t1, `tabEmployee Profile` t2 where t2.employee = t1.name and t1.status = 'Active' and t1.docstatus != 2 and ifnull(t2.cell_number,'')!='' %s" % where_clause)
+    elif self.doc.send_to == 'All Sales Person':
+      rec = sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
+
+    rec_list = ''
+    for d in rec:
+      rec_list += d[0] + ' - ' + d[1] + '\n'
+    self.doc.receiver_list = rec_list
+
+  def get_receiver_nos(self):
+    receiver_nos = []
+    for d in self.doc.receiver_list.split('\n'):
+      receiver_no = d
+      if '-' in d:
+        receiver_no = receiver_no.split('-')[1]
+      if receiver_no.strip():
+        receiver_nos.append(cstr(receiver_no).strip())
+    return receiver_nos
+
+  def send_sms(self):
+    if not self.doc.message:
+      msgprint("Please enter message before sending")
+    else:
+      receiver_list = self.get_receiver_nos()
+      if receiver_list:
+        msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.doc.message)))
diff --git a/crm/doctype/sms_center/sms_center.txt b/crm/doctype/sms_center/sms_center.txt
new file mode 100644
index 0000000..23e379f
--- /dev/null
+++ b/crm/doctype/sms_center/sms_center.txt
@@ -0,0 +1,486 @@
+[
+	{
+		'allow_attach': 0,
+		'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:24',
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocType',
+		'document_type': None,
+		'dt_template': None,
+		'hide_heading': 0,
+		'hide_toolbar': 0,
+		'idx': None,
+		'in_create': 0,
+		'in_dialog': None,
+		'is_transaction_doc': None,
+		'issingle': 1,
+		'istable': None,
+		'max_attachments': None,
+		'menu_index': 4,
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'SMS Center',
+		'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': ' ',
+		'show_in_menu': 1,
+		'smallicon': None,
+		'use_template': None,
+		'version': 36
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': 1,
+		'creation': '2010-08-08 17:09:24',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 1,
+		'match': None,
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'PERM00532',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'Administrator',
+		'submit': None,
+		'write': 1
+	},
+	{
+		'amend': None,
+		'cancel': None,
+		'create': 0,
+		'creation': '2010-08-08 17:09:24',
+		'docstatus': 0,
+		'doctype': 'DocPerm',
+		'execute': None,
+		'idx': 2,
+		'match': None,
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'PERM00533',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1,
+		'role': 'Administrator',
+		'submit': None,
+		'write': 0
+	},
+	{
+		'allow_on_submit': None,
+		'colour': None,
+		'creation': '2011-02-15 16:59:29',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'column_break1',
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 1,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL04772',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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:24',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'send_to',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 2,
+		'in_filter': None,
+		'label': 'Send To',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL03352',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': '\nAll Contact\nAll Customer Contact\nAll Supplier Contact\nAll Sales Partner Contact\nAll Lead (Open)\nAll Employee (Active)\nAll Sales Person',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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': 'White:FFF',
+		'creation': '2010-08-08 17:09:24',
+		'default': None,
+		'depends_on': "eval:doc.send_to=='All Customer Contact'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 3,
+		'in_filter': None,
+		'label': 'Customer',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL03353',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Customer',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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-01-11 15:10:58',
+		'default': None,
+		'depends_on': "eval:doc.send_to=='All Supplier Contact'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'supplier',
+		'fieldtype': 'Link',
+		'hidden': None,
+		'icon': None,
+		'idx': 4,
+		'in_filter': None,
+		'label': 'Supplier',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL04407',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'Supplier',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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-01-11 15:10:58',
+		'default': None,
+		'depends_on': "eval:doc.send_to=='All Employee (Active)'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'department',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 5,
+		'in_filter': None,
+		'label': 'Department',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL04409',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'link:Department',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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-01-11 15:10:58',
+		'default': None,
+		'depends_on': "eval:doc.send_to=='All Employee (Active)'",
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'branch',
+		'fieldtype': 'Select',
+		'hidden': None,
+		'icon': None,
+		'idx': 6,
+		'in_filter': None,
+		'label': 'Branch',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL04408',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'link:Branch',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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-01-11 16:55:50',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 7,
+		'in_filter': None,
+		'label': 'Create Receiver List',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL04411',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'create_receiver_list',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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:24',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'receiver_list',
+		'fieldtype': 'Code',
+		'hidden': None,
+		'icon': None,
+		'idx': 8,
+		'in_filter': None,
+		'label': 'Receiver List',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL03359',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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-02-15 16:59:29',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'column_break2',
+		'fieldtype': 'Column Break',
+		'hidden': None,
+		'icon': None,
+		'idx': 9,
+		'in_filter': None,
+		'label': None,
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL04773',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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:24',
+		'default': None,
+		'depends_on': None,
+		'description': 'Message greater than 160 character will be splitted into multiple mesage',
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': 'message',
+		'fieldtype': 'Text',
+		'hidden': None,
+		'icon': None,
+		'idx': 10,
+		'in_filter': None,
+		'label': 'Message',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL03354',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': None,
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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:24',
+		'default': None,
+		'depends_on': None,
+		'description': None,
+		'docstatus': 0,
+		'doctype': 'DocField',
+		'fieldname': None,
+		'fieldtype': 'Button',
+		'hidden': None,
+		'icon': None,
+		'idx': 11,
+		'in_filter': None,
+		'label': 'Send SMS',
+		'modified': '2011-02-15 17:06:33',
+		'modified_by': 'Administrator',
+		'name': 'FL03357',
+		'no_copy': None,
+		'oldfieldname': None,
+		'oldfieldtype': None,
+		'options': 'send_sms',
+		'owner': 'Administrator',
+		'parent': 'SMS Center',
+		'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/crm/page/__init__.py b/crm/page/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/__init__.py
diff --git a/crm/page/customers/__init__.py b/crm/page/customers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/customers/__init__.py
diff --git a/crm/page/customers/customers.comp.js b/crm/page/customers/customers.comp.js
new file mode 100644
index 0000000..b6e831c
--- /dev/null
+++ b/crm/page/customers/customers.comp.js
@@ -0,0 +1,3 @@
+
+pscript.onload_customers=function(){make_customer_tab($i('dcv_customers'));}
+function make_customer_tab(parent){pscript.dcv_customers=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'],set_values:{'is_customer':1},filter_by:['Customer','customer']},})}
\ No newline at end of file
diff --git a/crm/page/customers/customers.html b/crm/page/customers/customers.html
new file mode 100644
index 0000000..9f3d19c
--- /dev/null
+++ b/crm/page/customers/customers.html
@@ -0,0 +1 @@
+<div id="dcv_customers"></div>
\ No newline at end of file
diff --git a/crm/page/customers/customers.js b/crm/page/customers/customers.js
new file mode 100644
index 0000000..7902e24
--- /dev/null
+++ b/crm/page/customers/customers.js
@@ -0,0 +1,34 @@
+//make tabs
+
+pscript.onload_customers = function() {
+	make_customer_tab($i('dcv_customers'));
+}
+
+function make_customer_tab(parent) {	
+	pscript.dcv_customers = 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'],
+			set_values: {'is_customer': 1 },
+			filter_by : ['Customer', 'customer']
+		},
+	})
+}
+
+
diff --git a/crm/page/customers/customers.txt b/crm/page/customers/customers.txt
new file mode 100644
index 0000000..7f44ab45
--- /dev/null
+++ b/crm/page/customers/customers.txt
@@ -0,0 +1,26 @@
+[
+	{
+		'content': None,
+		'creation': '2011-03-25 13:48:50',
+		'docstatus': 0,
+		'doctype': 'Page',
+		'icon': None,
+		'idx': None,
+		'menu_index': None,
+		'modified': '2011-03-25 13:48:50',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'customers',
+		'owner': 'Administrator',
+		'page_name': 'Customers',
+		'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/crm/page/sales_browser/__init__.py b/crm/page/sales_browser/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/sales_browser/__init__.py
diff --git a/crm/page/sales_browser/sales_browser.html b/crm/page/sales_browser/sales_browser.html
new file mode 100644
index 0000000..1acb5ee
--- /dev/null
+++ b/crm/page/sales_browser/sales_browser.html
@@ -0,0 +1,4 @@
+<div class="layout_wrapper">
+<div id="tr_header"></div>
+<div id="tr_body" style="margin: 16px"></div>
+</div>
\ No newline at end of file
diff --git a/crm/page/sales_browser/sales_browser.js b/crm/page/sales_browser/sales_browser.js
new file mode 100644
index 0000000..a24c942
--- /dev/null
+++ b/crm/page/sales_browser/sales_browser.js
@@ -0,0 +1,421 @@
+pscript['onload_Sales Browser'] = function(){
+  var parent = $i('tr_body');
+  parent.innerHTML = 'Please select your chart: '
+  var sel = $a(parent,'select');
+  add_sel_options(sel, ['Territory', 'Customer Group', 'Item Group', 'Sales Person'], 'Territory');
+  var btn = $btn(parent, 'Go', function() { new SalesBrowser().set_val(sel_val(sel)) }, {marginTop:'8px'});
+}
+
+//================================= SalesBrowser Class ======================================
+SalesBrowser = function(){
+  
+  this.make_body = function(){
+  
+    $i('tr_header').innerHTML = '';
+    $i('tr_body').innerHTML = '';
+    //make header
+    var desc = this.sel;
+    var me = this;
+    var h = new PageHeader($i('tr_header'),desc);
+    h.add_button('New '+this.sel, function() { me.set_dialog(1); }, 0, 'ui-icon-plus', 1);
+    h.add_button('Refresh', function() { me.refresh_tree(); }, 0, 'ui-icon-refresh');
+
+    var div_body = $a($i('tr_body'),'div');
+    var tr_main_grid = make_table(div_body,1,2,'100%',['60%','40%'],{width: "100%", tableLayout: "fixed", borderCollapse: "collapse", border:"0px", padding:"4px 4px 4px 4px"});
+    
+    $y($td(tr_main_grid,0,0),{border: "1px solid #dddddd", padding: "8px", width: "60%"});   
+    this.tree_area = $a($td(tr_main_grid,0,0),'div');
+
+    $y($td(tr_main_grid,0,1),{border: "1px solid #DDD"});   
+    this.detail_area = $a($td(tr_main_grid,0,1),'div');
+    
+    this.make_tree_body(this.tree_area);  
+    this.refresh_tree();
+  }
+  
+  this.set_val = function(b){
+    var me = this;
+    me.sel = b;  
+    me.make_body();
+  }
+}
+
+//=================================================================================================================================
+SalesBrowser.prototype.make_tree_body = function(parent){
+
+  //this.tab2 =make_table(this.wrapper,1,2,'100%',['60%','40%']);
+  this.make_tree();
+  this.make_rgt_sect();
+  
+}
+
+//=================================================================================================================================
+SalesBrowser.prototype.make_rgt_sect=function(){
+  //var d = $a($td(this.tab2,0,1),'div','',{border:'1px solid #000'});
+
+  this.rgt_tab =make_table(this.detail_area,4,1,'','',{padding:"4px",spacing:"4px"});
+  this.dtl = $a($td(this.rgt_tab,0,0),'div');
+  this.btn = $a($td(this.rgt_tab,1,0),'div','span');
+  this.help = $a($td(this.rgt_tab,2,0),'div');
+  this.help.innerHTML = "Note: Explore and click on the tree node to see details."
+
+  this.set_btn();
+}
+//=================================================================================================================================
+SalesBrowser.prototype.set_btn = function(){
+  var me = this;
+  this.edit_btn = $btn(this.btn,'Edit',function(){ me.set_dialog(2); });
+
+  this.trash_btn = $btn(this.btn,'Trash',null);
+  this.trash_btn.onclick = function(){
+    var check = confirm("Are you sure you want to trash "+me.cur_node.rec.name+" node?");
+    
+    if(check){
+      var arg = [me.cur_node.rec.name, me.sel];
+      $c_obj('Sales Browser Control','trash_record',arg.join(','),function(r,rt){      me.refresh_tree();});
+
+    }
+  }
+}
+
+//=====================================================
+SalesBrowser.prototype.set_dialog = function(f){
+
+ 
+  if(this.sel == 'Territory')
+    new MakeDialog('Territory','territory',f,this);            //Territory Dialog
+  if(this.sel == 'Customer Group')
+    new MakeDialog('Customer Group','customer_group',f,this);  //Customer Group Dialog  
+  if(this.sel == 'Item Group')
+    new MakeDialog('Item Group','item_group',f,this);   //Item Group Dialog
+  if(this.sel == 'Sales Person')
+    new MakeDialog('Sales Person','sales_person',f,this);//Sales Person Dialog 
+  
+}
+//=====================================================Make Tree============================================================================
+SalesBrowser.prototype.make_tree = function() {
+  var me = this;
+
+  this.tree = new Tree(this.tree_area, '100%');
+  
+  //---------------------------------------------------------------------------------------------------------------------------------
+  // on click
+  this.tree.std_onclick = function(node) {
+      
+      me.cur_node = node;
+      if(node.rec.name =='All Customer Groups' || node.rec.name =='All Sales Persons' || node.rec.name =='All Item Groups' || node.rec.name =='All Territories'){
+        //$di(me.add_btn);
+
+        $dh(me.edit_btn);
+        $dh(me.trash_btn);
+      }
+      else{
+        //$di(me.add_btn);
+        //if(node.has_children == false)
+          //$dh(me.add_btn);
+
+        $di(me.edit_btn);
+        $di(me.trash_btn);
+
+      }
+      me.make_details();
+	  
+  }
+  //---------------------------------------------------------------------------------------------------------------------------------
+  // on expand
+  this.tree.std_onexp = function(node) {
+
+    if(node.expanded_once)return;
+    $di(node.loading_div);
+
+    var callback = function(r,rt) {
+
+      $dh(node.loading_div);
+      var n = me.tree.allnodes[r.message.parent];
+      var cl = r.message.cl;
+
+      for(var i=0;i<cl.length;i++) {
+        var imgsrc=null;
+        var has_children = true;
+
+        if(cl[i].is_group=='No') {
+          var imgsrc = 'images/icons/page.gif';
+          has_children = false;
+        }
+        var t = me.tree.addNode(n, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
+        t.rec = cl[i];
+        t.parent_account = r.message.parent;
+        t.has_children = has_children;
+      }
+
+    }
+    var arg = [node.rec.name, me.sel];
+    $c_obj('Sales Browser Control','get_record_list',arg.join(','),callback);
+  }
+  
+ 
+}
+
+//=================================================================================================================================
+SalesBrowser.prototype.make_details = function(){
+  var me = this;
+  var callback = function(r,rt){
+
+    me.dtl.innerHTML = "";
+    //me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse'})
+    
+    var h = $a(me.dtl,'h3','',{padding:'4px', margin:'0px',backgroundColor:'#EEEEEE',borderBottom:'1px solid #AAAAAA'});
+    $(h).html(r.message.name);
+    
+    var d = $a(me.dtl,'div');
+    me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse',padding:'4px'})
+    $td(me.dtl_tab,0,0).innerHTML="Parent";
+    if(r.message.parent != '')
+      $td(me.dtl_tab,0,1).innerHTML=": "+r.message.parent;
+    else
+      $td(me.dtl_tab,0,1).innerHTML=": ----";    
+    $td(me.dtl_tab,1,0).innerHTML="Has Child Node";
+    $td(me.dtl_tab,1,1).innerHTML=": "+r.message.is_group;
+   
+
+    me.open_doc = $a(me.dtl,'div','link_type',{paddingTop:'14px'});
+    me.open_doc.innerHTML = "Click here to open "+r.message.name;
+    
+    me.open_doc.onclick = function(){
+      loaddoc(me.sel,r.message.name );
+    }
+  }
+
+  var arg = [this.cur_node.rec.name, this.sel];
+  
+  $c_obj('Sales Browser Control','get_record',arg.join(','),callback);
+
+}
+//=================================================================================================================================
+SalesBrowser.prototype.refresh_tree=function(){
+
+  this.tree_area.innerHTML = '';
+  this.dtl.innerHTML = '';  
+  this.first_level_node();    //set root
+  //hide add, edit, trash buttons
+  //$dh(this.add_btn);
+  $dh(this.edit_btn);
+  $dh(this.trash_btn);
+  
+
+
+}
+
+//=============================== make first level node ================================================
+SalesBrowser.prototype.first_level_node = function(){
+
+  var me = this;
+  var callback = function(r,rt) {
+
+    var cl = r.message.cl;
+
+    for(var i=0;i<cl.length;i++) {
+      var imgsrc=null;
+      var has_children = true;
+
+      if(cl[i].is_group=='No') {
+        var imgsrc = 'images/icons/page.gif';
+        has_children = false;
+      }
+     me.tree_area.innerHTML = ''; 
+     if(me.tree) {
+
+        me.tree.innerHTML = '';
+        me.tree.body.innerHTML = '';
+        
+        me.make_tree();
+      }
+
+      var t = me.tree.addNode(null, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
+      t.rec ={};
+      t.rec.name = cl[i].name;
+      t.has_children = has_children;
+    }
+  }
+
+  $c_obj('Sales Browser Control','get_fl_node',this.sel,callback);
+
+}
+
+//========================================= Dialog Section ===================================================================
+//--------------------------------------------------------------------------------------------------------------------------------
+//========================================================================
+MakeDialog=function(label,field_name,n,cls_obj){
+
+  var new_head = 'Create A New '+label;
+
+  this.label = label;
+
+  this.lbl_rec = label+' Name';
+  this.field_name = field_name;
+  this.n = n;
+  this.cls_obj=cls_obj;
+  //-----------------------------------------------
+ 
+  this.main_dialog = new Dialog(400,300,new_head);      
+  this.set_dg_fields();
+  this.set_dg_values();
+  //-----------------------------------------------
+  this.new_main_dialog = this.main_dialog;
+  
+  this.new_main_dialog.show();
+
+}
+//=================================================================================================================================
+MakeDialog.prototype.set_dg_fields = function(){
+
+  var bd_lst = [];
+  bd_lst.push(['HTML','Heading'],['Data',this.lbl_rec],['Select','Parent'],['Select','Has Child Node']);
+  if(this.cls_obj.sel == 'Sales Person')
+    bd_lst.push(['HTML','','All nodes are allowed in transaction.']);
+  else
+    bd_lst.push(['HTML','','Only leaf nodes are allowed in transaction.']);
+  if(this.n==1)
+    bd_lst.push(['Button','Create']);
+  
+  if(this.n==2){
+    bd_lst.push(['Button','Update']);
+    this.set_edit_fields();
+  }  
+
+  this.main_dialog.make_body(bd_lst);
+  
+  //-----------------------------------------------
+}
+
+
+//==================================================================================================================================== 
+MakeDialog.prototype.set_edit_fields=function(){
+  var me = this;
+  var callback = function(r,rt){
+    
+    me.main_dialog.widgets[me.lbl_rec].value = r.message.name;
+    
+    add_sel_options(me.main_dialog.widgets['Parent'], r.message.parent_lst,r.message.parent);    
+    me.main_dialog.widgets['Has Child Node'].value = r.message.is_group;
+  }
+
+  var arg = [this.cls_obj.cur_node.rec.name, this.cls_obj.sel];
+  
+  $c_obj('Sales Browser Control','get_record',arg.join(','),callback);
+}
+//======================================= Validation - fields entered or not =================================================
+MakeDialog.prototype.validate = function(){
+
+  if(!this.main_dialog.widgets[this.lbl_rec].value) {
+      err_msg1 ='Please enter '+this.label +' Name' 
+      alert(err_msg1); 
+      return 1;
+    }
+    if(!this.main_dialog.widgets['Parent'].value){
+      alert('Please enter Parent Name' );
+      return 1;
+    }
+}
+//==================================================================================================================================== 
+MakeDialog.prototype.set_dg_values = function(){
+  if(this.n==1){
+    var me = this;
+    var callback = function(r,rt){
+      me.main_dialog.widgets[me.lbl_rec].disabled = 0;
+      me.main_dialog.widgets['Parent'].disabled = 0;
+
+      add_sel_options(me.main_dialog.widgets['Parent'],r.message);
+      //add_sel_options(this.main_dialog.widgets['Parent'], [this.cls_obj.cur_node.rec.name]);
+      me.btn_onclick('Create',me.cls_obj);
+    }
+  
+    $c_obj('Sales Browser Control','get_parent_lst',this.cls_obj.sel,callback);
+
+  }  
+  if(this.n == 2){
+    this.main_dialog.widgets[this.lbl_rec].disabled = 1;
+    this.main_dialog.widgets['Parent'].disabled = 0;
+    this.btn_onclick('Update');
+    this.old_value = sel_val(this.main_dialog.widgets['Parent']);
+  }
+
+  add_sel_options(this.main_dialog.widgets['Has Child Node'], ['Yes','No'], 'No');
+
+}
+
+//================================================================================================================================= 
+//-----------------------------------------Dialog button onclick event----------------------------------------------
+MakeDialog.prototype.btn_onclick=function(btn_name){
+  var me = this;
+  this.btn_name = btn_name;
+  this.main_dialog.widgets[this.btn_name].onclick = function() {
+  
+    var callback=function(r,rt){
+      if(r.message == 'true'){
+        me.main_dialog.hide();
+      }
+      else{
+        flag = me.validate();
+        if(flag == 1) return;
+           
+        //---------------------------------------------------------  
+
+        var arg2 = me.make_args();
+        
+        //create Sales Person -- server to Sales Browser Control
+        if(me.btn_name == "Create")
+          method_name = "add_node";
+        else 
+          method_name = "edit_node";       
+           
+        $c_obj('Sales Browser Control',method_name, docstring(arg2), function(r,rt) { 
+          me.main_dialog.widgets[me.lbl_rec].value='';
+          me.main_dialog.hide();
+          /*if(me.btn_name == "Create"){
+            me.cls_obj.cur_node.clear_child_nodes();
+            me.cls_obj.dtl.innerHTML = '';  
+            me.cls_obj.cur_node.expand();
+          }
+          else{
+            me.cls_obj.refresh_tree();   
+          }*/
+          me.cls_obj.refresh_tree(); 
+        });
+      }
+    }
+    var arg1 = {'node_title':me.cls_obj.sel,'is_group':sel_val(me.main_dialog.widgets['Has Child Node']),'lft':0,'rgt':0,'nm':me.main_dialog.widgets[me.lbl_rec].value,'parent_nm':sel_val(me.main_dialog.widgets['Parent']),'action':me.btn_name};
+    $c_obj('Sales Browser Control','mvalidate',docstring(arg1),callback);
+  }
+}
+//=================================================================================================================================
+
+MakeDialog.prototype.make_args = function(){
+  var args ={};   //args making
+  var nt = this.cls_obj.sel;
+  var nm = this.main_dialog.widgets[this.lbl_rec].value;
+  var pnm = sel_val(this.main_dialog.widgets['Parent']);
+  var grp = sel_val(this.main_dialog.widgets['Has Child Node']);
+
+  if(this.n==1)
+    var old_prt ='';
+  else if(this.n==2){
+    if(this.old_value == sel_val(this.main_dialog.widgets['Parent']))
+      var old_prt = '';
+    else
+      var old_prt = this.old_value;
+  }
+  
+  if(this.cls_obj.sel == 'Territory')
+    return {'node_title':nt,'territory_name':nm,'parent_territory':pnm,'is_group':grp,'old_parent':old_prt}
+
+  else if(this.cls_obj.sel == 'Customer Group')
+    return {'node_title':nt,'customer_group_name':nm,'parent_customer_group':pnm,'is_group':grp,'old_parent':old_prt}
+
+  else if(this.cls_obj.sel == 'Item Group')
+    return {'node_title':nt,'item_group_name':nm,'parent_item_group':pnm,'is_group':grp,'old_parent':old_prt}
+
+  else if(this.cls_obj.sel == 'Sales Person')
+    return {'node_title':nt,'sales_person_name':nm,'parent_sales_person':pnm,'is_group':grp,'old_parent':old_prt}
+
+}
\ No newline at end of file
diff --git a/crm/page/sales_browser/sales_browser.txt b/crm/page/sales_browser/sales_browser.txt
new file mode 100644
index 0000000..bdeb236
--- /dev/null
+++ b/crm/page/sales_browser/sales_browser.txt
@@ -0,0 +1 @@
+[{'creation': '2010-06-16 11:44:38', 'module': 'CRM', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Sales Browser', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Sales Browser', 'idx': None, 'static_content': None, 'modified': '2010-11-10 19:21:50', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000140', 'parent': 'Sales Browser', 'creation': '2010-06-16 12:08:31', 'modified': '2010-11-10 19:21:50', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'Administrator', 'name': 'PR000149', 'parent': 'Sales Browser', 'creation': '2010-07-14 15:57:09', 'modified': '2010-11-10 19:21:50', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'Material Master Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/crm/page/sales_dashboard/__init__.py b/crm/page/sales_dashboard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/sales_dashboard/__init__.py
diff --git a/crm/page/sales_dashboard/sales_dashboard.html b/crm/page/sales_dashboard/sales_dashboard.html
new file mode 100644
index 0000000..ec76d44
--- /dev/null
+++ b/crm/page/sales_dashboard/sales_dashboard.html
@@ -0,0 +1,6 @@
+<div class="layout_wrapper">
+<div id="pt_header"></div>
+<div id="pt_filters"></div>
+<p>&nbsp;</p>
+<div id="plot_test"></div>
+</div>
\ No newline at end of file
diff --git a/crm/page/sales_dashboard/sales_dashboard.js b/crm/page/sales_dashboard/sales_dashboard.js
new file mode 100644
index 0000000..cdb5c7c
--- /dev/null
+++ b/crm/page/sales_dashboard/sales_dashboard.js
@@ -0,0 +1,301 @@
+pscript['onload_Sales Dashboard'] = function() {
+  var h = new PageHeader('pt_header','Sales Dashboard');
+  
+  pscript.make_filters(); 
+  $dh(pscript.mnt_div);
+  $dh(pscript.mnt_div1);
+  //pscript.dx_axis = [];
+  
+  if($.jqplot) pscript.all_onchnge();
+  else
+    // import the library
+    $c_js('jquery/jquery.jqplot.min.js', pscript.all_onchnge);
+}
+//=======================================================================
+pscript.make_filters = function(){
+  this.tab = make_table('pt_filters', 2, 4, '800px', ['200px','200px','200px','200px'], {padding: '2px'});
+  pscript.fiscal_year();
+  pscript.report_type();
+  pscript.item_grp();
+  pscript.month_lst();
+}
+//=======================================================================
+
+pscript.fiscal_year=function(){
+  var me = this;
+  $td(this.tab,0,0).innerHTML = "Select Year";
+  this.sel_fy = $a($td(this.tab,1,0), 'select', null, {width:'120px'});
+  $c_obj('Plot Control', 'get_fiscal_year', '', function(r,rt){
+    if(r.message)  fy_lst = r.message;
+    else  fy_lst = [];
+    empty_select(me.sel_fy);
+    add_sel_options(me.sel_fy,fy_lst);
+    me.sel_fy.value = sys_defaults.fiscal_year;
+  });
+  
+}
+
+//=======================================================================
+
+pscript.report_type=function(){
+  $td(this.tab,0,1).innerHTML = "Select Report";
+  this.sel_rpt = $a($td(this.tab,1,1), 'select', null, {width:'120px'});
+  rpt_lst = ['Monthly','Weekly']; 
+  add_sel_options(this.sel_rpt,rpt_lst);
+}
+
+//=======================================================================
+
+pscript.item_grp=function(){
+  var me = this;
+  
+  $td(this.tab,0,2).innerHTML = "Select Item Group";
+  
+  this.sel_grp = $a($td(this.tab,1,2), 'select', null, {width:'120px'});
+  $c_obj('Plot Control', 'get_item_groups', '', function(r,rt){
+    
+    itg_lst = r.message;
+    itg_lst.push('All');
+    
+    empty_select(me.sel_grp);
+    add_sel_options(me.sel_grp, itg_lst.reverse());
+  });
+  
+}
+
+//=======================================================================
+
+pscript.month_lst=function(){
+  pscript.mnt_div1 = $a($td(this.tab,0,3));
+  pscript.mnt_div1.innerHTML = "Select Month";
+  pscript.mnt_div = $a($td(this.tab,1,3));
+  this.sel_mnt = $a(pscript.mnt_div, 'select', null, {width:'120px'});
+  mnt_lst = ['All','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; 
+  add_sel_options(this.sel_mnt,mnt_lst);
+}
+
+//=======================================================================
+pscript.all_onchnge = function(){
+  pscript.report_change();
+  pscript.fiscal_year_onchnage();
+  pscript.month_onchange();
+  pscript.item_grp_onchange();
+  pscript.monthly();
+}
+
+//=======================================================================
+pscript.report_change = function(){
+  var me = this;
+  this.sel_rpt.onchange = function(){
+    
+    $dh(pscript.mnt_div);
+    $dh(pscript.mnt_div1);
+    if(me.sel_rpt.value == 'Monthly'){
+      
+      pscript.monthly();
+    }
+    
+    else if(me.sel_rpt.value == 'Weekly'){
+      $ds(pscript.mnt_div); 
+      $ds(pscript.mnt_div1);
+      me.sel_mnt.value = 'All';
+      pscript.get_x_dates();
+
+    }
+    
+    else{
+      me.sel_mnt.value = 'All';
+      $i('plot_test').innerHTML = '';
+    }
+  }
+
+}
+//=======================================================================
+pscript.fiscal_year_onchnage = function(){
+  var me = this;
+  this.sel_fy.onchange = function(){ 
+
+    if(me.sel_rpt.value == 'Monthly'){
+      
+      me.sel_mnt.value = 'All';
+      $dh(pscript.mnt_div); 
+      $dh(pscript.mnt_div1);     
+      pscript.monthly();
+    }
+    else if(me.sel_rpt.value == 'Weekly' && me.sel_mnt.value){
+    
+      pscript.get_x_dates();
+      
+    }
+    
+    else{
+      me.sel_mnt.value = 'All';
+      me.sel_rpt.value == '';
+      $i('plot_test').innerHTML = '';
+      
+    }
+  }
+
+}
+//=======================================================================
+pscript.month_onchange = function(){
+  this.sel_mnt.onchange = function(){
+    pscript.get_x_dates();
+    
+  }
+}
+//=======================================================================
+
+pscript.item_grp_onchange=function(){
+  var me = this;
+  this.sel_grp.onchange = function(){
+  
+    if(me.sel_rpt.value == 'Monthly'){
+      
+      me.sel_mnt.value = 'All';
+      $dh(pscript.mnt_div); 
+      $dh(pscript.mnt_div1);     
+      pscript.monthly();
+    }
+    else if(me.sel_rpt.value == 'Weekly' && me.sel_mnt.value){
+    
+      pscript.get_x_dates();
+      
+    }
+    
+    else{
+      me.sel_mnt.value = 'All';
+      me.sel_rpt.value == '';
+      $i('plot_test').innerHTML = '';
+      
+    }
+  }
+    
+  }
+
+//=======================================================================
+
+pscript.get_x_dates=function(){
+  
+  if(this.sel_mnt.value !='All'){
+    
+    pscript.weekly();
+  }
+  else{ 
+    
+    $c_obj('Plot Control','yr_wk_dates',this.sel_fy.value,
+      function(r,rt){
+        
+        pscript.dx_axis = r.message[0];
+        
+        pscript.x_axis = r.message[1];
+        
+        pscript.yearly();
+      }
+    );
+    
+  }
+}
+
+//=======================================================================
+pscript.draw_graph1 = function(x_axis,line1,t) {
+  
+  t = t + " ("+sys_defaults.currency +")";
+  $i('plot_test').innerHTML = '';
+  // div plot_test contains the container div
+  $.jqplot('plot_test',  [line1],{
+    title:t,
+    axesDefaults: {
+      min:0  
+    },
+    
+    axes:{ 
+      xaxis:{ticks:x_axis}
+    }
+  });
+}
+//=======================================================================
+pscript.monthly = function(){
+  var callback = function(r,rt){
+    x_axis = r.message.x_axis;
+    msg_data = r.message.msg_data; 
+    
+    var line1 = [];
+    for(var i=0; i<x_axis.length;i++){
+      var f =0
+      for(var j=0; j<msg_data.length;j++){
+        if(msg_data[j] && x_axis[i]){
+          if(x_axis[i][1] == msg_data[j][1])
+          { 
+            line1.push([i+1,flt(msg_data[j][0])]);
+            f = 1
+          }
+          
+        }
+      }
+      if(f == 0){
+        line1.push([i+1,0]);
+      }
+    }
+    pscript.draw_graph1(x_axis,line1,'Monthly Sales');
+  }
+  var val2 = '';
+  if(this.sel_grp.value != 'All') val2 = this.sel_grp.value;
+  $c_obj('Plot Control','get_monthwise_amount',[this.sel_fy.value,val2],callback);
+}
+
+//=======================================================================
+
+pscript.weekly = function(){
+  
+  var callback = function(r,rt){
+    
+    x_axis =[[1,'Week1'],[2,'Week2'],[3,'Week3'],[4,'Week4'],[5,'Week5'],[6,'Week6']];
+    var line1 = [];
+    for(var i=0; i<x_axis.length;i++){
+      var f = 0;
+      for(var j=0; j<r.message.length;j++){
+        if(r.message[j]){
+          if(r.message[j][1] == x_axis[i][1]){ line1.push([i+1,flt(r.message[j][0])]); f=1;}}
+      }
+      if(f == 0){
+        line1.push([i+1,0]);
+      }
+    }
+    
+    pscript.draw_graph1(x_axis,line1,'Weekly Sales');
+  }
+  dict_mnt={'Jan':1,'Feb':2,'Mar':3,'Apr':4,'May':5,'Jun':6,'Jul':7,'Aug':8,'Sep':9,'Oct':10,'Nov':11,'Dec':12};
+  var val3 = '';
+  if(this.sel_grp.value != 'All') val3 = this.sel_grp.value;
+  $c_obj('Plot Control','get_weekwise_amount',[dict_mnt[this.sel_mnt.value],this.sel_fy.value,val3],callback);
+}
+
+//=======================================================================
+
+pscript.yearly = function(){
+  
+  var callback = function(r,rt){
+      
+    var line1 = [];
+    for(var i=0; i<pscript.x_axis.length;i++){
+      var f = 0
+      for(var j=0; j<r.message.length;j++){
+        if(r.message[j]){
+
+          if((r.message[j][1] == pscript.x_axis[i][1]) && (r.message[j][2] == pscript.x_axis[i][2])){ line1.push([pscript.x_axis[i][0],r.message[j][0]]); break; f =1;}
+      }
+      }
+      if(f == 0){
+        line1.push([pscript.x_axis[i][0],0]);
+      }
+    }
+    
+    pscript.draw_graph1(pscript.dx_axis,line1,'Year-Weekly Sales');
+  }
+  var val2 = '';
+  if(this.sel_grp.value != 'All') val2 = this.sel_grp.value;
+  
+  
+  $c_obj('Plot Control','get_year_weekwise_amount',[this.sel_fy.value,val2],callback);
+} 
\ No newline at end of file
diff --git a/crm/page/sales_dashboard/sales_dashboard.txt b/crm/page/sales_dashboard/sales_dashboard.txt
new file mode 100644
index 0000000..c08615a
--- /dev/null
+++ b/crm/page/sales_dashboard/sales_dashboard.txt
@@ -0,0 +1 @@
+[{'creation': '2010-05-21 13:56:25', 'module': 'CRM', 'doctype': 'Page', 'owner': 'harshada@webnotestech.com', 'style': None, 'modified_by': 'saumil@webnotestech.com', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Sales Dashboard', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Sales Dashboard', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000136', 'parent': 'Sales Dashboard', 'creation': '2010-05-21 13:56:25', 'modified': '2010-08-08 00:01:08', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Sales Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/crm/search_criteria/__init__.py b/crm/search_criteria/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/__init__.py
diff --git a/crm/search_criteria/delivered_items_to_be_install/__init__.py b/crm/search_criteria/delivered_items_to_be_install/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/delivered_items_to_be_install/__init__.py
diff --git a/crm/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.js b/crm/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.js
new file mode 100644
index 0000000..d8b6476
--- /dev/null
+++ b/crm/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.js
@@ -0,0 +1,4 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
+}
\ No newline at end of file
diff --git a/crm/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.txt b/crm/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.txt
new file mode 100644
index 0000000..13dd74b
--- /dev/null
+++ b/crm/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': "(`tabDelivery Note Detail`.`qty`- ifnull(`tabDelivery Note Detail`.`installed_qty`, 0)) AS 'Pending to Install'",
+		'add_cond': '`tabDelivery Note Detail`.`qty` > ifnull(`tabDelivery Note Detail`.`installed_qty`, 0)',
+		'add_tab': None,
+		'columns': 'Delivery Note\x01ID,Delivery Note\x01Status,Delivery Note\x01Customer,Delivery Note\x01Customer Name,Delivery Note\x01Contact Person,Delivery Note\x01Voucher Date,Delivery Note Detail\x01Item Code,Delivery Note Detail\x01Item Name,Delivery Note Detail\x01Quantity,Delivery Note Detail\x01Installed Qty,Delivery Note\x01% Installed',
+		'creation': '2011-05-09 11:04:19',
+		'criteria_name': 'Delivered Items to be Install',
+		'custom_query': '',
+		'description': 'Delivered Items to be Install',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Delivery Note Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Delivery Note\x01Saved':1,'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2011-03-29 14:08:46',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'delivered_items_to_be_install',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Delivery Note',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabDelivery Note`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/delivery_note_itemwise_pending_to_bill/__init__.py b/crm/search_criteria/delivery_note_itemwise_pending_to_bill/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/delivery_note_itemwise_pending_to_bill/__init__.py
diff --git a/crm/search_criteria/delivery_note_itemwise_pending_to_bill/delivery_note_itemwise_pending_to_bill.txt b/crm/search_criteria/delivery_note_itemwise_pending_to_bill/delivery_note_itemwise_pending_to_bill.txt
new file mode 100644
index 0000000..732281c
--- /dev/null
+++ b/crm/search_criteria/delivery_note_itemwise_pending_to_bill/delivery_note_itemwise_pending_to_bill.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': "SUM(`tabDelivery Note Detail`.`qty` - `tabDelivery Note Detail`.`billed_qty`) AS 'Pending Qty'\nSUM((`tabDelivery Note Detail`.`qty` - `tabDelivery Note Detail`.`billed_qty`) * `tabDelivery Note Detail`.`basic_rate`) AS 'Pending Amount'",
+		'add_cond': "`tabDelivery Note`.status != 'Stopped'\nCASE WHEN `tabDelivery Note`.`per_billed` IS NULL OR `tabDelivery Note`.per_billed = '' THEN 0 < 100 ELSE `tabDelivery Note`.per_billed <100 END",
+		'add_tab': None,
+		'columns': 'Delivery Note\x01ID,Delivery Note\x01Owner,Delivery Note\x01Status,Delivery Note\x01Customer Name,Delivery Note\x01Voucher Date,Delivery Note\x01% Billed,Delivery Note\x01Posting Date,Delivery Note\x01Company Name,Delivery Note\x01Fiscal Year,Delivery Note Detail\x01Item Code,Delivery Note Detail\x01Against Document No,Delivery Note Detail\x01Document Type,Delivery Note Detail\x01Against Document Detail No',
+		'creation': '2010-08-08 17:09:31',
+		'criteria_name': 'Delivery Note Itemwise Pending To Bill',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Delivery Note Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Delivery Note\x01Saved':1,'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Company Name':'','Delivery Note\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '`tabDelivery Note Detail`.item_code, `tabDelivery Note`.`name`',
+		'idx': None,
+		'modified': '2010-04-06 17:22:13',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'delivery_note_itemwise_pending_to_bill',
+		'owner': 'jai@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Delivery Note',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': '',
+		'server_script': None,
+		'sort_by': '`tabDelivery Note`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/draft_sales_orders/__init__.py b/crm/search_criteria/draft_sales_orders/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/draft_sales_orders/__init__.py
diff --git a/crm/search_criteria/draft_sales_orders/draft_sales_orders.js b/crm/search_criteria/draft_sales_orders/draft_sales_orders.js
new file mode 100644
index 0000000..0e73442
--- /dev/null
+++ b/crm/search_criteria/draft_sales_orders/draft_sales_orders.js
@@ -0,0 +1,6 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df['report_default'] = sys_defaults.year_start_date;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df['report_default'] = dateutil.obj_to_str(new Date());
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+
+}
\ No newline at end of file
diff --git a/crm/search_criteria/draft_sales_orders/draft_sales_orders.txt b/crm/search_criteria/draft_sales_orders/draft_sales_orders.txt
new file mode 100644
index 0000000..84dc8fe
--- /dev/null
+++ b/crm/search_criteria/draft_sales_orders/draft_sales_orders.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Status,Sales Order\x01Sales Order Date,Sales Order\x01Customer,Sales Order\x01P.O. No,Sales Order\x01Grand Total',
+		'creation': '2010-08-08 17:09:31',
+		'criteria_name': 'Draft Sales Orders',
+		'custom_query': '',
+		'description': 'List of Open Sales orders filtered by period, customer and other details',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Submitted':1,'Sales Order\x01Status':'Draft','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-06-01 15:19:41',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'draft_sales_orders',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/follow_up_report/__init__.py b/crm/search_criteria/follow_up_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/follow_up_report/__init__.py
diff --git a/crm/search_criteria/follow_up_report/follow_up_report.js b/crm/search_criteria/follow_up_report/follow_up_report.js
new file mode 100644
index 0000000..9497efb
--- /dev/null
+++ b/crm/search_criteria/follow_up_report/follow_up_report.js
@@ -0,0 +1,47 @@
+report.customize_filters = function() {
+  this.mytabs.items['Select Columns'].hide()
+  this.mytabs.items['More Filters'].hide()
+  
+  this.hide_all_filters();
+  this.add_filter({fieldname:'follow_up_on', label:'Follow up on', fieldtype:'Select', options:''+NEWLINE+'Lead'+NEWLINE+'Enquiry'+NEWLINE+'Quotation',ignore : 1,parent:'Follow up', in_first_page : 1, single_select :1});
+  this.add_filter({fieldname:'lead_name', label:'Lead', fieldtype:'Link', options:'Lead', report_default:'', ignore : 1, parent:'Follow up', in_first_page : 1});
+  this.add_filter({fieldname:'enq_name', label:'Enquiry', fieldtype:'Link', options:'Enquiry', report_default:'', ignore : 1, parent:'Follow up', in_first_page : 1});
+  this.add_filter({fieldname:'qtn_name', label:'Quotation', fieldtype:'Link', options:'Quotation', report_default:'', ignore : 1, parent:'Follow up', in_first_page : 1});
+  
+  this.get_filter('Follow up', 'Follow up type').set_as_single();
+  this.set_filter_properties('Follow up', 'Follow up by', {filter_hide:0, in_first_page : 1});
+  this.set_filter_properties('Follow up', 'Follow up type', {filter_hide:0, in_first_page : 1});
+  this.set_filter_properties('Follow up', 'From Date', {filter_hide:0, in_first_page : 1});
+  this.set_filter_properties('Follow up', 'To Date', {filter_hide:0, in_first_page : 1});
+
+  this.orig_sort_list = [['Date','`tabFollow up`.`date`'],['Document Type','`tabFollow up`.`parenttype`'],['Document','`tabFollow up`.`parent`'],['Follow Up By','`tabFollow up`.`follow_up_by`'],['Follow Up Type','`tabFollow up`.`follow_up_type`']];
+}
+
+
+report.get_query = function() {
+  var lead_id = this.filter_fields_dict['Follow up'+FILTER_SEP+'Lead'].get_value();
+  var enq_id = this.filter_fields_dict['Follow up'+FILTER_SEP+'Enquiry'].get_value();
+  var quo_id = this.filter_fields_dict['Follow up'+FILTER_SEP+'Quotation'].get_value();
+
+  var follow_up_on = this.filter_fields_dict['Follow up'+FILTER_SEP+'Follow up on'].get_value();
+  var follow_up_by = this.filter_fields_dict['Follow up'+FILTER_SEP+'Follow up by'].get_value();
+
+  var on_type = this.filter_fields_dict['Follow up'+FILTER_SEP+'Follow up type'].get_value();
+  var from_date = this.filter_fields_dict['Follow up'+FILTER_SEP+'From Date'].get_value();
+  var to_date = this.filter_fields_dict['Follow up'+FILTER_SEP+'To Date'].get_value();
+  
+  var cond = 'parenttype IN ("Lead","Enquiry","Quotation")';
+  if(follow_up_on) cond = 'parenttype = "'+follow_up_on+'"';
+
+  if((follow_up_on == 'Lead' && lead_id) || (lead_id && !follow_up_on)) cond +=' AND parent = "'+lead_id+'"';
+  if((follow_up_on == 'Enquiry' && enq_id) || (enq_id && !follow_up_on)) cond +=' AND parent = "'+enq_id+'"';
+  if((follow_up_on == 'Quotation' && quo_id) || (quo_id && !follow_up_on)) cond +=' AND parent = "'+quo_id+'"';
+
+  if(on_type) cond += ' AND follow_up_type ="'+on_type+'"';
+  if(from_date) cond += ' AND date >="'+from_date+'"';
+  if(to_date) cond += ' AND date <="'+to_date+'"';
+  if(follow_up_by) cond += ' AND follow_up_by = "'+follow_up_by+'"';
+
+  var q ='SELECT distinct `tabFollow up`.`parenttype`, `tabFollow up`.`parent`, `tabFollow up`.`date`, `tabFollow up`.`notes`, `tabFollow up`.`follow_up_type`, `tabFollow up`.`follow_up_by` FROM `tabFollow up` WHERE '+cond+' ORDER BY '+sel_val(this.dt.sort_sel)+' '+this.dt.sort_order;
+  return q;
+}
diff --git a/crm/search_criteria/follow_up_report/follow_up_report.py b/crm/search_criteria/follow_up_report/follow_up_report.py
new file mode 100644
index 0000000..1dcbeb0
--- /dev/null
+++ b/crm/search_criteria/follow_up_report/follow_up_report.py
@@ -0,0 +1,16 @@
+follow_up_on = filter_values.get('follow_up_on')
+
+cols = [['Document Type', 'Data', '150px', '']
+        ,['Document', 'Link', '150px', follow_up_on]
+        ,['Follow Up Date', 'Date', '150px', '']
+        ,['Description','Data','300px','']
+        ,['Follow Up Type','Data','150px','']
+        ,['Follow Up By','Link','150px','Sales Person']
+       ]
+
+for c in cols:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  col_idx[c[0]] = len(colnames)-1
diff --git a/crm/search_criteria/follow_up_report/follow_up_report.txt b/crm/search_criteria/follow_up_report/follow_up_report.txt
new file mode 100644
index 0000000..0da414b
--- /dev/null
+++ b/crm/search_criteria/follow_up_report/follow_up_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Lead\x01ID,Follow up\x01Date,Follow up\x01Notes,Follow up\x01Follow up type',
+		'creation': '2010-08-13 11:09:21',
+		'criteria_name': 'Follow-up Report',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Follow up',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Lead\x01Status':'','Lead\x01Source':'','Lead\x01Lead Type':'','Lead\x01Rating':'','Lead\x01Market Segment':'','Lead\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-08-12 16:33:19',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'follow-up_report',
+		'owner': 'ashwini@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Lead',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabLead`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/gross_profit/__init__.py b/crm/search_criteria/gross_profit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/gross_profit/__init__.py
diff --git a/crm/search_criteria/gross_profit/gross_profit.js b/crm/search_criteria/gross_profit/gross_profit.js
new file mode 100644
index 0000000..e610408
--- /dev/null
+++ b/crm/search_criteria/gross_profit/gross_profit.js
@@ -0,0 +1,16 @@
+report.customize_filters = function() {
+  this.mytabs.items['Select Columns'].hide();
+  this.mytabs.tabs['More Filters'].hide();
+  this.hide_all_filters();
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'ID'].df.filter_hide = 0;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
+  this.filter_fields_dict['Delivery Note Detail'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Project Name'].df.filter_hide = 0;
+
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'ID'].df.in_first_page = 1;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
+  this.filter_fields_dict['Delivery Note Detail'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Project Name'].df.in_first_page = 1;
+}
\ No newline at end of file
diff --git a/crm/search_criteria/gross_profit/gross_profit.py b/crm/search_criteria/gross_profit/gross_profit.py
new file mode 100644
index 0000000..04f0220
--- /dev/null
+++ b/crm/search_criteria/gross_profit/gross_profit.py
@@ -0,0 +1,61 @@
+# Add Columns
+# ------------
+colnames[colnames.index('Rate*')] = 'Rate' 
+col_idx['Rate'] = col_idx['Rate*']
+col_idx.pop('Rate*')
+colnames[colnames.index('Amount*')] = 'Amount' 
+col_idx['Amount'] = col_idx['Amount*']
+col_idx.pop('Amount*')
+
+columns = [['Valuation Rate','Currency','150px',''],
+           ['Valuation Amount','Currency','150px',''],
+           ['Gross Profit (%)','Currrency','150px',''],
+           ['Gross Profit','Currency','150px','']]
+
+for c in columns:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  col_idx[c[0]] = len(colnames)-1
+
+out, tot_amount, tot_val_amount, tot_gross_profit = [], 0, 0, 0
+
+for r in res:
+  tot_val_rate = 0
+  packing_list_items = sql("select item_code, warehouse, qty from `tabDelivery Note Packing Detail` where parent = %s and parent_item = %s", (r[col_idx['ID']], r[col_idx['Item Code']]))
+  for d in packing_list_items:
+    if d[1]:
+      val_rate = sql("select valuation_rate from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and voucher_type = 'Delivery Note' and voucher_no = %s and is_cancelled = 'No'", (d[0], d[1], r[col_idx['ID']]))
+      val_rate = val_rate and val_rate[0][0] or 0
+      if r[col_idx['Quantity']]: tot_val_rate += (flt(val_rate) * flt(d[2]) / flt(r[col_idx['Quantity']]))
+      else: tot_val_rate = 0
+
+  r.append(fmt_money(tot_val_rate))
+
+  val_amount = flt(tot_val_rate) * flt(r[col_idx['Quantity']])
+  r.append(fmt_money(val_amount))
+
+  gp = flt(r[col_idx['Amount']]) - flt(val_amount)
+  
+  if val_amount: gp_percent = gp * 100 / val_amount
+  else: gp_percent = gp
+  
+  r.append(fmt_money(gp_percent))
+  r.append(fmt_money(gp))
+  out.append(r)
+
+  tot_gross_profit += flt(gp)
+  tot_amount += flt(r[col_idx['Amount']])
+  tot_val_amount += flt(val_amount)  
+
+# Add Total Row
+# --------------
+l_row = ['' for i in range(len(colnames))]
+l_row[col_idx['Quantity']] = '<b>TOTALS</b>'
+l_row[col_idx['Amount']] = fmt_money(tot_amount)
+l_row[col_idx['Valuation Amount']] = fmt_money(tot_val_amount)
+if tot_val_amount: l_row[col_idx['Gross Profit (%)']] = fmt_money((tot_amount - tot_val_amount) * 100 / tot_val_amount)
+else: l_row[col_idx['Gross Profit (%)']] = fmt_money(tot_amount)
+l_row[col_idx['Gross Profit']] = fmt_money(tot_gross_profit)
+out.append(l_row)
\ No newline at end of file
diff --git a/crm/search_criteria/gross_profit/gross_profit.txt b/crm/search_criteria/gross_profit/gross_profit.txt
new file mode 100644
index 0000000..9e3857c
--- /dev/null
+++ b/crm/search_criteria/gross_profit/gross_profit.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Delivery Note\x01ID,Delivery Note\x01Posting Date,Delivery Note\x01Posting Time,Delivery Note Detail\x01Item Code,Delivery Note Detail\x01Item Name,Delivery Note Detail\x01Description,Delivery Note\x01Project Name,Delivery Note Detail\x01Quantity,Delivery Note Detail\x01Rate*,Delivery Note Detail\x01Amount*',
+		'creation': '2010-12-14 10:33:09',
+		'criteria_name': 'Gross Profit',
+		'custom_query': '',
+		'description': 'Invoice wise',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Delivery Note Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-11-10 12:39:03',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'gross_profit',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Delivery Note',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabDelivery Note`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/itemwise_delivery_details/__init__.py b/crm/search_criteria/itemwise_delivery_details/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/itemwise_delivery_details/__init__.py
diff --git a/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.js b/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.js
new file mode 100644
index 0000000..df3b401
--- /dev/null
+++ b/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.js
@@ -0,0 +1,7 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Voucher Date'].df['report_default'] = sys_defaults.year_start_date;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Voucher Date'].df['report_default'] = dateutil.obj_to_str(new Date());
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
+  this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
+
+}
\ No newline at end of file
diff --git a/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.py b/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.py
new file mode 100644
index 0000000..55041e4
--- /dev/null
+++ b/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.py
@@ -0,0 +1,17 @@
+out=[]
+qty,amt,bil_qty=0,0,0
+
+for r in res:
+  qty += flt(r[col_idx['Quantity']])
+  amt += flt(r[col_idx['Amount*']])
+  bil_qty += flt(r[col_idx['Billed Qty']])
+  out.append(r)
+
+
+#Add the totals row
+l_row = ['' for i in range(len(colnames))]
+l_row[col_idx['Item Name']] = '<b>TOTALS</b>'
+l_row[col_idx['Quantity']] = qty
+l_row[col_idx['Amount*']] = amt
+l_row[col_idx['Billed Qty']] = bil_qty
+out.append(l_row)
\ No newline at end of file
diff --git a/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.txt b/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.txt
new file mode 100644
index 0000000..6a6cac9
--- /dev/null
+++ b/crm/search_criteria/itemwise_delivery_details/itemwise_delivery_details.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Delivery Note\x01ID,Delivery Note Detail\x01Item Code,Delivery Note Detail\x01Item Name,Delivery Note Detail\x01Quantity,Delivery Note Detail\x01Rate*,Delivery Note Detail\x01Amount*,Delivery Note Detail\x01Billed Qty,Delivery Note\x01Company',
+		'creation': '2010-11-10 15:04:42',
+		'criteria_name': 'Itemwise Delivery Details',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Delivery Note Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01From Voucher Date\x01lower':'','Delivery Note\x01To Voucher Date\x01upper':'','Delivery Note\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-10-26 09:10:53',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'itemwise_delivery_details',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Delivery Note',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabDelivery Note`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/itemwise_sales_details/__init__.py b/crm/search_criteria/itemwise_sales_details/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/itemwise_sales_details/__init__.py
diff --git a/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.js b/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.js
new file mode 100644
index 0000000..43a6951
--- /dev/null
+++ b/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.js
@@ -0,0 +1,11 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'ID'].df.in_first_page = 1;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df['report_default'] = sys_defaults.year_start_date;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df['report_default'] = dateutil.obj_to_str(new Date());
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+  this.filter_fields_dict['Sales Order Detail'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Status'].df.filter_hide = 1;
+}
+
+//this.mytabs.items['Select Columns'].hide();
+this.mytabs.items['More Filters'].hide();
\ No newline at end of file
diff --git a/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.py b/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.py
new file mode 100644
index 0000000..e85302c
--- /dev/null
+++ b/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.py
@@ -0,0 +1,19 @@
+out=[]
+qty,amt,del_qty,bil_qty=0,0,0,0
+
+for r in res:
+  qty += flt(r[col_idx['Quantity']])
+  amt += flt(r[col_idx['Amount*']])
+  del_qty += flt(r[col_idx['Delivered Qty']])
+  bil_qty += flt(r[col_idx['Billed Qty']])
+  out.append(r)
+
+
+#Add the totals row
+l_row = ['' for i in range(len(colnames))]
+l_row[col_idx['Item Name']] = '<b>TOTALS</b>'
+l_row[col_idx['Quantity']] = qty
+l_row[col_idx['Amount*']] = amt
+l_row[col_idx['Delivered Qty']] = del_qty
+l_row[col_idx['Billed Qty']] = bil_qty
+out.append(l_row)
\ No newline at end of file
diff --git a/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.txt b/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.txt
new file mode 100644
index 0000000..00a5341
--- /dev/null
+++ b/crm/search_criteria/itemwise_sales_details/itemwise_sales_details.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Customer,Sales Order Detail\x01Item Code,Sales Order Detail\x01Item Name,Sales Order Detail\x01Quantity,Sales Order Detail\x01Basic Rate*,Sales Order Detail\x01Amount*,Sales Order Detail\x01Delivered Qty,Sales Order Detail\x01Billed Qty,Sales Order\x01Company',
+		'creation': '2010-09-01 15:47:57',
+		'criteria_name': 'Itemwise Sales Details',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Status':'','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '',
+		'idx': None,
+		'modified': '2010-08-30 12:22:47',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'itemwise_sales_details',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/monthly_despatched_trend/__init__.py b/crm/search_criteria/monthly_despatched_trend/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/monthly_despatched_trend/__init__.py
diff --git a/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.js b/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.js
new file mode 100644
index 0000000..ca88e29
--- /dev/null
+++ b/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.js
@@ -0,0 +1,2 @@
+this.mytabs.items['Select Columns'].hide();
+this.mytabs.items['More Filters'].hide();
\ No newline at end of file
diff --git a/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.py b/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.py
new file mode 100644
index 0000000..8aed5a2
--- /dev/null
+++ b/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.py
@@ -0,0 +1,7 @@
+total = 0.0
+monthlist = ['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
+for r in res:
+  r[0] = monthlist[r[0]]
+  total += r[1]
+
+colwidths[col_idx['Total Despatched']] = '200px'
\ No newline at end of file
diff --git a/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.txt b/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.txt
new file mode 100644
index 0000000..99504e9
--- /dev/null
+++ b/crm/search_criteria/monthly_despatched_trend/monthly_despatched_trend.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': "month(`tabDelivery Note`.posting_date) AS 'Sales Month'\nsum(`tabDelivery Note`.net_total) AS 'Total Despatched'",
+		'add_cond': '`tabDelivery Note`.net_total > 10',
+		'add_tab': None,
+		'columns': '',
+		'creation': '2010-08-08 17:09:31',
+		'criteria_name': 'Monthly Despatched Trend',
+		'custom_query': '',
+		'description': 'Monthly Despatched Trend',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Delivery Note',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Chargeable':'Yes','Delivery Note\x01Department':'','Delivery Note\x01Type':'','Delivery Note\x01Company Name':'Janak Healthcare Pvt Ltd','Delivery Note\x01Fiscal Year':'2009-2010'}",
+		'graph_series': 'Despatched Month',
+		'graph_values': 'Total Despatched',
+		'group_by': 'month(`tabDelivery Note`.Posting_date)',
+		'idx': None,
+		'modified': '2010-06-07 15:19:13',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'monthly_despatched_trend',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`Sales Month`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/periodic_sales_summary/__init__.py b/crm/search_criteria/periodic_sales_summary/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/periodic_sales_summary/__init__.py
diff --git a/crm/search_criteria/periodic_sales_summary/periodic_sales_summary.js b/crm/search_criteria/periodic_sales_summary/periodic_sales_summary.js
new file mode 100644
index 0000000..04d2755
--- /dev/null
+++ b/crm/search_criteria/periodic_sales_summary/periodic_sales_summary.js
@@ -0,0 +1,19 @@
+report.customize_filters = function() {
+  this.hide_all_filters();
+  this.add_filter({fieldname:'transaction_date', label:'Sales Order Date', fieldtype:'Date', parent:'Sales Order', in_first_page : 1,default:''});
+  
+  //this.filter_fields_dict['Sales Order'+FILTER_SEP +'Territory'].df.filter_hide = 0;
+  //this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Order Date'].df.filter_hide = 0;
+  //this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Order Date'].df.in_first_page = 1;
+  
+  this.filter_fields_dict['Sales Order Detail'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
+  this.filter_fields_dict['Sales Order Detail'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
+
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df.filter_hide = 0;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df.in_first_page = 1;
+
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+
+  //this.mytabs.items['Select Columns'].hide();
+  //this.mytabs.items['More Filters'].hide();
+}
\ No newline at end of file
diff --git a/crm/search_criteria/periodic_sales_summary/periodic_sales_summary.txt b/crm/search_criteria/periodic_sales_summary/periodic_sales_summary.txt
new file mode 100644
index 0000000..d3099d5
--- /dev/null
+++ b/crm/search_criteria/periodic_sales_summary/periodic_sales_summary.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': '',
+		'add_tab': None,
+		'columns': 'Sales Order Detail\x01Item Code,Sales Order Detail\x01Quantity,Sales Order Detail\x01Delivered Qty,Sales Order Detail\x01Billed Qty',
+		'creation': '2010-08-08 17:09:31',
+		'criteria_name': 'Periodic Sales Summary',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': 'fiscal_year',
+		'disabled': 1,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Company Name':'','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '`tabSales Order Detail`.`item_code`',
+		'idx': None,
+		'modified': '2010-06-03 13:09:00',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'periodic_sales_summary',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': '',
+		'sort_by': '`tabSales Order Detail`.`item_code`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_agentwise_commission/__init__.py b/crm/search_criteria/sales_agentwise_commission/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_agentwise_commission/__init__.py
diff --git a/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.js b/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.js
new file mode 100644
index 0000000..4cb0f3d
--- /dev/null
+++ b/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.js
@@ -0,0 +1,9 @@
+report.customize_filters = function() {
+  this.hide_all_filters();
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Partner'].df.filter_hide = 0;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Partner'].df.in_first_page = 1;
+}
+
+
+this.mytabs.items['Select Columns'].hide();
+this.mytabs.items['More Filters'].hide();
\ No newline at end of file
diff --git a/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.py b/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.py
new file mode 100644
index 0000000..4412f6c
--- /dev/null
+++ b/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.py
@@ -0,0 +1,8 @@
+coltypes[col_idx['Average Commission Rate']] = 'Currency'
+colwidths[col_idx['Average Commission Rate']] = '200px'
+
+coltypes[col_idx['Net Total']] = 'Currency'
+colwidths[col_idx['Net Total']] = '150px'
+
+coltypes[col_idx['Total Commission']] = 'Currency'
+colwidths[col_idx['Total Commission']] = '150px'
diff --git a/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.txt b/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.txt
new file mode 100644
index 0000000..27a0dbe
--- /dev/null
+++ b/crm/search_criteria/sales_agentwise_commission/sales_agentwise_commission.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': "SUM(`tabSales Order`.`total_commission`) AS 'Total Commission'\nSUM(`tabSales Order`.`net_total`) AS 'Net Total'\n((SUM(`tabSales Order`.`total_commission`) / SUM(`tabSales Order`.`net_total`)) * 100) AS 'Average Commission Rate'",
+		'add_cond': '`tabSales Order`.`net_total` > 0',
+		'add_tab': None,
+		'columns': 'Sales Order\x01Business Associate',
+		'creation': '2010-08-26 11:52:27',
+		'criteria_name': 'Sales Agentwise Commission',
+		'custom_query': '',
+		'description': 'Sales Agentwise Commission',
+		'dis_filters': None,
+		'disabled': 1,
+		'doc_type': 'Sales Order',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Submitted':1}",
+		'graph_series': '',
+		'graph_values': '',
+		'group_by': '`tabSales Order`.`sales_partner`',
+		'idx': None,
+		'modified': '2010-08-26 11:48:17',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_agentwise_commission',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_order_pending_items1/__init__.py b/crm/search_criteria/sales_order_pending_items1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_order_pending_items1/__init__.py
diff --git a/crm/search_criteria/sales_order_pending_items1/sales_order_pending_items1.js b/crm/search_criteria/sales_order_pending_items1/sales_order_pending_items1.js
new file mode 100644
index 0000000..46d4b2b
--- /dev/null
+++ b/crm/search_criteria/sales_order_pending_items1/sales_order_pending_items1.js
@@ -0,0 +1,4 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
+}
\ No newline at end of file
diff --git a/crm/search_criteria/sales_order_pending_items1/sales_order_pending_items1.txt b/crm/search_criteria/sales_order_pending_items1/sales_order_pending_items1.txt
new file mode 100644
index 0000000..1ea02d9
--- /dev/null
+++ b/crm/search_criteria/sales_order_pending_items1/sales_order_pending_items1.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': '(`tabSales Order Detail`.qty - ifnull(`tabSales Order Detail`.delivered_qty, 0)) AS "Qty To Deliver"\n(`tabSales Order Detail`.qty - ifnull(`tabSales Order Detail`.billed_qty, 0)) AS "Qty To Bill"\n(`tabSales Order Detail`.qty - ifnull(`tabSales Order Detail`.delivered_qty, 0))*`tabSales Order Detail`.basic_rate AS "Amount To Deliver"\n(`tabSales Order Detail`.qty - ifnull(`tabSales Order Detail`.billed_qty, 0))*`tabSales Order Detail`.basic_rate AS "Amount To Bill"',
+		'add_cond': '(`tabSales Order Detail`.qty - ifnull(`tabSales Order Detail`.delivered_qty, 0) > 0 or `tabSales Order Detail`.qty - ifnull(`tabSales Order Detail`.billed_qty, 0) > 0)\n`tabSales Order`.status != "Stopped"',
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Sales Order Date,Sales Order\x01Customer,Sales Order\x01Customer Name,Sales Order Detail\x01Item Code,Sales Order Detail\x01Item Name,Sales Order Detail\x01Description,Sales Order Detail\x01Quantity,Sales Order Detail\x01Delivered Qty,Sales Order Detail\x01Billed Qty',
+		'creation': '2011-05-09 11:04:19',
+		'criteria_name': 'Sales Order Pending Items1',
+		'custom_query': '',
+		'description': 'Sales Order Pending Items',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Status':'','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2011-05-09 11:08:05',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_order_pending_items1',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_orderwise_booking_ b/crm/search_criteria/sales_orderwise_booking_
new file mode 100644
index 0000000..46a478c
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_booking_
@@ -0,0 +1,4 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
+}
diff --git a/crm/search_criteria/sales_orderwise_booking_&_delivery_summary/__init__.py b/crm/search_criteria/sales_orderwise_booking_&_delivery_summary/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_booking_&_delivery_summary/__init__.py
diff --git a/crm/search_criteria/sales_orderwise_booking_&_delivery_summary/sales_orderwise_booking_&_delivery_summary.txt b/crm/search_criteria/sales_orderwise_booking_&_delivery_summary/sales_orderwise_booking_&_delivery_summary.txt
new file mode 100644
index 0000000..cce0f0a
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_booking_&_delivery_summary/sales_orderwise_booking_&_delivery_summary.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': "SUM(CASE WHEN `tabSales Order`.`status` = 'Stopped' THEN (`tabSales Order Detail`.`delivered_qty` * `tabSales Order Detail`.`basic_rate`) ELSE (`tabSales Order Detail`.`qty` * `tabSales Order Detail`.`basic_rate`) END) AS 'Booking Total'\nSUM(`tabSales Order Detail`.`delivered_qty` * `tabSales Order Detail`.`basic_rate`) AS 'Delivered Amount'",
+		'add_cond': '',
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Status,Sales Order\x01% Billed,Sales Order\x01Sales Order Date,Sales Order\x01Customer,Sales Order\x01Customer Name,Sales Order\x01Territory',
+		'creation': '2010-09-01 15:47:57',
+		'criteria_name': 'Sales Orderwise Booking & Delivery Summary',
+		'custom_query': '',
+		'description': 'Sales Orderwise Booking & Delivery Summary',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Status':'','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '`tabSales Order`.`name`',
+		'idx': None,
+		'modified': '2010-08-30 12:48:21',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_orderwise_booking_&_delivery_summary',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': '',
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_orderwise_pending_amount_to_bill/__init__.py b/crm/search_criteria/sales_orderwise_pending_amount_to_bill/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_pending_amount_to_bill/__init__.py
diff --git a/crm/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.js b/crm/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.js
new file mode 100644
index 0000000..46d4b2b
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.js
@@ -0,0 +1,4 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+  this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
+}
\ No newline at end of file
diff --git a/crm/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.txt b/crm/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.txt
new file mode 100644
index 0000000..290df07
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': 'SUM((`tabSales Order Detail`.`qty` - ifnull(`tabSales Order Detail`.`billed_qty`, 0)) * `tabSales Order Detail`.`basic_rate`) AS "Pending Amount"',
+		'add_cond': '`tabSales Order`.status != "Stopped"\n`tabSales Order`.order_type!="Maintenance"',
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Customer,Sales Order\x01Customer Address,Sales Order\x01Status,Sales Order\x01%  Delivered,Sales Order\x01% Billed,Sales Order\x01Company Name,Sales Order\x01Sales Order Date,Sales Order\x01Net Total,Sales Order\x01Zone,Sales Order\x01Territory,Sales Order\x01Email Id',
+		'creation': '2011-05-09 11:04:19',
+		'criteria_name': 'Sales Orderwise Pending Amount To Bill',
+		'custom_query': '',
+		'description': 'Sales Orderwise Pending Amount To Bill',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Submitted':1,'Sales Order\x01Company Name':'','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '`tabSales Order`.`name`',
+		'idx': None,
+		'modified': '2011-03-29 14:06:13',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_orderwise_pending_amount_to_bill',
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_orderwise_pending_qty_to_deliver/__init__.py b/crm/search_criteria/sales_orderwise_pending_qty_to_deliver/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_pending_qty_to_deliver/__init__.py
diff --git a/crm/search_criteria/sales_orderwise_pending_qty_to_deliver/sales_orderwise_pending_qty_to_deliver.txt b/crm/search_criteria/sales_orderwise_pending_qty_to_deliver/sales_orderwise_pending_qty_to_deliver.txt
new file mode 100644
index 0000000..31d8a21
--- /dev/null
+++ b/crm/search_criteria/sales_orderwise_pending_qty_to_deliver/sales_orderwise_pending_qty_to_deliver.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': 'SUM(`tabSales Order Detail`.`qty` - ifnull(`tabSales Order Detail`.`delivered_qty`, 0)) AS "Pending Qty"',
+		'add_cond': '`tabSales Order`.status != "Stopped"\n`tabSales Order Detail`.`qty` > ifnull(`tabSales Order Detail`.`delivered_qty`, 0)',
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Customer,Sales Order\x01Customer Name,Sales Order\x01Customer Address,Sales Order\x01Status,Sales Order\x01%  Delivered,Sales Order\x01% Billed,Sales Order\x01Sales Order Date,Sales Order\x01Territory,Sales Order\x01Email Id',
+		'creation': '2011-05-09 11:04:19',
+		'criteria_name': 'Sales Orderwise Pending Qty To Deliver',
+		'custom_query': '',
+		'description': 'Sales Orderwise Pending Qty To Deliver',
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Submitted':1,'Sales Order\x01Status':'','Sales Order\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '`tabSales Order`.`name`',
+		'idx': None,
+		'modified': '2011-03-29 14:02:58',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_orderwise_pending_qty_to_deliver',
+		'owner': 'dhanalekshmi@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': '',
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_persons_target_variance_item_group_wise/__init__.py b/crm/search_criteria/sales_persons_target_variance_item_group_wise/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_persons_target_variance_item_group_wise/__init__.py
diff --git a/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js b/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js
new file mode 100644
index 0000000..0e0d461
--- /dev/null
+++ b/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js
@@ -0,0 +1,45 @@
+report.customize_filters = function() {
+
+  this.hide_all_filters();
+
+  this.add_filter({fieldname:'sales_person', label:'Sales Person', fieldtype:'Link', options:'Sales Person',ignore : 1,parent:'Target Detail'});
+  
+  this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
+ 
+  this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
+  
+  this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
+  
+  this.add_filter({fieldname : 'target_on', label:'Target On', fieldtype:'Select', options:'Quantity'+NEWLINE+'Amount',report_default:'Quantity',ignore : 1,parent:'Target Detail'});
+  this.filter_fields_dict['Target Detail'+FILTER_SEP +'Sales Person'].df.in_first_page = 1;
+}
+this.mytabs.items['Select Columns'].hide();
+report.get_query = function() {
+
+  sales_person = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Sales Person'].get_value();
+  target_on = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Target On'].get_value();   
+  under = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Under'].get_value();
+  if(under == 'Sales Invoice') under = 'Receivable Voucher';
+
+  if(target_on == 'Quantity'){
+    q1 = 't1.target_qty AS "Target Quantity"';
+    q2 = '0 AS "Target Quantity"';
+    cond1 = 'ifnull(t1.target_qty,"")!=""';
+    cond2 = 'ifnull(t6.target_qty,"")!=""';
+  }  
+  else{
+    q1 = 't1.target_amount AS "Target Amount"';
+    q2 = '0 AS "Target Amount"';
+    cond1 = 'ifnull(t1.target_amount,"")!=""';
+    cond2 = 'ifnull(t6.target_amount,"")!=""';
+  }
+  if(under =='Receivable Voucher')
+    tab = 'RV';
+  else
+    tab = under;
+
+  var q ='SELECT t1.item_group AS "Item Group", '+q1+', t2.distribution_id AS "Distribution Id" FROM `tabTarget Detail` t1, `tabSales Person` t2 WHERE t1.parenttype = "Sales Person" AND t1.parent = "'+sales_person+'" AND t1.parent=t2.name AND ifnull(t1.item_group,"") != "" AND '+cond1+' UNION SELECT t3.item_group AS "Item Group", '+q2+',"" AS "Distribution Id" FROM `tab'+tab+' Detail` t3,`tabSales Team` t4,`tab'+under+'` t5 where t3.item_group NOT IN (SELECT t6.item_group AS "Item Group" FROM `tabTarget Detail` t6, `tabSales Person` t7 WHERE t6.parenttype = "Sales Person" AND t6.parent = "'+sales_person+'" AND t6.parent=t7.name AND '+cond2+') AND t4.sales_person = "'+sales_person+'" AND t3.parent = t5.name AND t4.parent = t5.name AND t5.docstatus = 1';
+
+  return q;
+
+}
\ No newline at end of file
diff --git a/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py b/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py
new file mode 100644
index 0000000..1eaf7bf
--- /dev/null
+++ b/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py
@@ -0,0 +1,125 @@
+# validate Filters
+flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'sales_person':'Sales Person', 'target_on':'Target On'}
+for f in flt_dict:
+  if not filter_values.get(f):
+    msgprint("Please Select " + cstr(flt_dict[f]))
+    raise Exception
+
+# Get Values from fliters
+fiscal_year = filter_values.get('fiscal_year')
+period = filter_values.get('period')
+under = filter_values.get('under')
+if under == 'Sales Invoice': under = 'Receivable Voucher'
+sales_person = filter_values.get('sales_person')
+target_on = filter_values.get('target_on')
+
+
+# Set required field names 
+based_on_fn = 'sales_person'
+
+date_fn  = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date' 
+
+mon_list = []
+
+data = {'start_date':0, 'end_date':1}
+
+def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
+  count = 1
+  if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
+  for m in range(12):
+    # get last date
+    last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
+    
+    # make mon_list for Monthly Period
+    if period == 'Monthly' :
+      mon_list.append([start_date, last_date])
+      # add months as Column names
+      month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
+      append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
+      
+    # get start date
+    start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
+    
+    # make mon_list for Quaterly Period
+    if period == 'Quarterly' and count % 3 == 0: 
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column names
+      append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+    
+    # make mon_list for Half Yearly Period
+    if period == 'Half Yearly' and count % 6 == 0 :
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+
+    # make mon_list for Annual Period
+    if period == 'Annual' and count % 12 == 0:
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
+    count = count +1
+
+def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
+  col = ['Target', 'Actual', 'Variance']
+  for c in col:
+    n = str(name) and ' (' + str(name) +')' or ''
+    colnames.append(str(c) + n )
+    coltypes.append('Currency')
+    colwidths.append('150px')
+    coloptions.append('')
+    col_idx[str(c) + n ] = len(colnames) - 1
+
+
+
+# make default columns
+#coltypes[col_idx['Item Group']] = 'Link'
+#coloptions[col_idx['Item Group']]= 'Sales '
+
+# get start date
+start_date = get_value('Fiscal Year', fiscal_year, 'year_start_date')
+if not start_date:
+  msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
+  raise Exception
+start_date = start_date.strftime('%Y-%m-%d')
+
+# make month list and columns
+make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
+
+
+
+bc_obj = get_obj('Budget Control')
+for r in res:
+
+  count = 0
+
+  for idx in range(3, len(colnames), 3):
+
+    cidx = 2
+    # ================= Calculate Target ==========================================
+    r.append(bc_obj.get_monthly_budget(r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
+
+    #================== Actual Amount =============================================
+    actual = 0
+
+
+
+    #----------------------------------------------------------    
+    if target_on == "Quantity":
+
+      actual = sql("select sum(ifnull(t2.qty,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Receivable Voucher') and 'RV' or under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+    
+    #----------------------------------------------------------  
+    if target_on == "Amount":
+
+      actual = sql("select sum(ifnull(t2.amount,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Receivable Voucher') and 'RV' or under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+    #----------------------------------------------------------
+
+    actual = actual and flt(actual[0][0]) or 0 
+    r.append(actual)
+    # ================ Variance ===================================================
+
+    r.append(r[idx] - r[idx + 1])
+
+    count = count +1
\ No newline at end of file
diff --git a/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.txt b/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.txt
new file mode 100644
index 0000000..07ba395
--- /dev/null
+++ b/crm/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': '',
+		'creation': '2010-12-14 10:33:09',
+		'criteria_name': 'Sales Persons Target Variance (Item Group wise)',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Target Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Person\x01Country':'','Sales Person\x01State':'','Target Detail\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-09-25 17:22:58',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_persons_target_variance_item_group_wise',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Person',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabTarget Detail`.`target_amount`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/sales_personwise_transaction_summary/__init__.py b/crm/search_criteria/sales_personwise_transaction_summary/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/sales_personwise_transaction_summary/__init__.py
diff --git a/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.js b/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.js
new file mode 100755
index 0000000..15de4b9
--- /dev/null
+++ b/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.js
@@ -0,0 +1,40 @@
+report.customize_filters = function() {
+  this.hide_all_filters();
+
+  //Add filter
+  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice', report_default:'Sales Order', ignore : 1,parent:'Sales Person', single_select :1, in_first_page:1});
+  this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'', ignore : 1,parent:'Sales Person', in_first_page:1});
+  this.add_filter({fieldname:'voucher_id', label:'Voucher Id', fieldtype:'Data', options:'', ignore : 1,parent:'Sales Person', in_first_page:1});
+  this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory', ignore : 1,parent:'Sales Person', in_first_page:1});
+  this.add_filter({fieldname:'sales_person', label:'Sales Person', fieldtype:'Link', options:'Sales Person', ignore : 1,parent:'Sales Person', in_first_page:1});
+}
+
+// hide sections
+this.mytabs.items['More Filters'].hide();
+this.mytabs.items['Select Columns'].hide();
+
+// Get query
+report.get_query = function() {
+  based_on = this.get_filter('Sales Person', 'Based On').get_value();
+  from_date = this.get_filter('Sales Person', 'From Date').get_value();
+  to_date = this.get_filter('Sales Person', 'To Date').get_value();
+  vid = this.get_filter('Sales Person', 'Voucher Id').get_value();
+  terr = this.get_filter('Sales Person', 'Territory').get_value();
+  sp = this.get_filter('Sales Person', 'Sales Person').get_value();
+
+  date_fld = 'transaction_date';
+  if(based_on == 'Sales Invoice') {
+    based_on = 'Receivable Voucher';
+    date_fld = 'voucher_date';
+  }
+
+  sp_cond = '';
+  if (from_date) sp_cond += ' AND t1.' + date_fld + '>= "' + from_date + '"';
+  if (to_date) sp_cond += ' AND t1.' + date_fld + '<= "' + to_date + '"';
+  if (vid) sp_cond += ' AND t1.name LIKE "%' + vid + '%"';
+  if (terr) sp_cond += ' AND t1.territory = "' + terr + '"';
+  if (sp) sp_cond += ' AND t2.sales_person = "' + sp + '"';
+
+  return 'SELECT t1.`name`, t1.`customer_name`, t1.`territory`, t1.`' + date_fld + '`, t1.`net_total`, t1.`grand_total`, t2.`sales_person`, t2.`allocated_percentage`, t2.`allocated_amount` FROM `tab' + based_on + '` t1, `tabSales Team` t2 WHERE t1.docstatus=1 AND t2.`parenttype` = "' + based_on + '" AND t2.`parent` = t1.`name`' + sp_cond + ' ORDER BY t1.`name` DESC';
+}
+
diff --git a/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.py b/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.py
new file mode 100755
index 0000000..e47d654
--- /dev/null
+++ b/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.py
@@ -0,0 +1,13 @@
+if filter_values.get('based_on') == 'Sales Invoice':
+  based_on_dt = 'Receivable Voucher'
+else:
+  based_on_dt = filter_values.get('based_on')
+
+cols = [[filter_values.get('based_on'), 'Link','150px', based_on_dt], ['Customer', 'Link','150px','Customer'], ['Territory', 'Link','120px','Territory'], ['Transaction Date', 'Date', '120px', ''], ['Net Total', 'Currency', '80px', ''], ['Grand Total', 'Currency', '80px', ''], ['Sales Person', 'Link', '150px', 'Sales Person'], ['% Contribution', 'Currency', '120px', ''], ['Contribution Amt', 'Currency', '120px', '']]
+
+for c in cols:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  col_idx[c[0]] = len(colnames)-1
diff --git a/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.txt b/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.txt
new file mode 100755
index 0000000..1013bc4
--- /dev/null
+++ b/crm/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Sales Person\x01ID',
+		'creation': '2011-06-07 16:58:27',
+		'criteria_name': 'Sales Personwise Transaction Summary',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Person',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Person\x01Saved':1,'Sales Person\x01Submitted':1,'Sales Person\x01Country':'','Sales Person\x01State':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2011-02-24 17:35:32',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'sales_personwise_transaction_summary',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSales Person`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/so_pending_items_3/__init__.py b/crm/search_criteria/so_pending_items_3/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/so_pending_items_3/__init__.py
diff --git a/crm/search_criteria/so_pending_items_3/so_pending_items_3.txt b/crm/search_criteria/so_pending_items_3/so_pending_items_3.txt
new file mode 100644
index 0000000..43cdc8d
--- /dev/null
+++ b/crm/search_criteria/so_pending_items_3/so_pending_items_3.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Sales Order\x01ID,Sales Order\x01Sales Order Date,Sales Order\x01Customer,Sales Order\x01Customer Name,Sales Order Detail\x01Item Code,Sales Order Detail\x01Item Name,Sales Order Detail\x01Description,Sales Order Detail\x01Quantity,Sales Order Detail\x01Delivered Qty,Sales Order Detail\x01Billed Qty',
+		'creation': '2010-12-14 10:33:09',
+		'criteria_name': 'SO Pending items 3',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Sales Order Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Status':'Submitted','Sales Order\x01Company':'Alpha Company','Sales Order\x01Fiscal Year':'2010-2011'}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-11-20 16:20:50',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'so_pending_items_3',
+		'owner': 'harshada@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Order',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': '',
+		'server_script': None,
+		'sort_by': '`tabSales Order`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/target_variance_report/__init__.py b/crm/search_criteria/target_variance_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/target_variance_report/__init__.py
diff --git a/crm/search_criteria/target_variance_report/target_variance_report.js b/crm/search_criteria/target_variance_report/target_variance_report.js
new file mode 100644
index 0000000..8a717b0
--- /dev/null
+++ b/crm/search_criteria/target_variance_report/target_variance_report.js
@@ -0,0 +1,27 @@
+report.customize_filters = function() {
+  this.hide_all_filters();
+  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Cost Center'+NEWLINE+'Sales Person'+NEWLINE+'Sales Partner',report_default:'Cost Center',ignore : 1,parent:'Target Detail'});
+  this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company',report_default:sys_defaults.company, ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item Group',ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Receivable Voucher',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
+
+}
+
+report.get_query = function() {
+  group_by = '';
+  group_by = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Group By'].get_value();
+  based_on = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Based On'].get_value();
+  sel_fields = '`tabTarget Detail`.parent AS "' + cstr(based_on)+'"';
+  cond = ' and ifnull(`tabTarget Detail`.item_group, "") = ""'
+  if (group_by == 'Item Group'){
+    sel_fields = cstr(sel_fields) + ', `tabTarget Detail`.item_group';
+    cond =  ' and ifnull(`tabTarget Detail`.item_group,"") != ""'
+  }
+  sel_fields = cstr(sel_fields) + ', `tabTarget Detail`.target_amount, `tabTarget Detail`.distribution_id';
+  var q = 'SELECT '+ cstr(sel_fields) +' FROM `tabTarget Detail` WHERE `tabTarget Detail`.parenttype = "' + cstr(based_on) + '"'+ cstr(cond);
+  return q
+}
+
+this.mytabs.items['Select Columns'].hide();
\ No newline at end of file
diff --git a/crm/search_criteria/target_variance_report/target_variance_report.py b/crm/search_criteria/target_variance_report/target_variance_report.py
new file mode 100644
index 0000000..44016ee
--- /dev/null
+++ b/crm/search_criteria/target_variance_report/target_variance_report.py
@@ -0,0 +1,110 @@
+# validate Filters
+flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'company':'Company', 'under' : 'Under', 'based_on' : 'Based On'}
+for f in flt_dict:
+  if not filter_values.get(f):
+    msgprint("Please Select " + cstr(flt_dict[f]))
+    raise Exception
+
+# Get Values from fliters
+fiscal_year = filter_values.get('fiscal_year')
+period = filter_values.get('period')
+under = filter_values.get('under')
+based_on = filter_values.get('based_on')
+group_by = filter_values.get('group_by')
+
+# Set required field names 
+based_on_fn = (based_on == 'Cost Center') and 'cost_center' or (based_on == 'Sales Partner') and 'sales_partner' or (based_on == 'Sales Person') and 'sales_person'
+date_fn  = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date' 
+
+mon_list = []
+data = {'start_date':0, 'end_date':1}
+
+def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
+  count = 1
+  if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
+  for m in range(12):
+    # get last date
+    last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
+    
+    # make mon_list for Monthly Period
+    if period == 'Monthly' :
+      mon_list.append([start_date, last_date])
+      # add months as Column names
+      month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
+      append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
+      
+    # get start date
+    start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
+    
+    # make mon_list for Quaterly Period
+    if period == 'Quarterly' and count % 3 == 0: 
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column names
+      append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+    
+    # make mon_list for Half Yearly Period
+    if period == 'Half Yearly' and count % 6 == 0 :
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+
+    # make mon_list for Annual Period
+    if period == 'Annual' and count % 12 == 0:
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
+    count = count +1
+
+def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
+  col = ['Budget', 'Actual', 'Variance']
+  for c in col:
+    colnames.append(str(c) + ' (' + str(name) +')' )
+    coltypes.append('Currency')
+    colwidths.append('150px')
+    coloptions.append('')
+    col_idx[str(c) + ' (' + str(name) +')' ] = len(colnames) - 1
+
+# make default columns
+coltypes[col_idx[based_on]] = 'Link'
+coloptions[col_idx[based_on]]= based_on 
+
+# get start date
+start_date = get_value('Fiscal Year', fiscal_year, 'year_start_date')
+if not start_date:
+  msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
+  raise Exception
+start_date = start_date.strftime('%Y-%m-%d')
+
+# make month list and columns
+make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
+
+bc_obj = get_obj('Budget Control')
+for r in res:
+  count = 0
+  for idx in range((group_by == 'Item Group') and 4 or 3, len(colnames), 3):
+    cidx = (group_by == 'Item Group') and 3 or 2
+    # ================= Calculate Target ==========================================
+    r.append(bc_obj.get_monthly_budget( r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
+    
+    #================== Actual Amount =============================================
+    actual = 0
+    if based_on == 'Cost Center' or based_on == 'Sales Partner':
+      if group_by =='Item Group':
+        actual = sql("select sum(ifnull(t2.amount,0)) from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s'" % (under, (under == 'Receivable Voucher') and 'RV' or under, under, based_on_fn, r[0], r[1], date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+        actual = flt(actual[0][0])
+      else:
+        actual = sql("select sum(ifnull(net_total,0)) from `tab%s` where %s = '%s' and docstatus = 1 and %s between '%s' and '%s' " % (under, based_on_fn, r[0], date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+        actual = flt(actual[0][0])
+    elif based_on == 'Sales Person':
+      if group_by =='Item Group':
+        actual = sql("select sum(ifnull(t2.amount,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Receivable Voucher') and 'RV' or under, based_on_fn, r[0], r[1], date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+        actual = flt(actual[0][0])
+      else:
+        actual = sql("select sum(ifnull(t2.allocated_amount,0)) from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and t1.%s between '%s' and '%s'"%(under, based_on_fn, r[0], under, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+        actual = flt(actual[0][0])
+    r.append(actual)
+    # ================ Variance ===================================================
+    r.append(r[idx] - r[idx + 1])
+    count = count +1
\ No newline at end of file
diff --git a/crm/search_criteria/target_variance_report/target_variance_report.txt b/crm/search_criteria/target_variance_report/target_variance_report.txt
new file mode 100644
index 0000000..5264f63
--- /dev/null
+++ b/crm/search_criteria/target_variance_report/target_variance_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Sales Person\x01ID,Sales Person\x01Owner,Sales Person\x01Sales Person,Sales Person\x01Country,Sales Person\x01State,Target Detail\x01Item Group,Target Detail\x01Fiscal Year,Target Detail\x01Target  Amount',
+		'creation': '2010-08-08 17:09:32',
+		'criteria_name': 'Target Variance Report',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': 0,
+		'doc_type': 'Target Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Person\x01Saved':1,'Sales Person\x01Submitted':1,'Sales Person\x01Country':'','Sales Person\x01State':'','Target Detail\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-06-23 12:27:37',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'target_variance_report',
+		'owner': 'harshada@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Person',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/territories_target_variance_item_group_wise/__init__.py b/crm/search_criteria/territories_target_variance_item_group_wise/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/territories_target_variance_item_group_wise/__init__.py
diff --git a/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.js b/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.js
new file mode 100644
index 0000000..1843632
--- /dev/null
+++ b/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.js
@@ -0,0 +1,45 @@
+report.customize_filters = function() {
+
+  this.hide_all_filters();
+
+  this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory',ignore : 1,parent:'Target Detail'});
+  
+  this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
+ 
+  this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
+  
+  this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
+  
+  this.add_filter({fieldname : 'target_on', label:'Target On', fieldtype:'Select', options:'Quantity'+NEWLINE+'Amount',report_default:'Quantity',ignore : 1,parent:'Target Detail'});
+  this.filter_fields_dict['Target Detail'+FILTER_SEP +'Territory'].df.in_first_page = 1;
+}
+this.mytabs.items['Select Columns'].hide();
+report.get_query = function() {
+
+  territory = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Territory'].get_value();
+  target_on = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Target On'].get_value();   
+  under = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Under'].get_value();   
+  if(under == 'Sales Invoice') under = 'Receivable Voucher';
+
+  if(target_on == 'Quantity'){
+    q1 = 't1.target_qty AS "Target Quantity"';
+    q2 = '0 AS "Target Quantity"';
+    cond1 = 'ifnull(t1.target_qty,"")!=""';
+    cond2 = 'ifnull(t5.target_qty,"")!=""';
+  }  
+  else{
+    q1 = 't1.target_amount AS "Target Amount"';
+    q2 = '0 AS "Target Amount"';
+    cond1 = 'ifnull(t1.target_amount,"")!=""';
+    cond2 = 'ifnull(t5.target_amount,"")!=""';
+  }
+  if(under =='Receivable Voucher')
+    tab = 'RV';
+  else
+    tab = under;
+
+  var q ='SELECT distinct t1.item_group AS "Item Group", '+q1+', t2.distribution_id AS "Distribution Id" FROM `tabTarget Detail` t1, `tabTerritory` t2 WHERE t1.parenttype = "Territory" AND t1.parent = "'+territory+'" AND t1.parent=t2.name AND ifnull(t1.item_group,"")!="" AND '+cond1+' UNION SELECT distinct t3.item_group AS "Item Group", '+q2+',"" AS "Distribution Id" FROM `tab'+tab+' Detail` t3,`tab'+under+'` t4 where t3.item_group NOT IN (SELECT t5.item_group FROM `tabTarget Detail` t5, `tabTerritory` t6 WHERE t5.parenttype = "Territory" AND t5.parent = "'+territory+'" AND t5.parent=t6.name AND '+cond2+') AND t4.territory = "'+territory+'" AND t3.parent = t4.name AND t4.docstatus = 1';
+
+  return q;
+
+}
\ No newline at end of file
diff --git a/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.py b/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.py
new file mode 100644
index 0000000..41e9e16
--- /dev/null
+++ b/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.py
@@ -0,0 +1,127 @@
+# validate Filters
+flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'territory':'Territory', 'target_on':'Target On'}
+for f in flt_dict:
+  if not filter_values.get(f):
+    msgprint("Please Select " + cstr(flt_dict[f]))
+    raise Exception
+
+# Get Values from fliters
+fiscal_year = filter_values.get('fiscal_year')
+period = filter_values.get('period')
+under = filter_values.get('under')
+if under == 'Sales Invoice': under = 'Receivable Voucher'
+territory = filter_values.get('territory')
+target_on = filter_values.get('target_on')
+
+
+# Set required field names 
+based_on_fn = 'territory'
+
+date_fn  = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date' 
+
+mon_list = []
+
+data = {'start_date':0, 'end_date':1}
+
+def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
+  count = 1
+  if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
+  for m in range(12):
+    # get last date
+    last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
+    
+    # make mon_list for Monthly Period
+    if period == 'Monthly' :
+      mon_list.append([start_date, last_date])
+      # add months as Column names
+      month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
+      append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
+      
+    # get start date
+    start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
+    
+    # make mon_list for Quaterly Period
+    if period == 'Quarterly' and count % 3 == 0: 
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column names
+      append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+    
+    # make mon_list for Half Yearly Period
+    if period == 'Half Yearly' and count % 6 == 0 :
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+
+    # make mon_list for Annual Period
+    if period == 'Annual' and count % 12 == 0:
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
+    count = count +1
+
+def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
+  col = ['Target', 'Actual', 'Variance']
+  for c in col:
+    n = str(name) and ' (' + str(name) +')' or ''
+    colnames.append(str(c) + n )
+    coltypes.append('Currency')
+    colwidths.append('150px')
+    coloptions.append('')
+    col_idx[str(c) + n ] = len(colnames) - 1
+
+
+
+# make default columns
+#coltypes[col_idx['Item Group']] = 'Link'
+#coloptions[col_idx['Item Group']]= 'Sales '
+
+# get start date
+start_date = get_value('Fiscal Year', fiscal_year, 'year_start_date')
+if not start_date:
+  msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
+  raise Exception
+start_date = start_date.strftime('%Y-%m-%d')
+
+# make month list and columns
+make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
+
+
+
+bc_obj = get_obj('Budget Control')
+for r in res:
+
+  count = 0
+
+  for idx in range(3, len(colnames), 3):
+
+    cidx = 2
+    # ================= Calculate Target ==========================================
+    r.append(bc_obj.get_monthly_budget(r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
+
+    #================== Actual Amount =============================================
+    actual = 0
+
+
+
+    #----------------------------------------------------------    
+    if target_on == "Quantity":
+
+      actual = sql("select sum(ifnull(t2.qty,0)) from `tab%s` t1, `tab%s Detail` t2 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s = '%s' and t1.docstatus = 1 and t2.item_group = '%s' and t1.%s between '%s' and '%s'" % (under, (under == 'Receivable Voucher') and 'RV' or under, under, based_on_fn, territory, r[0],date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+      
+    
+    #----------------------------------------------------------  
+    if target_on == "Amount":
+
+      actual = sql("select sum(ifnull(t2.amount,0)) from `tab%s` t1, `tab%s Detail` t2 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s = '%s' and t1.docstatus = 1 and t2.item_group = '%s' and t1.%s between '%s' and '%s'" % (under, (under == 'Receivable Voucher') and 'RV' or under, under, based_on_fn, territory, r[0],date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+
+    #----------------------------------------------------------
+
+    actual = actual and flt(actual[0][0]) or 0 
+    r.append(actual)
+    # ================ Variance ===================================================
+
+    r.append(r[idx] - r[idx + 1])
+
+    count = count +1
\ No newline at end of file
diff --git a/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.txt b/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.txt
new file mode 100644
index 0000000..497bc13
--- /dev/null
+++ b/crm/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': '',
+		'creation': '2010-12-14 10:33:09',
+		'criteria_name': 'Territories Target Variance (Item Group wise)',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Target Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Person\x01Country':'','Sales Person\x01State':'','Target Detail\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-11-25 13:18:22',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'territories_target_variance_item_group_wise',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Person',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabTarget Detail`.`target_amount`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/territory_item_group_wise_gp/__init__.py b/crm/search_criteria/territory_item_group_wise_gp/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/territory_item_group_wise_gp/__init__.py
diff --git a/crm/search_criteria/territory_item_group_wise_gp/territory_item_group_wise_gp.py b/crm/search_criteria/territory_item_group_wise_gp/territory_item_group_wise_gp.py
new file mode 100644
index 0000000..3c513df
--- /dev/null
+++ b/crm/search_criteria/territory_item_group_wise_gp/territory_item_group_wise_gp.py
@@ -0,0 +1,107 @@
+# Add Columns
+# ------------
+based_on = filter_values.get('based_on')
+
+columns = [[based_on,'Data','150px',''],
+           ['Total Qty','Currency','150px',''],
+           ['Revenue','Currency','150px',''],
+           ['Valuation Amount','Currency','150px',''],
+           ['Gross Profit (%)','Currrency','150px',''],
+           ['Gross Profit','Currency','150px','']]           
+
+for c in columns:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  col_idx[c[0]] = len(colnames)-1
+
+
+
+def make_child_lst(based_on,name):
+  rg = sql("select lft, rgt from `tab%s` where name = '%s'"%(based_on,name))
+  ch_name = sql("select name from `tab%s` where lft between %d and %d"%(based_on,int(rg[0][0]),int(rg[0][1])))
+  chl ='('
+  flag = 1
+  for c in ch_name:
+    if flag == 1:
+     chl += "'%s'"%c[0]
+     flag = 2
+    else:
+      chl +=",'%s'"%c[0]
+
+  chl +=")"
+  return chl
+
+
+
+for r in res:
+
+  qty, rate, amt, tot_val_rate, val_amount = 0, 0, 0, 0,0
+  cn = make_child_lst(based_on,r[0].strip())
+
+
+
+  if based_on == 'Item Group':
+  
+    dn = sql("select name from `tabItem` where item_group in %s"%(cn))
+    for n in dn:
+      
+      dt = sql("select sum(qty),sum(amount) from `tabDelivery Note Detail` where item_code ='%s' and docstatus = 1"%n[0])  
+          
+      qty += dt[0][0] and dt[0][0] or 0
+      amt += dt[0][1] and dt[0][1] or 0  
+      prt = sql("select distinct t1.name from `tabDelivery Note` t1, `tabDelivery Note Detail` t2 where t1.name = t2.parent and t2.item_code = '%s' and t1.docstatus = 1 and t2.docstatus =1 order by t1.name"%n[0])
+      for p in prt:
+        d1 = sql("select qty from `tabDelivery Note Detail` where parent = '%s' and parenttype ='Delivery Note' and docstatus =1 and item_code = '%s'"%(p[0],n[0]))
+        for t in d1:
+          tot_val_rate = 0
+          packing_list_items = sql("select item_code, warehouse, qty from `tabDelivery Note Packing Detail` where parent = '%s' and parent_item = '%s' and docstatus = 1 order by item_code, warehouse, qty"%(p[0],n[0]))
+                           
+          for d in packing_list_items:
+            if d[1]:
+              val_rate = sql("select valuation_rate from `tabStock Ledger Entry` where item_code = '%s' and warehouse = '%s' and voucher_type = 'Delivery Note' and voucher_no = '%s' and is_cancelled = 'No'"%(d[0], d[1], p[0]))
+              
+              val_rate = val_rate and val_rate[0][0] or 0
+              
+              tot_val_rate += t[0] and (flt(val_rate) * flt(d[2]) / flt(t[0])) or 0
+          val_amount += flt(tot_val_rate) * flt(t[0])  
+  elif based_on == 'Territory':
+    
+
+    dn = sql("select name from `tabDelivery Note` where territory in %s and docstatus =1 order by name"%(cn))
+
+    for n in dn:
+
+      dt = sql("select sum(qty), sum(amount) from `tabDelivery Note Detail` where parent = '%s' and docstatus = 1"%n[0])
+      qty += dt[0][0] and dt[0][0] or 0
+      amt += dt[0][1] and dt[0][1] or 0
+
+      d1 = sql("select item_code,qty from `tabDelivery Note Detail` where parent = '%s' and parenttype ='Delivery Note' and docstatus =1"%n[0])
+
+      for t in d1:
+        tot_val_rate = 0
+        packing_list_items = sql("select item_code, warehouse, qty from `tabDelivery Note Packing Detail` where parent = '%s' and parent_item = '%s' and docstatus = 1 order by item_code, warehouse,qty"%(n[0],t[0]))
+       
+        for d in packing_list_items:
+          if d[1]:
+            
+            val_rate = sql("select valuation_rate from `tabStock Ledger Entry` where item_code = '%s' and warehouse = '%s' and voucher_type = 'Delivery Note' and voucher_no = '%s' and is_cancelled = 'No'"%(d[0], d[1], n[0]))
+            val_rate = val_rate and val_rate[0][0] or 0
+            
+            tot_val_rate += t[1] and (flt(val_rate) * flt(d[2]) / flt(t[1])) or 0
+        val_amount += flt(tot_val_rate) * flt(t[1])
+  r.append(fmt_money(qty))
+
+  r.append(fmt_money(amt))
+  gp = flt(r[col_idx['Revenue']]) - flt(val_amount)
+  
+  if val_amount: gp_percent = gp * 100 / flt(val_amount)
+  else: gp_percent = gp
+  gp_percent = '%0.2f'%gp_percent
+
+      
+
+  r.append(fmt_money(val_amount))
+  r.append(fmt_money(gp_percent))
+  r.append(fmt_money(gp))
\ No newline at end of file
diff --git a/crm/search_criteria/territory_item_group_wise_gp/territory_item_group_wise_gp.txt b/crm/search_criteria/territory_item_group_wise_gp/territory_item_group_wise_gp.txt
new file mode 100644
index 0000000..ff29d1d
--- /dev/null
+++ b/crm/search_criteria/territory_item_group_wise_gp/territory_item_group_wise_gp.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': None,
+		'creation': '2010-12-14 17:52:48',
+		'criteria_name': 'Territory, Item Group wise GP',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Delivery Note',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Delivery Note\x01Status':'','Delivery Note\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2011-05-09 14:40:26',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'territory_item_group_wise_gp',
+		'owner': 'harshada@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': '',
+		'server_script': None,
+		'sort_by': None,
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/territory_sales___variance_report/__init__.py b/crm/search_criteria/territory_sales___variance_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/territory_sales___variance_report/__init__.py
diff --git a/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.js b/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.js
new file mode 100644
index 0000000..b589c25
--- /dev/null
+++ b/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.js
@@ -0,0 +1,6 @@
+report.customize_filters = function() {
+  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Receivable Voucher',report_default:'Sales Order',ignore : 1, parent:'Territory'});
+  this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Territory'});
+  this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company',report_default:sys_defaults.company, ignore : 1, parent:'Territory'});
+  this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Territory'});
+}
\ No newline at end of file
diff --git a/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.py b/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.py
new file mode 100644
index 0000000..3d0fbe2
--- /dev/null
+++ b/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.py
@@ -0,0 +1,188 @@
+if filter_values.get('period'):
+  period_values = filter_values['period']
+  if len(period_values.split(NEWLINE))>1:
+    msgprint("You can view report only for one period. Please select only one value in period.")
+    raise Exception
+  else:
+    period = period_values.split(NEWLINE)[0]
+
+if filter_values.get('based_on'):
+  based_on = filter_values['based_on']
+  if len(based_on.split(NEWLINE)) > 1:
+    msgprint("You can view report based on only one criteria. Please select only one value in Based On.")
+    raise Exception
+  else:
+    based_on = based_on.split(NEWLINE)[0]
+
+if not filter_values.get('fiscal_year'):
+  msgprint("Please Select Fiscal Year")
+  raise Exception
+elif not filter_values.get('period'):
+  msgprint("Please Select Period")
+  raise Exception
+elif not filter_values.get('based_on'):
+  msgprint("Please Select the Criteria on which you want your report to be based")
+  raise Exception
+
+fiscal_year = filter_values.get('fiscal_year')
+
+# get fiscal year start date and start month
+# ---------------------------------------------------------  
+year_start_date = sql("select year_start_date,MONTH(year_start_date) from `tabFiscal Year` where name = %s",fiscal_year)
+start_date = year_start_date and year_start_date[0][0] or ''
+start_month = year_start_date and year_start_date[0][1] or ''
+month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
+
+# Add columns based on period
+# --------------------------------
+columns = []
+# ================ Annual ======================
+if period == 'Annual':
+  columns.append(['Target','Currency','120px',''])
+  columns.append(['Actual','Currency','120px',''])
+
+# =========== Half Yearly ======================
+elif period == 'Half Yearly':
+  columns.append(['Target (H1)','Currency','120px','']) # first half
+  columns.append(['Actual (H1)','Currency','120px','']) # first half
+  if start_month == 1:  # this is case when fiscal year starts with JAN
+    columns.append(['Target (H2)','Currency','120px',''])
+    columns.append(['Actual (H2)','Currency','120px',''])
+  else:  #this is case when fiscal year starts with other than JAN
+    columns.append(['Target (H2)','Currency','120px',''])
+    columns.append(['Actual (H2)','Currency','120px',''])
+  
+# ================ Quarterly ===================
+elif period == 'Quarterly':
+  length_1 = (len(month_name) - start_month + 1) / 3  #this gives the total no. of times we need to iterate for quarter
+  val = length_1 % 4
+  q_no = 1
+  for i in range(length_1):
+    value = 3*i + val
+    columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
+    columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
+    q_no += 1
+  length_2 = (start_month - 1) / 3 #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
+  for i in range(length_2):
+    columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
+    columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
+    q_no += 1;
+
+  
+# =============== Monthly ======================
+elif period == 'Monthly':
+  for i in range(start_month-1,len(month_name)):
+    columns.append(['Target ('+month_name[i]+')','Currency','120px',''])
+    columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
+
+  for i  in range(start_month-1):
+    columns.append(['Target('+month_name[i]+')','Currency','120px',''])
+    columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
+
+
+
+for c in columns:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  col_idx[c[0]] = len(colnames)-1
+
+
+condition = ' docstatus = 1 and fiscal_year = "'+fiscal_year+'"'
+
+
+for r in res:
+  query = ''
+
+  # ================= Annual Report =============== 
+  if period == 'Annual':
+
+    target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s ",(r[col_idx['ID']],fiscal_year))
+    target = target and flt(target[0][0]) or 0
+    r.append(target)
+
+  
+    so = sql("select sum(net_total) from `tab%s` where territory = '%s' and %s" % (based_on, r[col_idx['ID']],condition))
+    so = so and flt(so[0][0]) or 0
+    r.append(so)
+
+  # ================= Half Yearly Report =============== 
+  elif period == 'Half Yearly':
+    target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s",(r[col_idx['ID']],fiscal_year))
+    target = target and flt(flt(target[0][0])/2) or 0
+    r.append(target)
+
+    query += ' MONTH(transaction_date) BETWEEN '+cstr(start_month)+' and '+cstr(start_month+5)
+    so = sql("select sum(net_total) from `tab%s` where territory = '%s'  and %s and %s" % (based_on, r[col_idx['ID']],condition,query))
+    so = so and flt(so[0][0]) or 0
+    r.append(so)
+    
+    r.append(target)
+
+    query =''
+    query += 'MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' and '+cstr(start_month+5)
+    so = sql("select sum(net_total) from `tab%s` where territory = '%s'  and %s and %s" % (based_on, r[col_idx['ID']],condition,query))
+    so = so and flt(so[0][0]) or 0
+    r.append(so)
+    query = ''
+
+  # =============== Quarterly Report ==============  
+  elif period == 'Quarterly':
+    query = ''
+    length_1 = (len(month_name) - start_month + 1) / 3; #this gives the total no. of times we need to iterate for quarter
+    val = length_1 % 4;
+    for i in range(length_1):
+      value = 3*i + val;
+      query +='SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),'
+    length_2 = (start_month - 1) / 3; #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
+    for i in range(length_2):
+      query += 'SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END)';
+
+    target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s",(r[col_idx['ID']],fiscal_year))
+    target = target and flt(flt(target[0][0])/4) or 0
+
+
+    so = sql("SELECT %s from `tab%s` where territory ='%s' and %s " %(query,based_on,r[col_idx['ID']],condition))
+    i = 0
+    length_l = 0
+    for c in columns:
+      if length_l == 0:
+        r.append(target)
+        length_l += 1
+      else:
+        so_total = so and flt(so[0][i]) or 0
+        r.append(so_total)
+        i +=1
+        length_l = 0
+
+  # ================ Monthly Report =============== 
+  elif period == 'Monthly':
+    query =''
+    target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s",(r[col_idx['ID']],fiscal_year))
+    #msgprint(target)
+    target = target and flt(flt(target[0][0])/12) or 0
+
+
+    # for loop is required twice coz fiscal year starts from April (this will also work if fiscal year starts in January)
+    for i in range(start_month-1,len(month_name)):
+      query += 'SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
+
+    for i  in range(start_month-1):
+      if i != (start_month-2):
+        query += 'SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
+      else:
+        query += 'SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END)';
+    so = sql("SELECT %s from `tab%s` where territory ='%s' and %s " %(query,based_on,r[col_idx['ID']],condition))
+
+    i = 0
+    length_l = 0
+    for c in columns:
+      if length_l == 0:
+        r.append(target)
+        length_l += 1
+      else:
+        so_total = so and flt(so[0][i]) or 0
+        r.append(so_total)
+        i +=1
+        length_l = 0
\ No newline at end of file
diff --git a/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.txt b/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.txt
new file mode 100644
index 0000000..3268c52
--- /dev/null
+++ b/crm/search_criteria/territory_sales___variance_report/territory_sales___variance_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Territory\x01ID',
+		'creation': '2010-08-08 17:09:31',
+		'criteria_name': 'Territory Sales - Variance Report',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Territory',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Territory\x01State':'','Territory\x01Based On':'Sales Order','Territory\x01Fiscal Year':'2009-2010','Territory\x01Company':'Alpha Company','Territory\x01Period':'Quarterly'}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': '',
+		'idx': None,
+		'modified': '2010-03-30 16:48:42',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'territory_sales_-_variance_report',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': 'ID',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/total_target_variance_report/__init__.py b/crm/search_criteria/total_target_variance_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/total_target_variance_report/__init__.py
diff --git a/crm/search_criteria/total_target_variance_report/total_target_variance_report.js b/crm/search_criteria/total_target_variance_report/total_target_variance_report.js
new file mode 100644
index 0000000..d5ec9de
--- /dev/null
+++ b/crm/search_criteria/total_target_variance_report/total_target_variance_report.js
@@ -0,0 +1,12 @@
+report.customize_filters = function() {
+  this.hide_all_filters();
+  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Territory'+NEWLINE+'Sales Person',report_default:'Territory',ignore : 1,parent:'Target Detail', single_select :1});
+  this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail', single_select :1});
+  this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail', single_select :1});
+  this.add_filter({fieldname : 'target_on', label:'Target On', fieldtype:'Select', options:'Quantity'+NEWLINE+'Amount',report_default:'Quantity',ignore : 1,parent:'Target Detail', single_select :1});
+}
+report.aftertableprint = function(t) {
+   $yt(t,'*',1,{whiteSpace:'pre'});
+}
+this.mytabs.items['Select Columns'].hide();
\ No newline at end of file
diff --git a/crm/search_criteria/total_target_variance_report/total_target_variance_report.py b/crm/search_criteria/total_target_variance_report/total_target_variance_report.py
new file mode 100644
index 0000000..ff26227
--- /dev/null
+++ b/crm/search_criteria/total_target_variance_report/total_target_variance_report.py
@@ -0,0 +1,206 @@
+# validate Filters
+flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'based_on' : 'Based On','target_on':'Target On'}
+for f in flt_dict:
+  if not filter_values.get(f):
+    msgprint("Please Select " + cstr(flt_dict[f]))
+    raise Exception
+
+# Get Values from fliters
+fiscal_year = filter_values.get('fiscal_year')
+period = filter_values.get('period')
+under = filter_values.get('under')
+if under == 'Sales Invoice': under = 'Receivable Voucher'
+based_on = filter_values.get('based_on')
+target_on = filter_values.get('target_on')
+
+#add distributed id field
+col = []
+col.append([based_on,'Date','150px',''])
+if target_on == 'Quantity':
+  col.append(['Target Quantity','Currency','150px',''])
+else:
+  col.append(['Target Amount','Currency','150px',''])
+col.append(['Distribution Id','Date','150px',''])
+
+for c in col:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  
+  col_idx[c[0]] = len(colnames)-1
+
+def make_child_lst(based_on,name):
+  rg = sql("select lft, rgt from `tab%s` where name = '%s'"%(based_on,name))
+  ch_name = sql("select name from `tab%s` where lft between %d and %d"%(based_on,int(rg[0][0]),int(rg[0][1])))
+  chl ='('
+  flag = 1
+  for c in ch_name:
+    if flag == 1:
+     chl += "'%s'"%c[0]
+     flag = 2
+    else:
+      chl +=",'%s'"%c[0]
+
+  chl +=")"
+  return chl
+
+
+def get_target(target_on,based_on,fiscal_year,r):
+
+  if target_on == 'Quantity':
+    q1 = "select t1.target_qty "
+    q2 = "select sum(t1.target_qty)"
+  if target_on == 'Amount':
+    q1 = "select t1.target_amount "
+    q2 = "select sum(t1.target_amount)"
+    
+  cond1 =" t1.fiscal_year ='%s' and t1.parent=t2.name and t1.parenttype = '%s' and t1.docstatus !=2"
+  #----------------------------------------------------------------  
+  q = "select t1.name from `tabTarget Detail` t1, `tab%s` t2 where "+cond1+" and t2.name = '%s'"
+  ch = sql(q%(based_on,fiscal_year,based_on,r))
+
+  return {'q1':q1,'q2':q2,'cond1':cond1,'ch':ch}
+
+for r in res:
+  
+  tt = get_target(target_on,based_on,fiscal_year,r[0].strip())
+  
+  if tt['ch']:
+    
+    cond2 = " ifnull(t1.item_group,'')='' and"
+    qur = tt['q1']+"from `tabTarget Detail` t1, `tab%s` t2 where "+cond2+tt['cond1']+" and t2.name = '%s'"
+    ret_amt = sql(qur%(based_on,fiscal_year,based_on,r[0].strip()))
+    
+    #----------------------------------------------------------------  
+    if not ret_amt:
+      qur = tt['q2']+"from `tabTarget Detail` t1, `tab%s` t2 where "+tt['cond1']+" and t2.name = '%s'"
+      ret_amt = sql(qur%(based_on,fiscal_year,based_on,r[0].strip()))  
+
+  #----------------------------------------------------------------      
+  else:
+    node_lst = make_child_lst(based_on,r[0].strip())
+    qur = tt['q2']+"from `tabTarget Detail` t1, `tab%s` t2 where "+tt['cond1']+" and t2.name in %s"
+    ret_amt = sql(qur%(based_on,fiscal_year,based_on,node_lst))    
+
+  #----------------------------------------------------------------  
+  ret_dis_id = sql("select distribution_id from `tab%s` where name = '%s'"%(based_on,r[0].strip()))
+
+  target_amt = ret_amt and flt(ret_amt[0][0]) or 0
+  dis_id = ret_dis_id and ret_dis_id[0][0] or ''
+
+  r.append(target_amt)
+  r.append(dis_id)
+
+
+# Set required field names 
+based_on_fn = (based_on == 'Territory') and 'territory' or 'sales_person'
+
+date_fn  = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date' 
+
+mon_list = []
+
+data = {'start_date':0, 'end_date':1}
+
+def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
+  count = 1
+  if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
+  for m in range(12):
+    # get last date
+    last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
+    
+    # make mon_list for Monthly Period
+    if period == 'Monthly' :
+      mon_list.append([start_date, last_date])
+      # add months as Column names
+      month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
+      append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
+      
+    # get start date
+    start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
+    
+    # make mon_list for Quaterly Period
+    if period == 'Quarterly' and count % 3 == 0: 
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column names
+      append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+    
+    # make mon_list for Half Yearly Period
+    if period == 'Half Yearly' and count % 6 == 0 :
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
+      if count != 12: mon_list.append([start_date])
+
+    # make mon_list for Annual Period
+    if period == 'Annual' and count % 12 == 0:
+      mon_list[len(mon_list) - 1 ].append(last_date)
+      # add Column Names
+      append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
+    count = count +1
+
+def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
+  col = ['Target', 'Actual', 'Variance']
+  for c in col:
+    n = str(name) and ' (' + str(name) +')' or ''
+    colnames.append(str(c) + n)
+    coltypes.append('Currency')
+    colwidths.append('150px')
+    coloptions.append('')
+    col_idx[str(c) + n ] = len(colnames) - 1
+
+
+
+# make default columns
+#coltypes[col_idx[based_on]] = 'Link'
+#coloptions[col_idx[based_on]]= based_on
+
+# get start date
+start_date = get_value('Fiscal Year', fiscal_year, 'year_start_date')
+if not start_date:
+  msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
+  raise Exception
+start_date = start_date.strftime('%Y-%m-%d')
+
+# make month list and columns
+make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
+
+
+bc_obj = get_obj('Budget Control')
+for r in res:
+  count = 0
+
+  for idx in range(3, len(colnames), 3):
+    cidx = 2
+
+    # ================= Calculate Target ==========================================
+    r.append(bc_obj.get_monthly_budget( r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
+    
+    #================== Actual Amount =============================================
+    actual = 0
+
+    ch = make_child_lst(based_on,r[0].strip())
+
+    #----------------------------------------------------------    
+    if target_on == "Quantity":
+      if based_on == "Territory":
+        actual = sql("select sum(ifnull(t2.qty,0)) from `tab%s` t1, `tab%s Detail` t2 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s in %s and t1.docstatus = 1 and t1.%s between '%s' and '%s'" % (under, (under == 'Receivable Voucher') and 'RV' or under, under, based_on_fn, ch, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+      
+      elif based_on == 'Sales Person':
+        actual = sql("select sum(ifnull(t2.qty,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s in %s and t1.docstatus != 2 and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Receivable Voucher') and 'RV' or under, based_on_fn, ch, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+    
+    #----------------------------------------------------------  
+    if target_on == "Amount":
+      if based_on == 'Territory':    
+        
+        actual = sql("select sum(ifnull(net_total,0)) from `tab%s` where %s in %s and docstatus = 1 and %s between '%s' and '%s' " % (under, based_on_fn, ch, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+    
+      elif based_on == 'Sales Person':
+        actual = sql("select sum(ifnull(t2.allocated_amount,0)) from `tab%s` t1, `tabSales Team` t2 where t2.%s in %s and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and t1.%s between '%s' and '%s'"%(under, based_on_fn, ch, under, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
+    #----------------------------------------------------------
+    actual = flt(actual[0][0])
+    r.append(actual)
+    # ================ Variance ===================================================
+    r.append(r[idx] - r[idx + 1])
+    count = count +1
\ No newline at end of file
diff --git a/crm/search_criteria/total_target_variance_report/total_target_variance_report.sql b/crm/search_criteria/total_target_variance_report/total_target_variance_report.sql
new file mode 100644
index 0000000..ebd7ae8
--- /dev/null
+++ b/crm/search_criteria/total_target_variance_report/total_target_variance_report.sql
@@ -0,0 +1 @@
+SELECT CONCAT(REPEAT('     ', COUNT(parent.name) - 1), node.name) AS name FROM `tab%(based_on)s` AS node,`tab%(based_on)s` AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.docstatus !=2 GROUP BY node.name ORDER BY node.lft
\ No newline at end of file
diff --git a/crm/search_criteria/total_target_variance_report/total_target_variance_report.txt b/crm/search_criteria/total_target_variance_report/total_target_variance_report.txt
new file mode 100644
index 0000000..27ea80c
--- /dev/null
+++ b/crm/search_criteria/total_target_variance_report/total_target_variance_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Sales Person\x01ID,Sales Person\x01Owner,Sales Person\x01Sales Person,Sales Person\x01Country,Sales Person\x01State,Sales Person\x01lft,Sales Person\x01rgt,Target Detail\x01Item Group,Target Detail\x01Fiscal Year,Target Detail\x01Target  Amount',
+		'creation': '2010-12-14 10:33:08',
+		'criteria_name': 'Total Target Variance Report',
+		'custom_query': None,
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Target Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Sales Person\x01Saved':1,'Sales Person\x01Submitted':1,'Sales Person\x01Country':'','Sales Person\x01State':'','Target Detail\x01Fiscal Year':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-11-30 15:15:34',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'total_target_variance_report',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Sales Person',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSales Person`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/crm/search_criteria/variance_report/__init__.py b/crm/search_criteria/variance_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/search_criteria/variance_report/__init__.py
diff --git a/crm/search_criteria/variance_report/variance_report.js b/crm/search_criteria/variance_report/variance_report.js
new file mode 100644
index 0000000..e1f67d6
--- /dev/null
+++ b/crm/search_criteria/variance_report/variance_report.js
@@ -0,0 +1,12 @@
+report.customize_filters = function() {
+  this.hide_all_filters();
+  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Territory'+NEWLINE+'Sales Person'+NEWLINE+'Sales Partner',report_default:'Territory',ignore : 1,parent:'Target Detail'});
+  this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company',report_default:sys_defaults.company, ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
+//  this.add_filter({fieldname:'item_group', label:'Item Group', fieldtype:'Link', options:'Item Group', ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item Group',ignore : 1, parent:'Target Detail'});
+  this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Receivable Voucher',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
+}  
+
+//this.mytabs.items['Select Columns'].hide()
diff --git a/crm/search_criteria/variance_report/variance_report.py b/crm/search_criteria/variance_report/variance_report.py
new file mode 100644
index 0000000..3c26745
--- /dev/null
+++ b/crm/search_criteria/variance_report/variance_report.py
@@ -0,0 +1,503 @@
+# Add columns
+# -----------
+row_list = [['ID','Data','150px','']]
+
+for r in row_list:
+  colnames.append(r[0])
+  coltypes.append(r[1])
+  colwidths.append(r[2])
+  coloptions.append(r[3])
+  col_idx[r[0]] = len(colnames)-1
+
+if not filter_values.get('fiscal_year'):
+  msgprint("Please Select Fiscal Year")
+  raise Exception
+elif not filter_values.get('period'):
+  msgprint("Please Select Period")
+  raise Exception
+elif not filter_values.get('based_on'):
+  msgprint("Please Select the Criteria on which you want your report to be based")
+  raise Exception
+elif not filter_values.get('group_by') and filter_values.get('item_group'):
+  msgprint("Item Group cannot be selected if Group By is not Item Group")
+  raise Exception
+
+fiscal_year = filter_values.get('fiscal_year')
+period = filter_values.get('period')
+based_on = filter_values.get('based_on')
+group_by = filter_values.get('group_by')
+item_group = filter_values.get('item_group')
+msgprint(item_group)
+company = filter_values.get('company')
+under = filter_values.get('under')
+
+#if filter_values.get('item_group'):
+#  itm_grp = filter_values.get('item_group')
+  
+if based_on == 'Territory':
+  based = 'territory'
+elif based_on == 'Sales Person':
+  based = 'sales_person'
+elif based_on == 'Sales Partner':
+  based = 'sales_partner'
+
+
+if under == 'Receivable Voucher':
+  under_detail = 'RV'
+  dt = 'voucher_date'
+else:
+  under_detail = under
+  dt = "transaction_date"
+  
+# get fiscal year start date and start month
+year_start_date = sql("select year_start_date,MONTH(year_start_date) from `tabFiscal Year` where name = %s",fiscal_year)
+start_date = year_start_date and year_start_date[0][0] or ''
+start_month = year_start_date and year_start_date[0][1] or ''
+month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
+
+# Add columns based on period
+# --------------------------------
+columns = []
+if group_by == 'Item Group':
+  columns.append(['Item Group','Data','120px',''])
+# ================ Annual ======================
+if period == 'Annual':
+  columns.append(['Target','Currency','120px',''])
+  columns.append(['Actual','Currency','120px',''])
+
+# =========== Half Yearly ======================
+elif period == 'Half Yearly':
+  columns.append(['Target (H1)','Currency','120px','']) # first half
+  columns.append(['Actual (H1)','Currency','120px','']) # first half
+  columns.append(['Target (H2)','Currency','120px',''])
+  columns.append(['Actual (H2)','Currency','120px','']) 
+  
+# ================ Quarterly ===================
+elif period == 'Quarterly':
+  length_1 = (len(month_name) - start_month + 1) / 3  #this gives the total no. of times we need to iterate for quarter
+  val = length_1 % 4
+  q_no = 1
+  for i in range(length_1):
+    value = 3*i + val
+    columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
+    columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
+    q_no += 1
+  length_2 = (start_month - 1) / 3 #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
+  for i in range(length_2):
+    columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
+    columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
+    q_no += 1;
+
+# =============== Monthly ======================
+elif period == 'Monthly':
+  for i in range(start_month-1,len(month_name)):
+    columns.append(['Target ('+month_name[i]+')','Currency','120px',''])
+    columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
+
+  for i  in range(start_month-1):
+    columns.append(['Target('+month_name[i]+')','Currency','120px',''])
+    columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
+
+for c in columns:
+  colnames.append(c[0])
+  coltypes.append(c[1])
+  colwidths.append(c[2])
+  coloptions.append(c[3])
+  col_idx[c[0]] = len(colnames)-1
+
+out = []
+if company:
+  condition = ' fiscal_year = "'+fiscal_year+'" and company = "'+company+'"'
+else:
+  condition = ' fiscal_year = "'+fiscal_year+'"'
+
+#=================== function for fetching  allocated percentage in Distribution id according to period=============
+def get_budget_distribution(period,dist_id,fiscal_year):
+  query = ''
+  id1 = 1
+  if period == 'Half Yearly':
+    id2 = 6
+    for i in range(2):
+      query += 'SUM(CASE WHEN t2.idx BETWEEN '+str(id1)+' AND '+str(id2)+' THEN t2.percentage_allocation ELSE NULL END)'
+      id1 += 6
+      id2 += 6
+      if i < 1 :
+        query += ','
+
+  elif period == 'Quarterly':
+    id2 = 3
+    for i in range(4):
+      query += 'SUM(CASE WHEN t2.idx BETWEEN '+str(id1)+' AND '+str(id2)+' THEN t2.percentage_allocation ELSE NULL END)'
+      id1 += 3
+      id2 += 3
+      if i < 3 :
+        query += ','
+    
+  elif period == 'Monthly':
+    for i in range(12):
+      query += 'SUM(CASE WHEN t2.idx ='+str(id1)+' THEN t2.percentage_allocation ELSE NULL END)'
+      id1 += 1
+      if i < 11 :
+        query += ','
+    
+#  msgprint(query) 
+   
+  # Main Query
+  dist = sql("select %s from `tabBudget Distribution` t1, `tabBudget Distribution Detail` t2 where t1.name = '%s' and t2.parent = t1.name and t1.fiscal_year = '%s'"%(query,dist_id,fiscal_year))
+  dist = dist and dist[0] or 0
+#  msgprint(dist)
+  bug = []
+  for i in dist:
+    i = i and float(i) or 0
+    bug.append(i)
+#  msgprint(bug)
+  return bug
+
+
+#============ function for appending target amt and actual amt in a proper order ======================= 
+def appending_func(ran,tl,lst,actual,flt):
+
+  c = 2
+  for i in range(ran):
+    #==== for each itemgroup their actual amt is appended/inserted between target amt  
+    if tl == 0:
+      lst.insert(c,actual and flt(actual[0][i]) or 0)
+    #======== here actual amt is appended/inserted b/w target amt for a particular territory/sales person/sales partner only if target is not zero 
+    elif tl == 1:
+#      msgprint(lst)
+      lst.insert(c,actual and flt(actual[0][i]) or 0)
+    c += 2
+  return lst
+
+def get_target(tar_det,group_by,period,fiscal_year,rng,r,get_budget_distribution,flt):
+
+  grp,lst = [],[]
+  list_range,tl = 0,0
+  if group_by == 'Item Group':
+    for i in tar_det:
+      if i[0] != '':
+        igrp = [i[0]]
+        if i[2]:
+          dist_id = i[2]
+          dist = get_budget_distribution(period,dist_id,fiscal_year)
+          for d in dist:
+            t = flt(flt(flt(i[1]) * flt(d))/ 100)
+            igrp.append(t)            
+        else:
+          t = i and flt(i[1]/rng) or 0
+          for i in range(rng):
+            igrp.append(t)
+            
+        grp.append(igrp)
+        list_range +=1
+    lst = [1,grp,list_range]
+    
+    #============== Total target(on basis of whole target ) ============
+  else:
+    for i in tar_det:
+      if i[0] == '':
+        if i[2]:
+          dist_id = i[2]
+          dist = get_budget_distribution(period,dist_id,fiscal_year)
+          for d in dist:
+            t = flt((flt(i[1]) * flt(d))/ 100)
+            r.append(t)
+        else:
+          tot_target = i and flt(i[1]/rng) or 0
+          for i in range(rng):
+            r.append(tot_target)
+        tl = 1
+    lst = [0,r,tl]
+  return lst
+#============ report display function =====================
+for r in res:
+  query = ''
+  grp=[]
+  list_range, count, ap, tot_target, tl = 0,0,0,0,0
+    
+  #============= ANNUAL REPORT ===================
+  if period == 'Annual':
+    tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year))
+#    msgprint(tar_det)
+
+    #================ Target based on individual item group ==============
+    if group_by == 'Item Group':
+      for i in tar_det:
+        if i[0] != '':
+          grp_target = i and flt(i[1]) or 0
+          igrp = [i[0],grp_target]
+          grp.append(igrp)
+#          msgprint(grp)
+          list_range +=1
+          count = 3
+
+    #============== Total target(will be displayed only if target is specified by the user) ============
+    else:
+      for i in tar_det:
+        # ======= here target is considered and not sum of target of item groups
+        if i[0] == '':
+          tot_target = tar_det and flt(i[1]) or 0
+#          msgprint(tot_target)
+    
+   #================== Actual Amount =============================================
+    if based_on == 'Territory' or based_on == 'Sales Partner':
+
+      if group_by =='Item Group':
+
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select sum(t2.amount) from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(under,under_detail,based,r[col_idx['ID']],item_group,condition))
+          msgprint(actual)
+          actual = actual and flt(actual[0][0]) or 0
+          i.append(actual)
+          
+      else:
+        actual = sql("select sum(net_total) from `tab%s` where %s = '%s' and docstatus = 1 and  %s" % (under, based, r[col_idx['ID']],condition))
+        actual = actual and flt(actual[0][0]) or 0
+        
+    elif based_on == 'Sales Person':
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select sum(t2.amount) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and  %s"%(under,under_detail,based,r[col_idx['ID']],item_group,condition))
+          actual = actual and flt(actual[0][0]) or 0
+#          msgprint(actual)
+          i.append(actual)
+
+      else:
+        actual = sql("select sum(t1.net_total) from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(under,based,r[col_idx['ID']],under,condition))
+        actual = actual and flt(actual[0][0]) or 0
+#        msgprint(actual)
+
+  # ================= Half Yearly Report =============== 
+  elif period == 'Half Yearly':
+    tl = 0
+    grp_target = []
+
+    tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year)) 
+#    msgprint(tar_det)
+    
+    tar = get_target(tar_det,group_by,period,fiscal_year,2,r,get_budget_distribution,flt)
+    if tar[0] == 1:
+      grp = tar[1]
+      list_range = tar[2]
+      count = 5
+    else:
+      r = tar[1]
+      tl = tar[2]
+      
+    #============= Actual Amount======================
+    if group_by == 'Item Group':
+      # first half
+      query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t2.amount ELSE NULL END),'
+      # second half
+      query += 'SUM(CASE WHEN MONTH(t1.'+dt+') NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t2.amount ELSE NULL END)';
+
+    elif based_on != 'Sales Person':
+      # first half
+      query += 'SUM(CASE WHEN MONTH('+dt+') BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),'
+      # second half
+      query += 'SUM(CASE WHEN MONTH('+dt+') NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END)';
+
+    else:
+      # first half
+      query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t1.net_total ELSE NULL END),'
+      # second half
+      query += 'SUM(CASE WHEN MONTH(t1.'+dt+') NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t1.net_total ELSE NULL END)';
+
+    #=========== Main Query ===============
+    if based_on == 'Territory' or based_on == 'Sales Partner':
+
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
+#          msgprint(actual)        
+          i = appending_func(2,tl,i,actual,flt)
+                    
+      else:
+        actual = sql("select %s from `tab%s` where %s = '%s' and docstatus = 1 and  %s" % (query,under, based, r[col_idx['ID']],condition))
+#        msgprint(actual)
+
+    elif based_on == 'Sales Person':
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
+#          msgprint(actual)
+          i = appending_func(2,tl,i,actual,flt)
+      else:
+        actual = sql("select %s from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(query,under,based,r[col_idx['ID']],under,condition))
+#        msgprint(actual)
+
+    if tl == 1:
+      r = appending_func(2,tl,r,actual,flt)
+#      msgprint(r)
+
+  #============== Quarterly Report =========================
+  elif period == 'Quarterly':
+    tl = 0
+    grp_target = []
+    tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year)) 
+
+    tar = get_target(tar_det,group_by,period,fiscal_year,4,r,get_budget_distribution,flt)
+    if tar[0] == 1:
+      grp = tar[1]
+      list_range = tar[2]
+      count = 9
+    else:
+      r = tar[1]
+      tl = tar[2]
+      
+    #======= Actual Amt ==================
+    length_1 = (len(month_name) - start_month + 1) / 3; #this gives the total no. of times we need to iterate for quarter
+    val = length_1 % 4;
+    for i in range(length_1):
+      value = 3*i + val;
+
+      if group_by == 'Item Group':
+        query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN t2.amount ELSE NULL END),'
+
+      elif based_on != 'Sales Person':
+        query += 'SUM(CASE WHEN MONTH('+dt+') BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),'
+
+      else:
+        query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN t1.net_total ELSE NULL END),'
+
+    length_2 = (start_month - 1) / 3; #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
+    for i in range(length_2):
+      if group_by == 'Item Group':
+        query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN t2.amount ELSE NULL END)';
+
+      elif based_on != 'Sales Person':
+        query += 'SUM(CASE WHEN MONTH('+dt+') BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END)';
+
+      else:
+        query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN t1.net_total ELSE NULL END)';
+
+    #=========== Main Query ===============
+    if based_on == 'Territory' or based_on == 'Sales Partner':
+
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
+#          msgprint(actual)
+          #================common function          
+          i = appending_func(4,tl,i,actual,flt)
+          
+      else:
+        actual = sql("select %s from `tab%s` where %s = '%s' and docstatus = 1 and  %s" % (query,under, based, r[col_idx['ID']],condition))
+#        msgprint(actual)
+        
+    elif based_on == 'Sales Person':
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
+#          msgprint(actual)
+          i = appending_func(4,tl,i,actual,flt)
+      else:
+        actual = sql("select %s from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(query,under,based,r[col_idx['ID']],under,condition))
+#        msgprint(actual)
+
+    if tl == 1:
+      r = appending_func(4,tl,r,actual,flt)
+#      msgprint(r)
+
+  #================ Monthly Report ===========================
+  elif period == 'Monthly':
+    tl = 0
+    grp_target = []
+    tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year)) 
+
+    tar = get_target(tar_det,group_by,period,fiscal_year,12,r,get_budget_distribution,flt)
+    if tar[0] == 1:
+      grp = tar[1]
+      list_range = tar[2]
+      count = 25
+    else:
+      r = tar[1]
+      tl = tar[2]
+      
+    #======= Actual Amt ==================
+    # for loop is required twice coz fiscal year starts from April (this will also work if fiscal year starts in January)
+    for i in range(start_month-1,len(month_name)):
+      if group_by == 'Item Group':
+        query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t2.amount ELSE NULL END),'
+
+      elif based_on != 'Sales Person':
+        query += 'SUM(CASE WHEN MONTH('+dt+') = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
+
+      else:
+        query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t1.net_total ELSE NULL END),'
+
+    for i  in range(start_month-1):
+      if i != (start_month-1):
+        if group_by == 'Item Group':
+          query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t2.amount ELSE NULL END)'
+
+        elif based_on != 'Sales Person':
+          query += 'SUM(CASE WHEN MONTH('+dt+') = '+cstr(i+1)+' THEN net_total ELSE NULL END)'
+
+        else:
+          query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t1.net_total ELSE NULL END)'
+
+        if i < (start_month -2):
+          query += ','
+
+    #=========== Main Query ===============
+    if based_on == 'Territory' or based_on == 'Sales Partner':
+
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
+#          msgprint(actual)
+          #===============common function=====================         
+          i = appending_func(12,tl,i,actual,flt)
+          
+      else:
+        actual = sql("select %s from `tab%s` where %s = '%s' and docstatus = 1 and  %s" % (query,under, based, r[col_idx['ID']],condition))
+#        msgprint(actual)
+        
+    elif based_on == 'Sales Person':
+      if group_by =='Item Group':
+        for i in grp:
+          item_group = i[0]
+          actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
+#          msgprint(actual)
+          i = appending_func(12,tl,i,actual,flt)
+      else:
+        actual = sql("select %s from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(query,under,based,r[col_idx['ID']],under,condition))
+#        msgprint(actual)
+
+    if tl == 1:
+      r = appending_func(12,tl,r,actual,flt)
+#      msgprint(r)
+
+#-------------DISPLAY OF TARGET vs ACTUAL ON BASIS OF TOTAL TARGET / ITEM GROUP 
+
+  if group_by == 'Item Group':
+    for col in range(len(colnames)-1): # this would make all first row blank. just for look
+      r.append('')
+
+    for des in range(list_range):
+      if ap == 0:
+        out.append(r)
+        ap = 1
+      t_row = ['' for i in range(len(colnames))]
+
+      for v in range(count):
+        t_row[col_idx[colnames[v+1]]] = grp[des][v]
+#        msgprint(t_row)
+      out.append(t_row)
+
+  elif tot_target != 0 and period =='Annual':
+    r.append(tot_target)
+    r.append(actual)
+    out.append(r)
+    tot_target = 0
+
+  elif tl == 1:
+    out.append(r)
\ No newline at end of file
diff --git a/crm/search_criteria/variance_report/variance_report.sql b/crm/search_criteria/variance_report/variance_report.sql
new file mode 100644
index 0000000..89becb7
--- /dev/null
+++ b/crm/search_criteria/variance_report/variance_report.sql
@@ -0,0 +1 @@
+SELECT DISTINCT t1.`name` FROM `tab%(based_on)s` t1, `tabTarget Detail` t2 WHERE t2.parent = t1.name  and (t2.target_amount != 0 or t2.target_amount is not null)
\ No newline at end of file
diff --git a/crm/search_criteria/variance_report/variance_report.txt b/crm/search_criteria/variance_report/variance_report.txt
new file mode 100644
index 0000000..5ca7ea6
--- /dev/null
+++ b/crm/search_criteria/variance_report/variance_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': '',
+		'creation': '2010-08-08 17:09:31',
+		'criteria_name': 'Variance Report',
+		'custom_query': None,
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Target Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Territory\x01State':'','Target Detail\x01Fiscal Year':'2009-2010','Target Detail\x01Based On':'Territory','Target Detail\x01Company':'Alpha Company','Target Detail\x01Period':'Quarterly','Target Detail\x01Under':'Sales Order'}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-05-05 11:13:12',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'variance_report',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Territory',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': 'ID',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file