restructured erpnext and deleted unwanted
diff --git a/stock/DocType Label/QA Inspection Report/QA Inspection Report.txt b/stock/DocType Label/QA Inspection Report/QA Inspection Report.txt
new file mode 100644
index 0000000..a4d266f
--- /dev/null
+++ b/stock/DocType Label/QA Inspection Report/QA Inspection Report.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'QA Inspection Report', 'parent': None, 'dt_label': 'Quality Inspection', 'creation': '2010-06-28 12:56:06', 'modified': '2010-06-28 12:56:06', 'module': 'Accounts', 'doctype': 'DocType Label', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'dt': 'QA Inspection Report', 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/DocType Mapper/Project-Delivery Note/Project-Delivery Note.txt b/stock/DocType Mapper/Project-Delivery Note/Project-Delivery Note.txt
new file mode 100644
index 0000000..410a120
--- /dev/null
+++ b/stock/DocType Mapper/Project-Delivery Note/Project-Delivery Note.txt
@@ -0,0 +1 @@
+[{'modified_by': 'ashwini@webnotestech.com', 'name': 'Project-Delivery Note', 'parent': None, 'to_doctype': 'Delivery Note', 'creation': '2010-08-18 18:07:55', 'modified': '2010-09-01 14:25:08', 'module': 'Mapper', 'doctype': 'DocType Mapper', 'idx': None, 'parenttype': None, 'ref_doc_submitted': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_doctype': 'Project', 'parentfield': None}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00894', 'parent': 'Project-Delivery Note', 'to_field': 'customer', 'creation': '2010-08-26 13:31:56', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 1, 'parenttype': 'DocType Mapper', 'checking_operator': '=', 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'customer', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00875', 'parent': 'Project-Delivery Note', 'to_field': 'customer_name', 'creation': '2010-08-18 18:07:55', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 2, 'parenttype': 'DocType Mapper', 'checking_operator': '', 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'customer_name', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00876', 'parent': 'Project-Delivery Note', 'to_field': 'customer_address', 'creation': '2010-08-18 18:07:55', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 3, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'customer_address', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00877', 'parent': 'Project-Delivery Note', 'to_field': 'contact_person', 'creation': '2010-08-18 18:07:55', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 4, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'contact_person', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00878', 'parent': 'Project-Delivery Note', 'to_field': 'contact_no', 'creation': '2010-08-18 18:07:55', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 5, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'contact_no', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00879', 'parent': 'Project-Delivery Note', 'to_field': 'email_id', 'creation': '2010-08-18 18:07:55', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 6, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'email_id', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00883', 'parent': 'Project-Delivery Note', 'to_field': 'territory', 'creation': '2010-08-19 14:14:32', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 7, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'territory', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'ashwini@webnotestech.com', 'name': 'FMD/00884', 'parent': 'Project-Delivery Note', 'to_field': 'customer_group', 'creation': '2010-08-19 14:14:32', 'modified': '2010-09-01 14:25:08', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 8, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'check_reference_value': None, 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'from_field': 'customer_group', 'parentfield': 'field_mapper_details'}, {'reference_key': '', 'modified_by': 'ashwini@webnotestech.com', 'name': 'TMD/0000087', 'parent': 'Project-Delivery Note', 'is_reference_table': None, 'to_field': None, 'creation': '2010-08-18 18:07:55', 'reference_doctype_key': '', 'modified': '2010-09-01 14:25:08', 'doctype': 'Table Mapper Detail', 'match_id': 0, 'idx': 1, 'parenttype': 'DocType Mapper', 'from_table': 'Project', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'to_table': 'Delivery Note', 'from_field': None, 'validation_logic': 'name is not null', 'parentfield': 'table_mapper_details'}]
\ No newline at end of file
diff --git a/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt b/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt
new file mode 100644
index 0000000..1d51ac1
--- /dev/null
+++ b/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt
@@ -0,0 +1,876 @@
+[
+	{
+		'_last_update': None,
+		'_user_tags': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': u'DocType Mapper',
+		'from_doctype': 'Purchase Order',
+		'idx': None,
+		'modified': '2011-05-13 12:42:57',
+		'modified_by': 'Administrator',
+		'module': 'Mapper',
+		'name': 'Purchase Order-Purchase Receipt',
+		'owner': 'Administrator',
+		'parent': None,
+		'parentfield': None,
+		'parenttype': None,
+		'ref_doc_submitted': 1,
+		'to_doctype': 'Purchase Receipt'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'supplier',
+		'idx': 1,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00197',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'supplier'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'supplier_address',
+		'idx': 2,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00198',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'supplier_address'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-09-01 15:48:10',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'supplier_name',
+		'idx': 4,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00586',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'supplier_name'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 15:54:25',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'address_display',
+		'idx': 5,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': '000003501',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'address_display'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 15:54:25',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_display',
+		'idx': 6,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': '000003502',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_display'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 15:54:25',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_mobile',
+		'idx': 7,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': '000003503',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_mobile'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 15:54:25',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_email',
+		'idx': 8,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': '000003504',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_email'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'company',
+		'idx': 9,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00199',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'company'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'fiscal_year',
+		'idx': 10,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00200',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'fiscal_year'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'currency',
+		'idx': 11,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00201',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'currency'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'warehouse',
+		'idx': 12,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00202',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'warehouse'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-09 09:44:02',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'terms',
+		'idx': 13,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00553',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'terms'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'conversion_factor',
+		'idx': 14,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00203',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'conversion_factor'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'stock_uom',
+		'idx': 15,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00204',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'stock_uom'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'name',
+		'idx': 16,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00205',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'prevdoc_detail_docname'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'parent',
+		'idx': 17,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00206',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'prevdoc_docname'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'parenttype',
+		'idx': 18,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00207',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'prevdoc_doctype'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'uom',
+		'idx': 19,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00208',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'uom'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_code',
+		'idx': 20,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00209',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_code'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'brand',
+		'idx': 21,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00210',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'brand'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_name',
+		'idx': 22,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00211',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_name'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) ',
+		'idx': 23,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00212',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'received_qty'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) ',
+		'idx': 24,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00213',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'qty'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor)',
+		'idx': 25,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00214',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'stock_qty'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'purchase_rate',
+		'idx': 26,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00215',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'purchase_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'description',
+		'idx': 27,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00216',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'description'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_group',
+		'idx': 28,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00217',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_group'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'import_rate',
+		'idx': 29,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:25',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00218',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'import_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.import_rate)',
+		'idx': 30,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00219',
+		'owner': 'jai@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'import_amount'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'schedule_date',
+		'idx': 31,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00220',
+		'owner': 'jitesh',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'schedule_date'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.purchase_rate)',
+		'idx': 32,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00221',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'amount'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-03-23 15:14:10',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_tax_rate',
+		'idx': 33,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': '000001919',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_tax_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'conversion_rate',
+		'idx': 34,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00222',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'conversion_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'category',
+		'idx': 35,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00223',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'category'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'add_deduct_tax',
+		'idx': 36,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00224',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'add_deduct_tax'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'charge_type',
+		'idx': 37,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00225',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'charge_type'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'row_id',
+		'idx': 38,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00226',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'row_id'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_wise_tax_detail',
+		'idx': 39,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00227',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_wise_tax_detail'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_person',
+		'idx': 39,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00232',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_person'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'description',
+		'idx': 40,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00228',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'description'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'account_head',
+		'idx': 41,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00229',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'account_head'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'cost_center',
+		'idx': 42,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00230',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'cost_center'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'rate',
+		'idx': 43,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00231',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-09-01 15:48:10',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'project_name',
+		'idx': 44,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00587',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'project_name'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': 'po_details',
+		'from_table': 'PO Detail',
+		'idx': 1,
+		'match_id': 1,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000025',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': 'prevdoc_doctype',
+		'reference_key': 'prevdoc_detail_docname',
+		'to_field': 'purchase_receipt_details',
+		'to_table': 'Purchase Receipt Detail',
+		'validation_logic': 'docstatus=1 and qty > ifnull(received_qty,0)'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': None,
+		'from_table': 'Purchase Order',
+		'idx': 2,
+		'match_id': 0,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000026',
+		'owner': 'Administrator',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': None,
+		'reference_key': 'prevdoc_docname',
+		'to_field': None,
+		'to_table': 'Purchase Receipt',
+		'validation_logic': 'docstatus = 1'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': 'purchase_tax_details',
+		'from_table': 'Purchase Tax Detail',
+		'idx': 3,
+		'match_id': 2,
+		'modified': '2011-05-20 15:54:26',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000027',
+		'owner': 'wasim@webnotestech.com',
+		'parent': 'Purchase Order-Purchase Receipt',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': None,
+		'reference_key': None,
+		'to_field': 'purchase_tax_details',
+		'to_table': 'Purchase Tax Detail',
+		'validation_logic': 'docstatus = 1'
+	}
+]
\ No newline at end of file
diff --git a/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt b/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt
new file mode 100755
index 0000000..3b4e8ba
--- /dev/null
+++ b/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'Receivable Voucher-Delivery Note', 'parent': None, 'to_doctype': 'Delivery Note', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'module': 'Mapper', 'doctype': 'DocType Mapper', 'idx': None, 'parenttype': None, 'ref_doc_submitted': 1, 'owner': 'Administrator', 'docstatus': 0, 'from_doctype': 'Receivable Voucher', 'parentfield': None}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00521', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'currency', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 1, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'currency', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00522', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'company', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 2, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'company', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00523', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'fiscal_year', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 3, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'fiscal_year', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00524', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'customer', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 4, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'customer', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00525', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'customer_name', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 5, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'customer_name', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00526', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'price_list_name', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 6, 'parenttype': 'DocType Mapper', 'checking_operator': '', 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'price_list_name', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00527', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'conversion_rate', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 7, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'conversion_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00528', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'charge', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 8, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'charge', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00529', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'terms', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 9, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'terms', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00530', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'item_code', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 10, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'item_code', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00531', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'item_name', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 11, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'item_name', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00532', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'brand', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 12, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'brand', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00533', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'description', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 13, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'description', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00534', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'item_group', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 14, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'item_group', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00535', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'qty', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 15, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'eval: flt(obj.qty) - flt(obj.delivered_qty)', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00536', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'base_ref_rate', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 16, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'base_ref_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00537', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'ref_rate', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 17, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'ref_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00538', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'basic_rate', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 18, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'basic_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00539', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'export_rate', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 19, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'export_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00540', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'prevdoc_docname', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 20, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'parent', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00541', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'prevdoc_doctype', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 21, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'parenttype', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00542', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'prevdoc_detail_docname', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 22, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'name', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00543', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'export_rate', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 23, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'export_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00544', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'amount', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 24, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00545', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'export_amount', 'creation': '2010-12-14 16:40:41', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 25, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00546', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'adj_rate', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 26, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'adj_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00547', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'item_tax_rate', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 27, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'item_tax_rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00548', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'warehouse', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 1, 'idx': 28, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'warehouse', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00549', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'charge_type', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 29, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'charge_type', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00550', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'row_id', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 30, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'row_id', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00551', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'item_wise_tax_detail', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 31, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'item_wise_tax_detail', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00552', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'description', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 32, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'description', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00553', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'account_head', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 33, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'account_head', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00554', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'rate', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 34, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'rate', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00555', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'tax_amount', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 35, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'tax_amount', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00556', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'total', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 2, 'idx': 36, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'total', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00557', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'sales_person', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 3, 'idx': 37, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'sales_person', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00558', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'allocated_percentage', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 3, 'idx': 38, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'allocated_percentage', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00559', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'allocated_amount', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 3, 'idx': 39, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'allocated_amount', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00560', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'source', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 40, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'source', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00561', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'campaign', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 41, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'campaign', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00562', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'sales_partner', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 42, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'sales_partner', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00563', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'customer_address', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 43, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'customer_address', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00564', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'delivery_address', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 44, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'customer_address', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00565', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'net_total', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 45, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'net_total', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00566', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'grand_total', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 46, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'grand_total', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00567', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'territory', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 47, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'territory', 'parentfield': 'field_mapper_details'}, {'map': 'Yes', 'modified_by': 'Administrator', 'name': 'FMD/00568', 'parent': 'Receivable Voucher-Delivery Note', 'to_field': 'project_name', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Field Mapper Detail', 'match_id': 0, 'idx': 48, 'parenttype': 'DocType Mapper', 'checking_operator': None, 'owner': 'Administrator', 'docstatus': 0, 'from_field': 'project_name', 'parentfield': 'field_mapper_details'}, {'reference_key': '', 'modified_by': 'Administrator', 'name': 'TMD/0000056', 'parent': 'Receivable Voucher-Delivery Note', 'reference_doctype_key': '', 'to_field': None, 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Table Mapper Detail', 'match_id': 0, 'idx': 1, 'parenttype': 'DocType Mapper', 'from_table': 'Receivable Voucher', 'owner': 'Administrator', 'docstatus': 0, 'to_table': 'Delivery Note', 'from_field': '', 'validation_logic': 'docstatus=1', 'parentfield': 'table_mapper_details'}, {'reference_key': '', 'modified_by': 'Administrator', 'name': 'TMD/0000057', 'parent': 'Receivable Voucher-Delivery Note', 'reference_doctype_key': '', 'to_field': 'delivery_note_details', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Table Mapper Detail', 'match_id': 1, 'idx': 2, 'parenttype': 'DocType Mapper', 'from_table': 'RV Detail', 'owner': 'Administrator', 'docstatus': 0, 'to_table': 'Delivery Note Detail', 'from_field': 'entries', 'validation_logic': 'docstatus = 1', 'parentfield': 'table_mapper_details'}, {'reference_key': '', 'modified_by': 'Administrator', 'name': 'TMD/0000058', 'parent': 'Receivable Voucher-Delivery Note', 'reference_doctype_key': '', 'to_field': 'other_charges', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Table Mapper Detail', 'match_id': 2, 'idx': 3, 'parenttype': 'DocType Mapper', 'from_table': 'RV Tax Detail', 'owner': 'Administrator', 'docstatus': 0, 'to_table': 'RV Tax Detail', 'from_field': 'other_charges', 'validation_logic': 'name is not null', 'parentfield': 'table_mapper_details'}, {'reference_key': '', 'modified_by': 'Administrator', 'name': 'TMD/0000059', 'parent': 'Receivable Voucher-Delivery Note', 'reference_doctype_key': '', 'to_field': 'sales_team', 'creation': '2010-12-14 16:40:42', 'modified': '2010-12-14 20:43:41', 'doctype': 'Table Mapper Detail', 'match_id': 3, 'idx': 4, 'parenttype': 'DocType Mapper', 'from_table': 'Sales Team', 'owner': 'Administrator', 'docstatus': 0, 'to_table': 'Sales Team', 'from_field': 'sales_team', 'validation_logic': 'name is not null', 'parentfield': 'table_mapper_details'}]
\ No newline at end of file
diff --git a/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt b/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt
new file mode 100644
index 0000000..ef4cf6c
--- /dev/null
+++ b/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt
@@ -0,0 +1,1473 @@
+[
+	{
+		'_last_update': None,
+		'_user_tags': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': u'DocType Mapper',
+		'from_doctype': 'Sales Order',
+		'idx': None,
+		'modified': '2011-05-16 11:48:19',
+		'modified_by': 'Administrator',
+		'module': 'Mapper',
+		'name': 'Sales Order-Delivery Note',
+		'owner': 'Administrator',
+		'parent': None,
+		'parentfield': None,
+		'parenttype': None,
+		'ref_doc_submitted': 1,
+		'to_doctype': 'Delivery Note'
+	},
+	{
+		'checking_operator': '>=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'transaction_date',
+		'idx': 1,
+		'map': 'No',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00320',
+		'owner': 'nabin@webnotestech.com',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'transaction_date'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'price_list_name',
+		'idx': 2,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00321',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'price_list_name'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'name',
+		'idx': 3,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00322',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'sales_order_no'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'company',
+		'idx': 4,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00323',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'company'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'fiscal_year',
+		'idx': 5,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00324',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'fiscal_year'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'po_date',
+		'idx': 6,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00325',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'po_date'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'po_no',
+		'idx': 7,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00326',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'po_no'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'sales_partner',
+		'idx': 8,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00327',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'sales_partner'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'commission_rate',
+		'idx': 9,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00328',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'commission_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'total_commission',
+		'idx': 10,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00329',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'total_commission'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'currency',
+		'idx': 11,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00331',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'currency'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'conversion_rate',
+		'idx': 12,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00332',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'conversion_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 12:58:43',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'shipping_address_name',
+		'idx': 14,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': '000003464',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer_address'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'customer_address',
+		'idx': 15,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2010-08-08 17:09:35',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00334',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'delivery_address'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_person',
+		'idx': 15,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00336',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_person'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'customer_name',
+		'idx': 16,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00333',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer_name'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'customer_address',
+		'idx': 16,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2010-08-08 17:09:35',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00335',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer_address'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 12:58:43',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'shipping_address',
+		'idx': 17,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': '000003465',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'address_display'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 12:58:43',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_display',
+		'idx': 18,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': '000003466',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_display'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_no',
+		'idx': 18,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2010-08-08 17:09:35',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00337',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_no'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 12:58:43',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_mobile',
+		'idx': 19,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': '000003467',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_mobile'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'email_id',
+		'idx': 19,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2010-08-08 17:09:35',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00338',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'email_id'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 12:58:43',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'contact_email',
+		'idx': 20,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': '000003468',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'contact_email'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-03-24 14:08:13',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'ship_det_no',
+		'idx': 21,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-03-24 14:08:13',
+		'modified_by': 'rahul@webnotestech.com',
+		'name': '000002010',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'ship_det_no'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-03-24 14:08:13',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'ship_to',
+		'idx': 22,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-03-24 14:08:13',
+		'modified_by': 'rahul@webnotestech.com',
+		'name': '000002011',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'ship_to'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'customer_group',
+		'idx': 22,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00340',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer_group'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-03-24 14:08:13',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'shipping_address',
+		'idx': 23,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-03-24 14:08:13',
+		'modified_by': 'rahul@webnotestech.com',
+		'name': '000002012',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'shipping_address'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'charge',
+		'idx': 23,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00339',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'charge'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'parent',
+		'idx': 24,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00341',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'prevdoc_docname'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'parenttype',
+		'idx': 25,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00342',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'prevdoc_doctype'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'name',
+		'idx': 26,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00343',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'prevdoc_detail_docname'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'export_rate',
+		'idx': 27,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00344',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'export_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)',
+		'idx': 28,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00345',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'export_amount'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_code',
+		'idx': 29,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00346',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_code'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_name',
+		'idx': 30,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00347',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_name'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'description',
+		'idx': 31,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00348',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'description'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_group',
+		'idx': 32,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00349',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_group'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'stock_uom',
+		'idx': 33,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00350',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'stock_uom'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'base_ref_rate',
+		'idx': 34,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00351',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'base_ref_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'ref_rate',
+		'idx': 35,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00352',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'ref_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'adj_rate',
+		'idx': 36,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00353',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'adj_rate'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'basic_rate',
+		'idx': 37,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00354',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'basic_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval: flt(obj.qty) - flt(obj.delivered_qty)',
+		'idx': 38,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00355',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'qty'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)',
+		'idx': 39,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00356',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'amount'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'reserved_warehouse',
+		'idx': 40,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00357',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'warehouse'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_tax_rate',
+		'idx': 41,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00358',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_tax_rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'charge_type',
+		'idx': 42,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00359',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'charge_type'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'row_id',
+		'idx': 43,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00360',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'row_id'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'item_wise_tax_detail',
+		'idx': 44,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00361',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'item_wise_tax_detail'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'description',
+		'idx': 45,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00362',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'description'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'account_head',
+		'idx': 46,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00363',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'account_head'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'rate',
+		'idx': 47,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00364',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'rate'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'tax_amount',
+		'idx': 48,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00365',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'tax_amount'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'total',
+		'idx': 49,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00366',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'total'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'idx',
+		'idx': 50,
+		'map': 'Yes',
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00367',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'idx'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'net_total',
+		'idx': 51,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00368',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'net_total'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'other_charges_total',
+		'idx': 52,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00369',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'other_charges_total'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'grand_total',
+		'idx': 53,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00370',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'grand_total'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'rounded_total',
+		'idx': 54,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00371',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'rounded_total'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'in_words',
+		'idx': 55,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00372',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'in_words'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'grand_total_export',
+		'idx': 56,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00373',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'grand_total_export'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'rounded_total_export',
+		'idx': 57,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00374',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'rounded_total_export'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'customer_mobile_no',
+		'idx': 57,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2010-08-08 17:09:35',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00376',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer_mobile_no'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'in_words_export',
+		'idx': 58,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00375',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'in_words_export'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2011-05-20 12:58:43',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'allocated_amount',
+		'idx': 59,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': '000003469',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer_mobile_no'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'allocated_amount',
+		'idx': 60,
+		'map': 'Yes',
+		'match_id': 3,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00377',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'allocated_amount'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'allocated_percentage',
+		'idx': 60,
+		'map': 'Yes',
+		'match_id': 3,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00378',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'allocated_percentage'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'sales_person',
+		'idx': 61,
+		'map': 'Yes',
+		'match_id': 3,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00379',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'sales_person'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'source',
+		'idx': 62,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00380',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'source'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'campaign',
+		'idx': 63,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00381',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'campaign'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'brand',
+		'idx': 64,
+		'map': 'Yes',
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00382',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'brand'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'terms',
+		'idx': 65,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00384',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'terms'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'territory',
+		'idx': 66,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00383',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'territory'
+	},
+	{
+		'checking_operator': None,
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'tc_name',
+		'idx': 66,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00385',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'tc_name'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-09-09 12:52:00',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'project_name',
+		'idx': 67,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00592',
+		'owner': 'harshada@webnotestech.com',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'project_name'
+	},
+	{
+		'checking_operator': '=',
+		'creation': '2010-09-09 12:52:00',
+		'docstatus': 0,
+		'doctype': 'Field Mapper Detail',
+		'from_field': 'customer',
+		'idx': 70,
+		'map': 'Yes',
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'FMD/00593',
+		'owner': 'saumil@webnotestech.com',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'field_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'to_field': 'customer'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': 'sales_team',
+		'from_table': 'Sales Team',
+		'idx': 1,
+		'match_id': 3,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000035',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': None,
+		'reference_key': None,
+		'to_field': 'sales_team',
+		'to_table': 'Sales Team',
+		'validation_logic': 'name is not null'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': 'other_charges',
+		'from_table': 'RV Tax Detail',
+		'idx': 2,
+		'match_id': 2,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000036',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': None,
+		'reference_key': None,
+		'to_field': 'other_charges',
+		'to_table': 'RV Tax Detail',
+		'validation_logic': 'name is not null'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': 'sales_order_details',
+		'from_table': 'Sales Order Detail',
+		'idx': 3,
+		'match_id': 1,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000037',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': 'prevdoc_doctype',
+		'reference_key': 'prevdoc_detail_docname',
+		'to_field': 'delivery_note_details',
+		'to_table': 'Delivery Note Detail',
+		'validation_logic': 'qty > ifnull(delivered_qty,0) and docstatus = 1'
+	},
+	{
+		'creation': '2010-08-08 17:09:35',
+		'docstatus': 0,
+		'doctype': 'Table Mapper Detail',
+		'from_field': None,
+		'from_table': 'Sales Order',
+		'idx': 4,
+		'match_id': 0,
+		'modified': '2011-05-20 12:58:43',
+		'modified_by': 'Administrator',
+		'name': 'TMD/0000038',
+		'owner': 'Administrator',
+		'parent': 'Sales Order-Delivery Note',
+		'parentfield': 'table_mapper_details',
+		'parenttype': 'DocType Mapper',
+		'reference_doctype_key': None,
+		'reference_key': 'prevdoc_docname',
+		'to_field': None,
+		'to_table': 'Delivery Note',
+		'validation_logic': 'docstatus = 1'
+	}
+]
\ No newline at end of file
diff --git a/stock/Item Group/All Item Groups/All Item Groups.txt b/stock/Item Group/All Item Groups/All Item Groups.txt
new file mode 100644
index 0000000..f03fa1a
--- /dev/null
+++ b/stock/Item Group/All Item Groups/All Item Groups.txt
@@ -0,0 +1 @@
+[{'creation': '2010-07-16 11:03:21', 'doctype': 'Item Group', 'lft': 1, 'owner': 'harshada@webnotestech.com', 'rgt': 286, 'company_abbr': None, 'docstatus': 0, 'item_group_name': 'All Item Groups', 'description': None, 'parent': None, 'is_group': 'Yes', 'company': None, 'show_in_catalogue': None, 'group_or_ledger': None, 'modified_by': 'harshada@webnotestech.com', 'group_name': None, 'trash_reason': None, 'name': 'All Item Groups', 'idx': None, 'modified': '2010-07-16 11:03:21', 'parent_item_group': '', 'old_parent': '', 'parenttype': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/Item Group/Default/Default.txt b/stock/Item Group/Default/Default.txt
new file mode 100644
index 0000000..c0b6207
--- /dev/null
+++ b/stock/Item Group/Default/Default.txt
@@ -0,0 +1 @@
+[{'creation': '2010-07-05 16:08:14', 'doctype': 'Item Group', 'lft': 76, 'owner': 'nabin@webnotestech.com', 'rgt': 77, 'company_abbr': None, 'docstatus': 0, 'item_group_name': 'Default', 'description': None, 'parent': None, 'is_group': 'No', 'company': None, 'show_in_catalogue': None, 'group_or_ledger': None, 'modified_by': 'nabin@webnotestech.com', 'group_name': None, 'trash_reason': None, 'name': 'Default', 'idx': None, 'modified': '2010-07-05 16:08:14', 'parent_item_group': 'All Item Groups', 'old_parent': '', 'parenttype': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/Module Def/Stock/Stock.txt b/stock/Module Def/Stock/Stock.txt
new file mode 100644
index 0000000..eae0a2e
--- /dev/null
+++ b/stock/Module Def/Stock/Stock.txt
@@ -0,0 +1,421 @@
+[
+	{
+		'_last_update': None,
+		'creation': '2011-06-30 15:49:38',
+		'disabled': 'No',
+		'docstatus': 0,
+		'doctype': u'Module Def',
+		'doctype_list': 'DocType Label, QA Inspection Report',
+		'file_list': None,
+		'idx': None,
+		'is_hidden': 'No',
+		'last_updated_date': None,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'module_desc': 'Material Management',
+		'module_icon': 'Stock.gif',
+		'module_label': 'Stock',
+		'module_name': 'Stock',
+		'module_page': None,
+		'module_seq': 7,
+		'name': 'Stock',
+		'owner': 'Administrator',
+		'parent': None,
+		'parentfield': None,
+		'parenttype': None,
+		'trash_reason': None,
+		'widget_code': None
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Item master',
+		'display_name': 'Item',
+		'doc_name': 'Item',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'name\nitem_group\ndescription',
+		'hide': None,
+		'icon': None,
+		'idx': 1,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01321',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Record of items added, removed or moved from one warehouse to another.',
+		'display_name': 'Stock Entry',
+		'doc_name': 'Stock Entry',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'transfer_date\npurpose\nfrom_warehouse\nto_warehouse\nremarks',
+		'hide': None,
+		'icon': None,
+		'idx': 2,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01322',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Record of items delivered to your customers along with the Printed Note',
+		'display_name': 'Delivery Note',
+		'doc_name': 'Delivery Note',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'status\ntransaction_date\ncustomer\nterritory\ngrand_total\nper_billed',
+		'hide': None,
+		'icon': None,
+		'idx': 3,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01323',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Record of incoming material from your suppliers',
+		'display_name': 'Purchase Receipt',
+		'doc_name': 'Purchase Receipt',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'status\ntransaction_date\nsupplier\ngrand_total\nper_billed',
+		'hide': None,
+		'icon': None,
+		'idx': 4,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01324',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Details of Installation done after delivery',
+		'display_name': 'Installation Note',
+		'doc_name': 'Installation Note',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 5,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01325',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Create Quality Inspection Report for any item',
+		'display_name': 'Inspection Report',
+		'doc_name': 'QA Inspection Report',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'inspection_type\nitem_code\nreport_date\npurchase_receipt_no\ndelivery_note_no',
+		'hide': None,
+		'icon': None,
+		'idx': 6,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01326',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Reconcile your stock by uploading it form an excel file',
+		'display_name': 'Stock Reconciliation',
+		'doc_name': 'Stock Reconciliation',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': 'reconciliation_date\nreconciliation_time\nremark',
+		'hide': None,
+		'icon': None,
+		'idx': 7,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01327',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'This utility tool will update Stock UOM in Item and will respectively update Actual Qty in Stock Ledger as per Conversion Factor.',
+		'display_name': 'Stock UOM Replace Utility',
+		'doc_name': 'Stock UOM Replace Utility',
+		'doc_type': 'Single DocType',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 8,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01328',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'This utility will help in tracking stock for Sales Return and Purchase Return.',
+		'display_name': 'Sales and Purchase Return Wizard',
+		'doc_name': 'Sales and Purchase Return Wizard',
+		'doc_type': 'Single DocType',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 9,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01329',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 18:57:58',
+		'description': 'You can create master template for landed cost wizard',
+		'display_name': 'Landed Cost Master',
+		'doc_name': 'Landed Cost Master',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'accept.gif',
+		'idx': 10,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01372',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 18:57:58',
+		'description': 'Add extra expenses into Purchase Receipt which should be consider for item valuation. The cost will be added proportionately as per purchase receipt value.',
+		'display_name': 'Landed Cost Wizard',
+		'doc_name': 'Landed Cost Wizard',
+		'doc_type': 'Forms',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': 'accept.gif',
+		'idx': 11,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01371',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': None,
+		'display_name': 'Stock Ledger',
+		'doc_name': 'Stock Ledger Entry',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 12,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01330',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': None,
+		'display_name': 'Stock Level',
+		'doc_name': 'Bin',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 13,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01331',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': None,
+		'display_name': 'Shortage To Indent',
+		'doc_name': 'Item',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 14,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01332',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': 'Stock Value as per Item and Warehouse',
+		'display_name': 'Stock Report',
+		'doc_name': 'Stock Ledger Entry',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 15,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01333',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'click_function': None,
+		'creation': '2011-06-30 15:49:38',
+		'description': None,
+		'display_name': 'Stock Aging Report',
+		'doc_name': 'Serial No',
+		'doc_type': 'Reports',
+		'docstatus': 0,
+		'doctype': 'Module Def Item',
+		'fields': None,
+		'hide': None,
+		'icon': None,
+		'idx': 16,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDI01334',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+	{
+		'creation': '2011-06-30 15:49:38',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 1,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDR00336',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Material User'
+	},
+	{
+		'creation': '2011-06-30 15:49:38',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 2,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDR00337',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Material Master Manager'
+	},
+	{
+		'creation': '2011-06-30 15:49:38',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 3,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDR00338',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Material Manager'
+	},
+	{
+		'creation': '2011-06-30 15:49:38',
+		'docstatus': 0,
+		'doctype': 'Module Def Role',
+		'idx': 4,
+		'modified': '2011-07-01 09:36:22',
+		'modified_by': 'Administrator',
+		'name': 'MDR00339',
+		'owner': 'Administrator',
+		'parent': 'Stock',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def',
+		'role': 'Quality Manager'
+	}
+]
\ No newline at end of file
diff --git a/stock/Print Format/Purchase Receipt Format/Purchase Receipt Format.txt b/stock/Print Format/Purchase Receipt Format/Purchase Receipt Format.txt
new file mode 100644
index 0000000..3314962
--- /dev/null
+++ b/stock/Print Format/Purchase Receipt Format/Purchase Receipt Format.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'Purchase Receipt Format', 'parent': None, 'creation': '2009-03-12 12:10:22', 'modified': '2009-09-07 11:03:11', 'module': 'Material Management', 'doctype': 'Print Format', 'idx': None, 'parenttype': None, 'html': '<html>\n<head>\n<!--Other charges function-->\n<script>\n    var make_row = function(title,val,bold){\n    var bstart = \'<b>\'; var bend = \'</b>\';\n    return \'<tr><td style="width:50%">\'+(bold?bstart:\'\')+title+(bold?bend:\'\')+\'</td>\'\n              +\'<td style="width:20%;text-align:right">\'+doc.currency+\'</td>\'\n              +\'<td style="width:30%;text-align:right">\'+(val?val:\'0.00\')+\'</td>\'\n              +\'</tr>\'\n  }\n\n  function get_other_charges(){\n    var out =\'\';\n    out += \'<div><table class="noborder" style="width:100%">\';\n    out += make_row(\'Total Amount\',fmt_money(convert_rate(doc.total_amount)),1)\n          +make_row(\'Grand Total\',fmt_money(convert_rate(doc.grand_total)),1);\n    out += \'</table></div>\';\n    return out;\n  }\n\n  function get_buying_costs(){\n    var out =\'\';\n    if(doc.buying_cost_transport || doc.buying_cost_taxes || doc.buying_cost_other){\n      out += \'<div><table class="noborder" style="width:100%">\'\n            + \'<tr><td style="width:100%"><b>\'+\'Buying Cost Details\'+\'</b></td></tr>\';\n      if(doc.buying_cost_transport){ out += make_row(\'Transport Cost\',fmt_money(convert_rate(doc.buying_cost_transport)),0)}\n      if(doc.buying_cost_taxes){ out += make_row(\'Taxes\',fmt_money(convert_rate(doc.buying_cost_taxes)),0)}\n      if(doc.buying_cost_other){ out += make_row(\'Other Cost\',fmt_money(convert_rate(doc.buying_cost_other)),0)}\n      out += \'</table></div>\';\n    }\n    return out;\n  }\n\n  function get_letter_head(){\n    var cp = locals[\'Control Panel\'][\'Control Panel\'];\n  \tif(cp.letter_head) {return cp.letter_head; }\n  }\n  \n  function convert_rate(val){\n    var new_val = flt(val)/flt(doc.conversion_rate);\n    return new_val;\n  }\n  \n    function get_transport_details(){\n    var out = \'\';\n    if(doc.transporter_name || doc.lr_no || doc.lr_date){\n     out += \'<div><table class="noborder" style="width:40%">\'\n            +\'<tr><td style="width:80%"><b>\' + \'Transporter Details\'+\'</b></td><td style="width:20%"></td></tr>\'\n\n     if(doc.transporter_name){ out += \'<tr><td style="width:40%">\' + \'Transporter Name\'+\'</td><td style="width:60%">\'+doc.transporter_name+\'</td></tr>\'}\n     if(doc.lr_no){ out += \'<tr><td style="width:40%">\' + \'LR No\'+\'</td><td style="width:60%">\'+doc.lr_no+\'</td></tr>\'}\n     if(doc.lr_date){ out += \'<tr><td style="width:40%">\' + \'LR Date\'+\'</td><td style="width:60%">\'+doc.lr_date+\'</td></tr>\'}\n     out += \'</table></div>\'\n    }\n    return out;\n  }\n\n</script>\n</head>\n<body>\n<div style="border:1px solid black;padding:15px">\n<!--header-->\n<div><script>get_letter_head()</script></div>\n<div style="border-bottom: 1px solid; padding-bottom: 5px;">\n <div><br><b>Purchase Receipt: <script>doc.name</script></b></div>\n <div>Date: <script>date.str_to_user(doc.transaction_date)</script></div>\n</div>\n\n<div style="padding-top:15px">\n<div><script>doc.supplier</script></div>\n<div><br><script>replace_newlines(doc.supplier_address)</script></div>\n</div>\n\n<div>\n<br>\n    <script>\n    var t = print_table(\'Purchase Receipt\', doc.name, \'purchase_receipt_details\', \'Purchase Receipt Detail\', [\'SR\', \'item_code\',\'description\',\'received_qty\',\'qty\',\'rejected_qty\',\'po_rate\',\'amount\',\'billed_qty\'], [\'Sr\', \'Item Code\', \'Description\',\'Received Quantity\',\'Accepted Qty\',\'Rejected Qty\',\'Rate\',\'Amount\',\'Billed Qty\'], [\'4%\',\'12%\', \'24%\', \'10%\',\'10%\',\'10%\',\'10%\',\'10%\',\'10%\'])\n    if(t.appendChild) {\n      // single\n      out = t.innerHTML;\n    } \n    else {//multiple\n      out = \'\'\n      for(var i=0;i<t.length;i++) {\n        if(i!=t.length-1){\n          out += \'<div style:"padding-top:5px;"></div>\' + t[i].innerHTML +\'<div style="page-break-after:always"></div>\';\n        }\n        else out += \'<div style:"padding-top:5px;"></div>\' + t[i].innerHTML;\n      }\n    }\n    out;\n    </script>\n\n</div>\n\n<!--Other charges table-->\n<div>\n<table style="width:100%">\n  <tr><td style="width:40%"><script>get_buying_costs()</script></td>\n  <td style="width:20%"></td><td style="width:40%"><script>get_other_charges()</script></td></tr>\n</table>\n</div>\n<div><script>get_transport_details()</script></div>\n<div><br>Payment Terms</div>\n<div><br><script>replace_newlines(doc.payment_terms)</script></div>\n<div><br>For NCSCI</div>\n<div><br><br>(Authorised Signatory)</div>\n</div></body>\n</html>', 'owner': 'Administrator', 'docstatus': 0, 'standard': 'Yes', 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/Role/Material Manager/Material Manager.txt b/stock/Role/Material Manager/Material Manager.txt
new file mode 100644
index 0000000..9e3ba18
--- /dev/null
+++ b/stock/Role/Material Manager/Material Manager.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'Material Manager', 'parent': None, 'creation': '2009-03-12 12:09:44', 'modified': '2009-03-19 14:56:51', 'module': 'Roles', 'doctype': 'Role', 'idx': None, 'parenttype': None, 'role_name': 'Material Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/Role/Material Master Manager/Material Master Manager.txt b/stock/Role/Material Master Manager/Material Master Manager.txt
new file mode 100644
index 0000000..5f4666d
--- /dev/null
+++ b/stock/Role/Material Master Manager/Material Master Manager.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'Material Master Manager', 'parent': None, 'creation': '2010-04-08 13:49:58', 'modified': '2010-04-08 13:49:58', 'module': 'Roles', 'doctype': 'Role', 'idx': None, 'parenttype': None, 'role_name': 'Material Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/Role/Material User/Material User.txt b/stock/Role/Material User/Material User.txt
new file mode 100644
index 0000000..320e280
--- /dev/null
+++ b/stock/Role/Material User/Material User.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'Material User', 'parent': None, 'creation': '2010-04-08 12:08:13', 'modified': '2010-04-08 12:08:13', 'module': 'Roles', 'doctype': 'Role', 'idx': None, 'parenttype': None, 'role_name': 'Material User', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/Role/Quality Manager/Quality Manager.txt b/stock/Role/Quality Manager/Quality Manager.txt
new file mode 100644
index 0000000..aacf400
--- /dev/null
+++ b/stock/Role/Quality Manager/Quality Manager.txt
@@ -0,0 +1 @@
+[{'modified_by': 'Administrator', 'name': 'Quality Manager', 'parent': None, 'creation': '2010-05-04 13:12:27', 'modified': '2010-05-04 13:12:27', 'module': 'Roles', 'doctype': 'Role', 'idx': None, 'parenttype': None, 'role_name': 'Quality Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}]
\ No newline at end of file
diff --git a/stock/__init__.py b/stock/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/__init__.py
diff --git a/stock/doctype/__init__.py b/stock/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/__init__.py
diff --git a/stock/doctype/batch/__init__.py b/stock/doctype/batch/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/batch/__init__.py
diff --git a/stock/doctype/batch/batch.txt b/stock/doctype/batch/batch.txt
new file mode 100644
index 0000000..f589b12
--- /dev/null
+++ b/stock/doctype/batch/batch.txt
@@ -0,0 +1,158 @@
+# DocType, Batch
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:08:52',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'Administrator',
+		'owner': 'harshada@webnotestech.com'
+	},
+
+	# These values are common for all DocType
+	{
+		'allow_trash': 1,
+		'autoname': 'field:batch_id',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'version': 12
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Batch',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Batch',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1,
+		'role': 'Material Master Manager'
+	},
+
+	# DocType, Batch
+	{
+		'doctype': 'DocType',
+		'name': 'Batch'
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'idx': 1,
+		'label': 'Trash Reason',
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'batch_id',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'label': 'Batch ID',
+		'no_copy': 1,
+		'oldfieldname': 'batch_id',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Small Text',
+		'idx': 3,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 0,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'start_date',
+		'fieldtype': 'Date',
+		'idx': 4,
+		'label': 'Batch Started Date',
+		'oldfieldname': 'start_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'finished_date',
+		'fieldtype': 'Date',
+		'idx': 5,
+		'label': 'Batch Finished Date',
+		'oldfieldname': 'finished_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'expiry_date',
+		'fieldtype': 'Date',
+		'idx': 6,
+		'label': 'Expiry Date',
+		'oldfieldname': 'expiry_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item',
+		'fieldtype': 'Link',
+		'idx': 7,
+		'label': 'Item',
+		'oldfieldname': 'item',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 0,
+		'reqd': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/bin/__init__.py b/stock/doctype/bin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/bin/__init__.py
diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py
new file mode 100644
index 0000000..1a1eb70
--- /dev/null
+++ b/stock/doctype/bin/bin.py
@@ -0,0 +1,283 @@
+# 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
+
+	# -------------
+	# stock update
+	# -------------
+	def update_stock(self, actual_qty=0, reserved_qty=0, ordered_qty=0, indented_qty=0, planned_qty=0, dt=None, sle_id='', posting_time='', serial_no = '', is_cancelled = 'No'):
+
+		if not dt: dt = nowdate()
+		# update the stock values (for current quantities)
+		self.doc.actual_qty = flt(self.doc.actual_qty) + flt(actual_qty)
+		self.doc.ordered_qty = flt(self.doc.ordered_qty) + flt(ordered_qty)
+		self.doc.reserved_qty = flt(self.doc.reserved_qty) + flt(reserved_qty)
+		self.doc.indented_qty = flt(self.doc.indented_qty) + flt(indented_qty)
+		self.doc.planned_qty = flt(self.doc.planned_qty) + flt(planned_qty)
+		self.doc.projected_qty = flt(self.doc.actual_qty) + flt(self.doc.ordered_qty) + flt(self.doc.indented_qty) + flt(self.doc.planned_qty) - flt(self.doc.reserved_qty)
+
+		self.doc.save()
+
+		# update valuation for post dated entry
+		if actual_qty:
+			prev_sle = self.get_prev_sle(dt, posting_time, sle_id)
+			cqty = flt(prev_sle.get('bin_aqat', 0))
+			# Block if actual qty becomes negative
+			if (flt(cqty) + flt(actual_qty)) < 0 and flt(actual_qty) < 0 and is_cancelled == 'No':
+				msgprint('Not enough quantity (requested: %s, current: %s) for Item <b>%s</b> in Warehouse <b>%s</b> as on %s %s' % (flt(actual_qty), flt(cqty), self.doc.item_code, self.doc.warehouse, dt, posting_time), raise_exception = 1)
+
+			self.update_item_valuation(sle_id, dt, posting_time, serial_no, prev_sle)
+
+	# --------------------------------
+	# get first stock ledger entry
+	# --------------------------------
+	
+	def get_first_sle(self):
+		sle = sql("""
+			select * from `tabStock Ledger Entry`
+			where item_code = %s
+			and warehouse = %s
+			and ifnull(is_cancelled, 'No') = 'No'
+			order by timestamp(posting_date, posting_time) asc, name asc
+			limit 1
+		""", (self.doc.item_code, self.doc.warehouse), as_dict=1)
+		return sle and sle[0] or None
+
+	# --------------------------------
+	# get previous stock ledger entry
+	# --------------------------------
+			
+	def get_prev_sle(self, posting_date, posting_time, sle_id = ''):
+		# this function will only be called for a live entry
+		# for which the "name" will be the latest (even for the same timestamp)
+		# and even for a back-dated entry
+		# hence there cannot be any "backdated entries" with a name greater than the
+		# current one
+		
+		# if there are multiple entries on this timestamp, then the last one will be with
+		# the last "name"		
+		# else, the last entry will be the highest name at the previous timestamp
+		# hence, the double sort on timestamp and name should be sufficient condition
+		# to get the last sle
+
+		sle = sql("""
+			select * from `tabStock Ledger Entry`
+			where item_code = %s
+			and warehouse = %s
+			and name != %s
+			and ifnull(is_cancelled, 'No') = 'No'
+			and timestamp(posting_date, posting_time) <= timestamp(%s, %s)
+			order by timestamp(posting_date, posting_time) desc, name desc
+			limit 1
+		""", (self.doc.item_code, self.doc.warehouse, sle_id, posting_date, posting_time), as_dict=1)
+
+		return sle and sle[0] or {}
+
+
+
+
+	# --------------------------------------------------------------------------------------------------------------------------------------
+	# validate negative stock (validate if stock is going -ve in between for back dated entries will consider only is_cancel = 'No' entries)
+	# --------------------------------------------------------------------------------------------------------------------------------------
+	def validate_negative_stock(self, cqty, s):
+		if cqty + s['actual_qty'] < 0 and s['is_cancelled'] != 'Yes':
+			msgprint(cqty)
+			msgprint(s['actual_qty'])
+			msgprint('Cannot complete this transaction because stock will become negative in future transaction for Item <b>%s</b> in Warehouse <b>%s</b> on <b>%s %s</b>' % \
+				(self.doc.item_code, self.doc.warehouse, s['posting_date'], s['posting_time']))
+			raise Exception
+
+	# ------------------------------------
+	# get serialized inventory values
+	# ------------------------------------
+	def get_serialized_inventory_values(self, val_rate, in_rate, opening_qty, actual_qty, is_cancelled, serial_nos):
+		if flt(in_rate) < 0: # wrong incoming rate
+			in_rate = val_rate
+		elif flt(in_rate) == 0: # In case of delivery/stock issue, get average purchase rate of serial nos of current entry
+			in_rate = flt(sql("select ifnull(avg(purchase_rate), 0) from `tabSerial No` where name in (%s)" % (serial_nos))[0][0])
+
+		if in_rate and val_rate == 0: # First entry
+			val_rate = in_rate		
+		# val_rate is same as previous entry if val_rate is negative
+		# Otherwise it will be calculated as per moving average
+		elif opening_qty + actual_qty > 0 and ((opening_qty * val_rate) + (actual_qty * in_rate)) > 0:
+			val_rate = ((opening_qty *val_rate) + (actual_qty * in_rate)) / (opening_qty + actual_qty)
+		stock_val = val_rate
+		return val_rate, stock_val
+
+
+
+	# ------------------------------------
+	# get moving average inventory values
+	# ------------------------------------
+	def get_moving_average_inventory_values(self, val_rate, in_rate, opening_qty, actual_qty, is_cancelled):
+		if flt(in_rate) <= 0: # In case of delivery/stock issue in_rate = 0 or wrong incoming rate
+			in_rate = val_rate
+		if in_rate and val_rate == 0: # First entry
+			val_rate = in_rate
+
+		# val_rate is same as previous entry if :
+		# 1. actual qty is negative(delivery note / stock entry)
+		# 2. cancelled entry
+		# 3. val_rate is negative
+		# Otherwise it will be calculated as per moving average
+		elif actual_qty > 0 and (opening_qty + actual_qty) > 0 and is_cancelled == 'No' and ((opening_qty * val_rate) + (actual_qty * in_rate)) > 0:
+			val_rate = ((opening_qty *val_rate) + (actual_qty * in_rate)) / (opening_qty + actual_qty)
+		stock_val = val_rate
+		return val_rate, stock_val
+
+
+	# --------------------------
+	# get fifo inventory values
+	# --------------------------
+	def get_fifo_inventory_values(self, in_rate, actual_qty):
+		# add batch to fcfs balance
+		if actual_qty > 0:
+			self.fcfs_bal.append([flt(actual_qty), flt(in_rate)])
+
+		# remove from fcfs balance
+		else:
+			withdraw = flt(abs(actual_qty))
+			while withdraw:
+				if not self.fcfs_bal:
+					break # nothing in store
+				
+				batch = self.fcfs_bal[0]
+			 
+				if batch[0] <= withdraw:
+					# not enough or exactly same qty in current batch, clear batch
+					withdraw -= batch[0]
+					self.fcfs_bal.pop(0)
+				else:
+					# all from current batch
+					batch[0] -= withdraw
+					withdraw = 0
+
+		fcfs_val = sum([flt(d[0])*flt(d[1]) for d in self.fcfs_bal])
+		fcfs_qty = sum([flt(d[0]) for d in self.fcfs_bal])
+		val_rate = fcfs_qty and fcfs_val / fcfs_qty or 0
+		
+		return val_rate
+
+	# -------------------
+	# get valuation rate
+	# -------------------
+	def get_valuation_rate(self, val_method, serial_nos, val_rate, in_rate, stock_val, cqty, s):
+		if serial_nos:
+			val_rate, stock_val = self.get_serialized_inventory_values(val_rate, in_rate, opening_qty = cqty, actual_qty = s['actual_qty'], is_cancelled = s['is_cancelled'], serial_nos = serial_nos)
+		elif val_method == 'Moving Average':
+			val_rate, stock_val = self.get_moving_average_inventory_values(val_rate, in_rate, opening_qty = cqty, actual_qty = s['actual_qty'], is_cancelled = s['is_cancelled'])
+		elif val_method == 'FIFO':
+			val_rate = self.get_fifo_inventory_values(in_rate, actual_qty = s['actual_qty'])
+		return val_rate, stock_val
+
+
+	# ----------------
+	# get stock value
+	# ----------------
+	def get_stock_value(self, val_method, cqty, stock_val, serial_nos):
+		if val_method == 'Moving Average' or serial_nos:
+			stock_val = flt(stock_val) * flt(cqty)
+		elif val_method == 'FIFO':
+			stock_val = sum([flt(d[0])*flt(d[1]) for d in self.fcfs_bal])
+		return stock_val
+
+	# ----------------------
+	# update item valuation
+	# ----------------------
+	def update_item_valuation(self, sle_id=None, posting_date=None, posting_time=None, serial_no=None, prev_sle=None):
+		# no sle given, start from the first one (for repost)
+		if not prev_sle:
+			cqty, cval, val_rate, self.fcfs_bal = 0, 0, 0, []
+		
+		# normal
+		else:
+			cqty = flt(prev_sle.get('bin_aqat', 0))
+			cval =flt(prev_sle.get('stock_value', 0))
+			val_rate = flt(prev_sle.get('valuation_rate', 0))
+			self.fcfs_bal = eval(prev_sle.get('fcfs_stack', '[]') or '[]')
+
+		val_method = get_obj('Valuation Control').get_valuation_method(self.doc.item_code)	# get valuation method
+
+		# recalculate the balances for all stock ledger entries
+		# after this one (so that the corrected balance will reflect
+		# correctly in all entries after this one)
+		sll = sql("""
+			select *
+			from `tabStock Ledger Entry` 
+			where item_code = %s 
+			and warehouse = %s 
+			and ifnull(is_cancelled, 'No') = 'No'
+			and timestamp(posting_date, posting_time) > timestamp(%s, %s)
+			order by timestamp(posting_date, posting_time) asc, name asc""", \
+				(self.doc.item_code, self.doc.warehouse, posting_date, posting_time), as_dict = 1)
+
+		# if in live entry - update the values of the current sle
+		if sle_id:
+			sll = sql("select * from `tabStock Ledger Entry` where name=%s and ifnull(is_cancelled, 'No') = 'No'", sle_id, as_dict=1) + sll
+		for s in sll:
+			# block if stock level goes negative on any date
+			self.validate_negative_stock(cqty, s)
+
+			stock_val, in_rate = 0, s['incoming_rate'] # IN
+			serial_nos = s["serial_no"] and ("'"+"', '".join(cstr(s["serial_no"]).split('\n')) + "'") or ''
+
+			# Get valuation rate
+			val_rate, stock_val = self.get_valuation_rate(val_method, serial_nos, val_rate, in_rate, stock_val, cqty, s) 
+			
+			# Qty upto the sle
+			cqty += s['actual_qty'] 
+
+			# Stock Value upto the sle
+			stock_val = self.get_stock_value(val_method, cqty, stock_val, serial_nos) 
+			# update current sle --> will it be good to update incoming rate in sle for outgoing stock entry?????
+			sql("""update `tabStock Ledger Entry` 
+			set bin_aqat=%s, valuation_rate=%s, fcfs_stack=%s, stock_value=%s 
+			where name=%s""", (cqty, flt(val_rate), cstr(self.fcfs_bal), stock_val, s['name']))
+		
+		# update the bin
+		if sll:
+			sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s where name=%s", \
+				(flt(val_rate), cqty, flt(stock_val), self.doc.name))
+
+
+	# item re-order
+	# -------------
+	def reorder_item(self):
+		#check if re-order is required
+		projected_qty = flt(self.doc.actual_qty) + flt(self.doc.indented_qty) + flt(self.doc.ordered_qty)
+		item_reorder_level = sql("select reorder_level from `%sItem` where name = '%s'" % (self.prefix, self.doc.item_code))[0][0] or 0
+		if flt(item_reorder_level) > flt(projected_qty):
+			msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent raised (Not Implemented).")
+	
+	# validate
+	def validate(self):
+		self.validate_mandatory()
+
+	
+	# set defaults in bin
+	def validate_mandatory(self):
+		qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty']
+		for f in qf:
+			if (not self.doc.fields.has_key(f)) or (not self.doc.fields[f]): 
+				self.doc.fields[f] = 0.0
diff --git a/stock/doctype/bin/bin.txt b/stock/doctype/bin/bin.txt
new file mode 100644
index 0000000..2ecbcf0
--- /dev/null
+++ b/stock/doctype/bin/bin.txt
@@ -0,0 +1,299 @@
+# DocType, Bin
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:08:52',
+		'docstatus': 0,
+		'modified': '2010-12-16 23:57:05',
+		'modified_by': 'nabin@webnotestech.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1308741898',
+		'autoname': 'BIN/.#######',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'hide_toolbar': 1,
+		'in_create': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'read_only': 0,
+		'search_fields': 'item_code,warehouse',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 114
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Bin',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 1
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Bin',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Bin
+	{
+		'doctype': 'DocType',
+		'name': 'Bin'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 1,
+		'role': 'Sales Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'Sales User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Purchase Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 1,
+		'role': 'Purchase User'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Warehouse',
+		'oldfieldname': 'warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse_type',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'label': 'Warehouse Type',
+		'oldfieldname': 'warehouse_type',
+		'oldfieldtype': 'Data'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'reserved_qty',
+		'fieldtype': 'Currency',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Reserved Quantity',
+		'oldfieldname': 'reserved_qty',
+		'oldfieldtype': 'Currency',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'actual_qty',
+		'fieldtype': 'Currency',
+		'idx': 6,
+		'in_filter': 1,
+		'label': 'Actual Quantity',
+		'oldfieldname': 'actual_qty',
+		'oldfieldtype': 'Currency',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'ordered_qty',
+		'fieldtype': 'Currency',
+		'idx': 7,
+		'in_filter': 1,
+		'label': 'Ordered Quantity',
+		'oldfieldname': 'ordered_qty',
+		'oldfieldtype': 'Currency',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'indented_qty',
+		'fieldtype': 'Currency',
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Indented Quantity',
+		'oldfieldname': 'indented_qty',
+		'oldfieldtype': 'Currency',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'planned_qty',
+		'fieldtype': 'Currency',
+		'idx': 9,
+		'in_filter': 1,
+		'label': 'Planned Qty',
+		'oldfieldname': 'planned_qty',
+		'oldfieldtype': 'Currency',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'projected_qty',
+		'fieldtype': 'Currency',
+		'idx': 10,
+		'in_filter': 1,
+		'label': 'Projected Qty',
+		'oldfieldname': 'projected_qty',
+		'oldfieldtype': 'Currency'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'ma_rate',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 11,
+		'in_filter': 0,
+		'label': 'Moving Average Rate',
+		'oldfieldname': 'ma_rate',
+		'oldfieldtype': 'Currency',
+		'print_hide': 1,
+		'report_hide': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Data',
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'UOM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Data',
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fcfs_rate',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 12,
+		'label': 'FCFS Rate',
+		'oldfieldname': 'fcfs_rate',
+		'oldfieldtype': 'Currency',
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'valuation_rate',
+		'fieldtype': 'Currency',
+		'idx': 13,
+		'label': 'Valuation Rate',
+		'oldfieldname': 'valuation_rate',
+		'oldfieldtype': 'Currency'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_value',
+		'fieldtype': 'Currency',
+		'idx': 14,
+		'label': 'Stock Value',
+		'oldfieldname': 'stock_value',
+		'oldfieldtype': 'Currency'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/__init__.py b/stock/doctype/delivery_note/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/delivery_note/__init__.py
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
new file mode 100644
index 0000000..823eca4
--- /dev/null
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -0,0 +1,351 @@
+// Module Material Management
+cur_frm.cscript.tname = "Delivery Note Detail";
+cur_frm.cscript.fname = "delivery_note_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, dt, dn) {
+  if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
+  if(!doc.transaction_date) set_multiple(dt,dn,{transaction_date:get_today()});
+  if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
+  if(doc.__islocal && doc.customer) cur_frm.cscript.pull_item_details_onload(doc,dt,dn);
+
+  if(!doc.posting_time) doc.posting_time = wn.datetime.get_cur_time()
+    
+  if(doc.__islocal){
+    hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+  }   
+
+}
+
+cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
+  // 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);	
+} 
+
+// REFRESH
+// ================================================================================================
+cur_frm.cscript.refresh = function(doc, cdt, cdn) { 
+
+  cur_frm.clear_custom_buttons();
+ 
+  if(doc.per_billed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
+  
+  if(doc.per_installed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']);
+
+  if (doc.docstatus!=1) {
+    hide_field(['SMS', 'Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
+  } else {
+    cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+    unhide_field(['SMS','Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
+  }
+  
+  set_print_hide(doc, cdt, cdn);
+}
+
+
+//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_shipping_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['Get Items'] = function(doc,dt,dn) {
+  var callback = function(r,rt){
+    var doc = locals[cur_frm.doctype][cur_frm.docname];          
+    if(r.message){              
+      doc.sales_order_no = r.message;      
+		  if(doc.sales_order_no) {		      
+  			  unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);			    			    			  
+		  }		  
+		  refresh_many(['delivery_note_details','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+    }
+  } 
+ $c_obj(make_doclist(doc.doctype, doc.name),'pull_sales_order_details','',callback); 
+}
+
+
+//RV-DN : Pull Item details - UOM, Item Group as it was not in Sales Invoice
+//---------------------------------------------------------------------
+cur_frm.cscript.pull_item_details_onload = function(doc,dt,dn){
+  var callback = function(r,rt){
+    refresh_field('delivery_note_details');
+    cur_frm.cscript.customer(doc,dt,dn);
+  } 
+  $c_obj(make_doclist(dt,dn),'set_item_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);
+}
+
+//========================= Overloaded query for link batch_no =============================================================
+cur_frm.fields_dict['delivery_note_details'].grid.get_field('batch_no').get_query= function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(d.item_code){
+    return "SELECT tabBatch.name, tabBatch.description FROM tabBatch WHERE tabBatch.docstatus != 2 AND tabBatch.item = '"+ d.item_code +"' AND `tabBatch`.`name` like '%s' ORDER BY `tabBatch`.`name` DESC LIMIT 50"
+  }
+  else{
+    alert("Please enter Item Code.");
+  }
+}
+
+// ***************** 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']);
+  });
+}
+*/
+
+
+
+// UTILITY FUNCTIONS
+// ================================================================================================
+/*
+var cfn_set_fields = function(doc, cdt, cdn) { 
+ var supplier_field_list = ['Supplier','supplier','supplier_address'];
+  var customer_field_list = ['Customer','customer','customer_name','customer_address','territory','customer_group','Business Associate','sales_partner','commission_rate','total_commission','sales_order_no','Get Items'];
+  if (doc.delivery_type == 'Rejected' && doc.purchase_receipt_no) {
+    unhide_field('purchase_receipt_no');
+    unhide_field(supplier_field_list);
+    hide_field(customer_field_list);
+    get_field(doc.doctype, 'delivery_type' , doc.name).permlevel = 1;
+  }
+  else if (doc.delivery_type == 'Subcontract' && doc.purchase_order_no) {
+    unhide_field('purchase_order_no');
+    unhide_field(supplier_field_list);
+    hide_field(cutomer_field_list);
+    get_field(doc.doctype, 'delivery_type' , doc.name).permlevel = 1;
+  }
+  else if (doc.delivery_type == 'Sample') unhide_field('to_warehouse');
+  else get_field(doc.doctype, 'delivery_type' , doc.name).permlevel = 0;   
+    
+  
+}
+
+*/
+
+// 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 FROM `tabContact` WHERE ((`tabContact`.is_customer = 1 AND `tabContact`.customer = "'+ doc.customer+'") or (`tabContact`.is_sales_partner = 1 AND `tabContact`.sales_partner = "'+ doc.sales_partner+'")) AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
+}
+*/
+
+/*
+// ***************** 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';
+}
+*/
+
+
+
+// *************** Customized link query for SALES ORDER based on customer and currency***************************** 
+cur_frm.fields_dict['sales_order_no'].get_query = function(doc) {
+  doc = locals[this.doctype][this.docname];
+  var cond = '';
+  
+  if(doc.customer) {
+    if(doc.currency) cond = '`tabSales Order`.customer = "'+doc.customer+'" and `tabSales Order`.currency = "'+doc.currency+'" and';
+    else cond = '`tabSales Order`.customer = "'+doc.customer+'" and';
+  }
+  else {
+    if(doc.currency) cond = '`tabSales Order`.currency = "'+doc.currency+'" and';
+    else cond = '';
+  }
+  if(doc.project_name){
+    cond += '`tabSales Order`.project_name ="'+doc.project_name+'"';
+  }
+  return repl('SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "%(company)s" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_delivered,0) < 100 and %(cond)s `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50', {company:doc.company,cond:cond})
+}
+
+
+// ****************************** DELIVERY TYPE ************************************
+cur_frm.cscript.delivery_type = function(doc, cdt, cdn) {
+  if (doc.delivery_type = 'Sample') cfn_set_fields(doc, cdt, cdn);
+}
+
+cur_frm.cscript.serial_no = function(doc, cdt , cdn) {
+  var d = locals[cdt][cdn];
+  if (d.serial_no) {
+     get_server_fields('get_serial_details',d.serial_no,'delivery_note_details',doc,cdt,cdn,1);
+  }
+}
+
+/* 
+// this won't work in case of Sales Bom item where item.is_stock_item = 'No'
+cur_frm.fields_dict['delivery_note_details'].grid.get_field('warehouse').get_query= function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  return "SELECT `tabBin`.`warehouse`, `tabBin`.`actual_qty` FROM `tabBin` WHERE `tabBin`.`item_code` = '"+ d.item_code +"' AND ifnull(`tabBin`.`actual_qty`,0) > 0 AND `tabBin`.`warehouse` like '%s' ORDER BY `tabBin`.`warehouse` DESC LIMIT 50";
+}
+*/
+
+cur_frm.cscript.warehouse = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if (! d.item_code) {alert("please enter item code first"); return};
+  if (d.warehouse) {
+    arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.warehouse +"'}";
+    get_server_fields('get_actual_qty',arg,'delivery_note_details',doc,cdt,cdn,1);
+  }
+}
+
+
+cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
+  return 'SELECT DISTINCT `tabSupplier`.`name` FROM `tabSupplier` WHERE `tabSupplier`.supplier_type = "transporter" AND `tabSupplier`.docstatus != 2 AND `tabSupplier`.%(key)s LIKE "%s" ORDER BY `tabSupplier`.`name` LIMIT 50';
+}
+
+//-----------------------------------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':"[['Delivery Note','Receivable Voucher'],['Delivery Note Detail','RV Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
+    }, function(r,rt) {
+       loaddoc('Receivable Voucher', n);
+    }
+  );
+}
+
+//-----------------------------------Make Installation Note----------------------------------------------
+cur_frm.cscript['Make Installation Note'] = function() {
+  var doc = cur_frm.doc;
+  if(doc.per_installed < 100){
+    n = createLocal('Installation Note');
+    $c('dt_map', args={
+      'docs':compress_doclist([locals['Installation Note'][n]]),
+      'from_doctype':doc.doctype,
+      'to_doctype':'Installation Note',
+      'from_docname':doc.name,
+      'from_to_list':"[['Delivery Note','Installation Note'],['Delivery Note Detail','Installed Item Details']]"
+      }, function(r,rt) {
+         loaddoc('Installation Note', n);
+      }
+    );
+  }
+  else if(doc.per_installed >= 100)
+    msgprint("Item installation is already completed")
+}
+
+//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';
+}
+
+//------------------------for printing without amount----------
+
+var set_print_hide= function(doc, cdt, cdn){
+  if (doc.print_without_amount) {
+    fields['Delivery Note']['currency'].print_hide = 1;
+    fields['Delivery Note Detail']['export_rate'].print_hide = 1;
+    fields['Delivery Note Detail']['adj_rate'].print_hide = 1;
+    fields['Delivery Note Detail']['ref_rate'].print_hide = 1;
+    fields['Delivery Note Detail']['export_amount'].print_hide = 1;
+  } else {
+    fields['Delivery Note']['currency'].print_hide = 0;
+    fields['Delivery Note Detail']['export_rate'].print_hide = 0;
+    fields['Delivery Note Detail']['adj_rate'].print_hide = 0;
+    fields['Delivery Note Detail']['ref_rate'].print_hide = 0;
+    fields['Delivery Note Detail']['export_amount'].print_hide = 0;
+  }
+}
+
+cur_frm.cscript.print_without_amount = function(doc, cdt, cdn) {
+  set_print_hide(doc, cdt, cdn);
+}
+
+
+//****************** For print sales order no and date*************************
+cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){
+  //function to make row of table
+  
+  var make_row = function(title,val1, val2, bold){
+    var bstart = '<b>'; var bend = '</b>';
+
+    return '<tr><td style="width:39%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+     +'<td style="width:61%;text-align:left;">'+val1+(val2?' ('+dateutil.str_to_user(val2)+')':'')+'</td>'
+     +'</tr>'
+  }
+
+  out ='';
+  
+  var cl = getchildren('Delivery Note Detail',doc.name,'delivery_note_details');
+
+  // outer table  
+  var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';
+  
+  // main table
+  out +='<table class="noborder" style="width:100%">';
+
+  // add rows
+  if(cl.length){
+    prevdoc_list = new Array();
+    for(var i=0;i<cl.length;i++){
+      if(cl[i].prevdoc_doctype == 'Sales Order' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
+        prevdoc_list.push(cl[i].prevdoc_docname);
+        if(prevdoc_list.length ==1)
+          out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
+        else
+          out += make_row('', cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
+      }
+    }
+  }
+
+  out +='</table></td></tr></table></div>';
+
+  return out;
+}
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
new file mode 100644
index 0000000..74e6f8a
--- /dev/null
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -0,0 +1,443 @@
+# 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 = 'Delivery Note Detail'
+    self.fname = 'delivery_note_details'
+    
+    # Notification objects
+    self.notify_obj = get_obj('Notification Control')
+
+  # Autoname
+  # ---------
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+
+    
+# DOCTYPE TRIGGERS FUNCTIONS
+# ==============================================================================
+#************Fiscal Year Validation*****************************
+  def validate_fiscal_year(self):
+    get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
+
+  # ******************* 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):
+    return cstr(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)
+  
+  # *************** Pull Sales Order Details ************************
+  def pull_sales_order_details(self):
+    self.validate_prev_docname()
+    self.doc.clear_table(self.doclist,'other_charges')
+        
+    if self.doc.sales_order_no:        
+      get_obj('DocType Mapper', 'Sales Order-Delivery Note').dt_map('Sales Order', 'Delivery Note', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Delivery Note'],['Sales Order Detail', 'Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]")
+    else:
+      msgprint("Please select Sales Order No. whose details need to be pulled")    
+
+    return cstr(self.doc.sales_order_no)
+
+    
+  
+  #-------------------set item details -uom and item group----------------
+  def set_item_details(self):
+    for d in getlist(self.doclist,'delivery_note_details'):
+      res = sql("select stock_uom, item_group from `tabItem` where name ='%s'"%d.item_code)
+      if not d.stock_uom:    d.stock_uom = res and cstr(res[0][0]) or ''
+      if not d.item_group:   d.item_group = res and cstr(res[0][1]) or ''
+      d.save()
+      
+  # ::::: Validates that Sales Order is not pulled twice :::::::
+  def validate_prev_docname(self):
+    for d in getlist(self.doclist, 'delivery_note_details'): 
+      if self.doc.sales_order_no == d.prevdoc_docname:
+        msgprint(cstr(self.doc.sales_order_no) + " sales order details have already been pulled. ")
+        raise Exception, "Validation Error. "
+  
+  #Set Actual Qty based on item code and warehouse
+  #------------------------------------------------------
+  def set_actual_qty(self):
+    for d in getlist(self.doclist, 'delivery_note_details'):
+      if d.item_code and d.warehouse:
+        actual_qty = sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code, d.warehouse))
+        d.actual_qty = actual_qty and flt(actual_qty[0][0]) or 0
+
+
+  # GET TERMS & CONDITIONS
+  # -------------------------------------
+  def get_tc_details(self):
+    return get_obj('Sales Common').get_tc_details(self)
+  
+  #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-Delivery Note').dt_map('Project', 'Delivery Note', self.doc.project_name, self.doc, self.doclist, "[['Project', 'Delivery Note']]")
+        
+# DELIVERY NOTE 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 Actual Qty of item in warehouse selected *************
+  def get_actual_qty(self,args):
+    args = eval(args)
+    actual_qty = sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
+    ret = {
+       'actual_qty' : actual_qty and flt(actual_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)
+
+    
+  #check in manage account if sales order required or not.
+  # ====================================================================================
+  def so_required(self):
+    res = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'so_required'")
+    if res and res[0][0] == 'Yes':
+       for d in getlist(self.doclist,'delivery_note_details'):
+         if not d.prevdoc_docname:
+           msgprint("Sales Order No. required against item %s"%d.item_code)
+           raise Exception
+       
+
+    
+# VALIDATE
+# ====================================================================================
+  def validate(self):
+    self.so_required()
+    self.validate_fiscal_year()
+    self.validate_proj_cust()
+    sales_com_obj = get_obj(dt = 'Sales Common')
+    sales_com_obj.check_stop_sales_order(self)
+    sales_com_obj.check_active_sales_items(self)
+    sales_com_obj.get_prevdoc_date(self)
+    self.validate_mandatory()
+    #self.validate_prevdoc_details()
+    self.validate_reference_value()
+    self.validate_for_items()
+    sales_com_obj.make_packing_list(self,'delivery_note_details')
+    get_obj('Stock Ledger').validate_serial_no(self, 'packing_details')
+    sales_com_obj.validate_max_discount(self, 'delivery_note_details')             #verify whether rate is not greater than max discount
+    sales_com_obj.get_allocated_sum(self)  # this is to verify that the allocated % of sales persons is 100%    
+    sales_com_obj.check_conversion_rate(self)
+    # ::::::: Get total in Words ::::::::
+    dcc = TransactionBase().get_company_currency(self.doc.company)
+    self.doc.in_words = sales_com_obj.get_total_in_words(dcc, 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 actual qty for each item in selected warehouse :::::::
+    self.update_current_stock()
+    # :::::: set DN status :::::::
+
+    self.doc.status = 'Draft'
+    if not self.doc.billing_status: self.doc.billing_status = 'Not Billed'
+    if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
+    
+ 
+  # ************** 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. "
+
+  #check for does customer belong to same project as entered..
+  #-------------------------------------------------------------------------------------------------
+  def validate_proj_cust(self):
+    if self.doc.project_name and self.doc.customer:
+      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 values with reference document
+  #----------------------------------------
+  def validate_reference_value(self):
+    get_obj('DocType Mapper', 'Sales Order-Delivery Note', with_children = 1).validate_reference_value(self, self.doc.name)
+  
+	  
+  # ******* Validate Previous Document Details ************
+  def validate_prevdoc_details(self):
+    for d in getlist(self.doclist,'delivery_note_details'):
+           
+      prevdoc = d.prevdoc_doctype
+      prevdoc_docname = d.prevdoc_docname
+      
+      if prevdoc_docname and prevdoc:
+        # ::::::::::: Validates Transaction Date of DN and previous doc (i.e. SO , PO, PR) *********
+        trans_date = sql("select transaction_date from `tab%s` where name = '%s'" %(prevdoc,prevdoc_docname))[0][0]
+        if trans_date and getdate(self.doc.transaction_date) < (trans_date):
+          msgprint("Your Voucher Date cannot be before "+cstr(prevdoc)+" Date.")
+          raise Exception
+        # ::::::::: Validates DN and previous doc details ::::::::::::::::::
+        get_name = sql("select name from `tab%s` where name = '%s'" % (prevdoc, prevdoc_docname))
+        name = get_name and get_name[0][0] or ''
+        if name:  #check for incorrect docname
+          if prevdoc == 'Sales Order':
+            dt = sql("select company, docstatus, customer, currency, sales_partner from `tab%s` where name = '%s'" % (prevdoc, name))
+            cust_name = dt and dt[0][2] or ''
+            if cust_name != self.doc.customer:
+              msgprint(cstr(prevdoc) + ": " + cstr(prevdoc_docname) + " customer :" + cstr(cust_name) + " does not match with customer : " + cstr(self.doc.customer) + " of current document.")
+              raise Exception, "Validation Error. "
+            sal_partner = dt and dt[0][4] or ''
+            if sal_partner != self.doc.sales_partner:
+              msgprint(cstr(prevdoc) + ": " + cstr(prevdoc_docname) + " sales partner name :" + cstr(sal_partner) + " does not match with sales partner name : " + cstr(self.doc.sales_partner_name) + " of current document.")
+              raise Exception, "Validation Error. "
+          else:
+            dt = sql("select company, docstatus, supplier, currency from `tab%s` where name = '%s'" % (prevdoc, name))
+            supp_name = dt and dt[0][2] or ''
+            company_name = dt and dt[0][0] or ''
+            docstatus = dt and dt[0][1] or 0
+            currency = dt and dt[0][3] or ''
+            if (currency != self.doc.currency):
+              msgprint(cstr(prevdoc) + ": " + cstr(prevdoc_docname) + " currency : "+ cstr(currency) + "does not match with Currency: " + cstr(self.doc.currency) + "of current document")
+              raise Exception, "Validation Error."
+            if (company_name != self.doc.company):
+              msgprint(cstr(prevdoc) + ": " + cstr(prevdoc_docname) + " does not belong to the Company: " + cstr(self.doc.company_name))
+              raise Exception, "Validation Error."
+            if (docstatus != 1):
+              msgprint(cstr(prevdoc) + ": " + cstr(prevdoc_docname) + " is not Submitted Document.")
+              raise Exception, "Validation Error."
+        else:
+          msgprint(cstr(prevdoc) + ": " + cstr(prevdoc_docname) + " is not a valid " + cstr(prevdoc))
+          raise Exception, "Validation Error."
+
+
+  # ******************** Validate Items **************************
+  def validate_for_items(self):
+    check_list, chk_dupl_itm = [], []
+    for d in getlist(self.doclist,'delivery_note_details'):
+      ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
+      if d.prevdoc_doctype and d.prevdoc_detail_docname and ch and ch[0][0]=='Yes':
+        self.validate_items_with_prevdoc(d)
+      
+      # validates whether item is not entered twice
+      e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or '', d.batch_no or '']
+      f = [d.item_code, d.description, d.prevdoc_docname or '']
+
+      if ch and ch[0][0] == 'Yes':
+        if e in check_list:
+          msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code)
+        else:
+          check_list.append(e)
+      elif ch and ch[0][0] == 'No':
+        if f in chk_dupl_itm:
+          msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code)
+        else:
+          chk_dupl_itm.append(f)
+
+
+  # check if same item, warehouse present in prevdoc
+  # ------------------------------------------------------------------
+  def validate_items_with_prevdoc(self, d):
+    if d.prevdoc_doctype == 'Sales Order':
+      data = sql("select item_code, reserved_warehouse from `tabSales Order Detail` where parent = '%s' and name = '%s'" % (d.prevdoc_docname, d.prevdoc_detail_docname))
+    if d.prevdoc_doctype == 'Purchase Receipt':
+      data = sql("select item_code, rejected_warehouse from `tabPurchase Receipt Detail` where parent = '%s' and name = '%s'" % (d.prevdoc_docname, d.prevdoc_detail_docname))
+    if not data or data[0][0] != d.item_code or data[0][1] != d.warehouse:
+      msgprint("Item: %s / Warehouse: %s is not matching with Sales Order: %s. Sales Order might be modified after fetching data from it. Please delete items and fetch again." % (d.item_code, d.warehouse, d.prevdoc_docname))
+      raise Exception
+
+
+  # ********* UPDATE CURRENT STOCK *****************************
+  def update_current_stock(self):
+    for d in getlist(self.doclist, 'delivery_note_details'):
+      bin = sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
+      d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
+
+    for d in getlist(self.doclist, 'packing_details'):
+      bin = sql("select actual_qty, projected_qty from `tabBin` where item_code =  %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
+      d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
+      d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0  
+      
+
+# ON SUBMIT
+# =================================================================================================
+  def on_submit(self):
+    set(self.doc, 'message', 'Items against your Order #%s have been delivered. Delivery #%s: ' % (self.doc.po_no, self.doc.name))
+    self.check_qty_in_stock()
+    # Check for Approving Authority
+    get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
+    sl_obj = get_obj("Stock Ledger")
+    sl_obj.validate_serial_no_warehouse(self, 'packing_details')
+    sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
+    get_obj("Sales Common").update_prevdoc_detail(1,self)
+    self.update_stock_ledger(update_stock = 1)
+
+    #------------Check Credit Limit---------------------
+    self.credit_limit()
+
+    # set DN status
+    set(self.doc, 'status', 'Submitted')
+
+    # on submit notification
+    self.notify_obj.notify_contact('Delivery Note',self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
+
+   
+  # *********** Checks whether actual quantity is present in warehouse *************
+  def check_qty_in_stock(self):
+    for d in getlist(self.doclist, 'packing_details'):
+      is_stock_item = sql("select is_stock_item from `tabItem` where name = '%s'" % d.item_code)[0][0]
+      if is_stock_item == 'Yes' and d.warehouse and flt(d.qty) > flt(d.actual_qty):
+        msgprint("For Item: " + cstr(d.item_code) + " at Warehouse: " + cstr(d.warehouse) + " Quantity: " + cstr(d.qty) +" is not Available. (Must be less than or equal to " + cstr(d.actual_qty) + " )")
+        raise Exception, "Validation Error"
+
+
+
+# ON CANCEL
+# =================================================================================================  
+  def on_cancel(self):
+    sales_com_obj = get_obj(dt = 'Sales Common')
+    sales_com_obj.check_stop_sales_order(self)
+    self.check_next_docstatus()
+    get_obj('Stock Ledger').update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
+    sales_com_obj.update_prevdoc_detail(0,self)
+    self.update_stock_ledger(update_stock = -1)
+    # :::::: set DN status :::::::
+    set(self.doc, 'status', 'Cancelled')
+
+  
+  # ******************** Check Next DocStatus **************************
+  def check_next_docstatus(self):
+    submit_rv = sql("select t1.name from `tabReceivable Voucher` t1,`tabRV Detail` t2 where t1.name = t2.parent and t2.delivery_note = '%s' and t1.docstatus = 1" % (self.doc.name))
+    if submit_rv:
+      msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted !")
+      raise Exception , "Validation Error."
+    
+    submit_in = sql("select t1.name from `tabInstallation Note` t1, `tabInstalled Item Details` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name))
+    if submit_in:
+      msgprint("Installation Note : "+cstr(submit_in[0][0]) +" has already been submitted !")
+      raise Exception , "Validation Error."
+
+
+# UPDATE STOCK LEDGER
+# =================================================================================================
+  def update_stock_ledger(self, update_stock, is_stopped = 0):
+    self.values = []
+    for d in self.get_item_list(is_stopped):
+      stock_item = sql("SELECT is_stock_item, is_sample_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[0]['is_stock_item'] == "Yes":
+        if not d[0]:
+          msgprint("Message: Please enter Warehouse for item %s as it is stock item."% d[1])
+          raise Exception
+        # if prevdoc_doctype = "Sales Order" 
+        if d[3] < 0 :
+          # Reduce Reserved Qty from warehouse
+          bin = get_obj('Warehouse', d[0]).update_bin(0, flt(update_stock) * flt(d[3]), 0, 0, 0, d[1], self.doc.transaction_date)
+          
+        # Reduce actual qty from warehouse
+        self.make_sl_entry(d, d[0], - flt(d[2]) , 0, update_stock)
+    get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
+
+
+  # ***************** Gets Items from packing list *****************
+  def get_item_list(self, is_stopped):
+   return get_obj('Sales Common').get_item_list(self, is_stopped)
+
+	
+  # ********************** Make Stock Entry ************************************
+  def make_sl_entry(self, d, wh, qty, in_value, update_stock):
+    self.values.append({
+      'item_code'           : d[1],
+      'warehouse'           : wh,
+      'transaction_date'    : self.doc.transaction_date,
+      'posting_date'        : self.doc.posting_date,
+      'posting_time'        : self.doc.posting_time,
+      'voucher_type'        : 'Delivery Note',
+      'voucher_no'          : self.doc.name,
+      'voucher_detail_no'   : '', 
+      'actual_qty'          : qty, 
+      'stock_uom'           : d[4],
+      'incoming_rate'       : in_value,
+      'company'             : self.doc.company,
+      'fiscal_year'         : self.doc.fiscal_year,
+      'is_cancelled'        : (update_stock==1) and 'No' or 'Yes',
+      'batch_no'            : d[5],
+      'serial_no'           : d[6]
+    })    
+
+  
+  # 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))
+
+
+#------------ check credit limit of items in DN Detail which are not fetched from sales order----------
+  def credit_limit(self):
+    amount, total = 0, 0
+    for d in getlist(self.doclist, 'delivery_note_details'):
+      if not d.prevdoc_docname:
+        amount += d.amount
+    if amount != 0:
+      total = (amount/self.doc.net_total)*self.doc.grand_total
+      get_obj('Sales Common').check_credit(self, total)
+
+  # on update
+  def on_update(self):
+    self.set_actual_qty()
+    get_obj('Stock Ledger').scrub_serial_nos(self)
+
+  # Repair Delivery Note
+  # ===========================================
+  def repair_delivery_note(self):
+    get_obj('Sales Common', 'Sales Common').repair_curr_doctype_details(self)
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
new file mode 100644
index 0000000..0c1cc52
--- /dev/null
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -0,0 +1,1510 @@
+# DocType, Delivery Note
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:08:57',
+		'docstatus': 0,
+		'modified': '2011-06-27 16:42:01',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1309173122',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Transaction',
+		'in_create': 0,
+		'is_transaction_doc': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'read_only_onload': 1,
+		'search_fields': 'status,transaction_date,customer,customer_name, territory,grand_total',
+		'section_style': 'Tabbed',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'subject': 'To %(customer_name)s on %(transaction_date)s | %(per_billed)s% billed',
+		'tag_fields': 'billing_status',
+		'version': 444
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Delivery Note',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Delivery Note',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Delivery Note
+	{
+		'doctype': 'DocType',
+		'name': 'Delivery Note'
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'Sales User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 0,
+		'role': 'Accounts User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 1,
+		'role': 'Accounts User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 9,
+		'match': 'customer_name',
+		'permlevel': 0,
+		'role': 'Customer'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 10,
+		'permlevel': 2,
+		'role': 'All',
+		'write': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 1,
+		'label': 'Basic Info',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 2,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'trigger': 'Client',
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'idx': 3,
+		'label': 'Series',
+		'no_copy': 1,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'DN',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Customer',
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Link',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Shipping Address',
+		'options': 'Address',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_person',
+		'fieldtype': 'Link',
+		'idx': 6,
+		'in_filter': 1,
+		'label': 'Contact Person',
+		'options': 'Contact',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'idx': 7,
+		'label': 'Customer Name',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Small Text',
+		'idx': 8,
+		'label': 'Shipping Address',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_display',
+		'fieldtype': 'Small Text',
+		'idx': 9,
+		'label': 'Contact',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_mobile',
+		'fieldtype': 'Text',
+		'idx': 10,
+		'label': 'Mobile No',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_email',
+		'fieldtype': 'Text',
+		'idx': 11,
+		'label': 'Contact Email',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 12,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Today',
+		'description': 'The date at which current entry is made in system.',
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'idx': 13,
+		'in_filter': 1,
+		'label': 'Voucher Date',
+		'no_copy': 1,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': 'Draft',
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'idx': 14,
+		'in_filter': 1,
+		'label': 'Status',
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nDraft\nSubmitted\nCancelled',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': 'eval:!doc.__islocal',
+		'description': '% of materials billed against this Delivery Note',
+		'doctype': 'DocField',
+		'fieldname': 'per_billed',
+		'fieldtype': 'Currency',
+		'idx': 15,
+		'in_filter': 1,
+		'label': '% Qty Billed',
+		'no_copy': 1,
+		'oldfieldname': 'per_billed',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': 'eval:!doc.__islocal',
+		'description': '% of materials delivered against this Delivery Note',
+		'doctype': 'DocField',
+		'fieldname': 'per_installed',
+		'fieldtype': 'Currency',
+		'idx': 16,
+		'in_filter': 1,
+		'label': '% Installed',
+		'no_copy': 1,
+		'oldfieldname': 'per_installed',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 0,
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'idx': 17,
+		'label': 'Amended From',
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry is corrected in the system.',
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'idx': 18,
+		'label': 'Amendment Date',
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 19,
+		'in_filter': 1,
+		'label': 'Territory',
+		'options': 'Territory',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_group',
+		'fieldtype': 'Link',
+		'idx': 20,
+		'in_filter': 1,
+		'label': 'Customer Group',
+		'options': 'Customer Group',
+		'permlevel': 0,
+		'print_hide': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 21,
+		'label': 'Transporter Info',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'transporter_name',
+		'fieldtype': 'Data',
+		'idx': 22,
+		'label': 'Transporter Name',
+		'no_copy': 0,
+		'oldfieldname': 'transporter_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Transporter lorry number',
+		'doctype': 'DocField',
+		'fieldname': 'lr_no',
+		'fieldtype': 'Data',
+		'idx': 23,
+		'label': 'LR No',
+		'no_copy': 0,
+		'oldfieldname': 'lr_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Today',
+		'description': 'Date on which lorry started from your warehouse',
+		'doctype': 'DocField',
+		'fieldname': 'lr_date',
+		'fieldtype': 'Date',
+		'idx': 24,
+		'label': 'LR Date',
+		'no_copy': 0,
+		'oldfieldname': 'lr_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 25,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'challan_no',
+		'fieldtype': 'Data',
+		'idx': 26,
+		'label': 'Challan No',
+		'oldfieldname': 'challan_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'challan_date',
+		'fieldtype': 'Date',
+		'idx': 27,
+		'label': 'Challan Date',
+		'oldfieldname': 'challan_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 28,
+		'label': 'Items',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'You can make a delivery note from multiple sales orders. Select sales orders one by one and click on the button below.',
+		'doctype': 'DocField',
+		'fieldname': 'sales_order_no',
+		'fieldtype': 'Link',
+		'idx': 29,
+		'label': 'Sales Order No',
+		'no_copy': 0,
+		'oldfieldname': 'sales_order_no',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Order',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'idx': 30,
+		'label': 'Get Items',
+		'oldfieldtype': 'Button',
+		'options': 'pull_sales_order_details',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'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.',
+		'doctype': 'DocField',
+		'fieldname': 'price_list_name',
+		'fieldtype': 'Select',
+		'idx': 31,
+		'label': 'Price List',
+		'oldfieldname': 'price_list_name',
+		'oldfieldtype': 'Select',
+		'options': 'link:Price List',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 32,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': "Customer's Currency",
+		'doctype': 'DocField',
+		'fieldname': 'currency',
+		'fieldtype': 'Select',
+		'idx': 33,
+		'label': 'Currency',
+		'oldfieldname': 'currency',
+		'oldfieldtype': 'Select',
+		'options': 'link:Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '1.00',
+		'description': "Rate at which customer's currency is converted to your currency",
+		'doctype': 'DocField',
+		'fieldname': 'conversion_rate',
+		'fieldtype': 'Currency',
+		'idx': 34,
+		'label': 'Conversion Rate',
+		'no_copy': 0,
+		'oldfieldname': 'conversion_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 35,
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_note_details',
+		'fieldtype': 'Table',
+		'idx': 36,
+		'label': 'Delivery Note Details',
+		'no_copy': 0,
+		'oldfieldname': 'delivery_note_details',
+		'oldfieldtype': 'Table',
+		'options': 'Delivery Note Detail',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'net_total',
+		'fieldtype': 'Currency',
+		'idx': 37,
+		'label': 'Net Total*',
+		'no_copy': 0,
+		'oldfieldname': 'net_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 38,
+		'label': 'Re-Calculate Values',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 39,
+		'label': 'Note',
+		'oldfieldtype': 'HTML',
+		'options': '<b>NOTE :</b>* In Base Currency',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 40,
+		'label': 'Taxes',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'If you have created a standard template in Other Charges master, select one and click on the button below.',
+		'doctype': 'DocField',
+		'fieldname': 'charge',
+		'fieldtype': 'Link',
+		'idx': 41,
+		'label': 'Charge',
+		'oldfieldname': 'charge',
+		'oldfieldtype': 'Link',
+		'options': 'Other Charges',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 42,
+		'label': 'Get Charges',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'other_charges',
+		'fieldtype': 'Table',
+		'idx': 43,
+		'label': 'Other Charges',
+		'no_copy': 0,
+		'oldfieldname': 'other_charges',
+		'oldfieldtype': 'Table',
+		'options': 'RV Tax Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'other_charges_total',
+		'fieldtype': 'Currency',
+		'idx': 44,
+		'label': 'Charges Total',
+		'oldfieldname': 'other_charges_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 45,
+		'label': 'Calculate Charges',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 46,
+		'label': 'Other Charges Calculation',
+		'oldfieldtype': 'HTML',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 47,
+		'label': 'Totals',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'grand_total',
+		'fieldtype': 'Currency',
+		'idx': 48,
+		'label': 'Grand Total',
+		'no_copy': 0,
+		'oldfieldname': 'grand_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'rounded_total',
+		'fieldtype': 'Currency',
+		'idx': 49,
+		'label': 'Rounded Total',
+		'no_copy': 0,
+		'oldfieldname': 'rounded_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'In Words will be visible once you save the Delivery Note.',
+		'doctype': 'DocField',
+		'fieldname': 'in_words',
+		'fieldtype': 'Data',
+		'idx': 50,
+		'label': 'In Words',
+		'no_copy': 0,
+		'oldfieldname': 'in_words',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '200px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 51,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'grand_total_export',
+		'fieldtype': 'Currency',
+		'idx': 52,
+		'label': 'Grand Total (Export)',
+		'no_copy': 0,
+		'oldfieldname': 'grand_total_export',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'rounded_total_export',
+		'fieldtype': 'Currency',
+		'idx': 53,
+		'label': 'Rounded Total (Export)',
+		'no_copy': 0,
+		'oldfieldname': 'rounded_total_export',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'In Words (Export) will be visible once you save the Delivery Note.',
+		'doctype': 'DocField',
+		'fieldname': 'in_words_export',
+		'fieldtype': 'Data',
+		'idx': 54,
+		'label': 'In Words (Export)',
+		'no_copy': 0,
+		'oldfieldname': 'in_words_export',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 55,
+		'label': 'Terms',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'tc_name',
+		'fieldtype': 'Link',
+		'idx': 56,
+		'label': 'Select Terms',
+		'oldfieldname': 'tc_name',
+		'oldfieldtype': 'Link',
+		'options': 'Term',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 57,
+		'label': 'Get Terms',
+		'oldfieldtype': 'Button',
+		'options': 'get_tc_details',
+		'permlevel': 0,
+		'trigger': 'Server'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 58,
+		'label': 'Terms HTML',
+		'oldfieldtype': 'HTML',
+		'options': 'You can add Terms and Notes that will be printed in the Transaction',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'terms',
+		'fieldtype': 'Text Editor',
+		'idx': 59,
+		'label': 'Term Details',
+		'oldfieldname': 'terms',
+		'oldfieldtype': 'Text Editor',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Filling in Additional Information about the Delivery Note will help you analyze your data better.',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 60,
+		'label': 'More Info',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Select the relevant company name if you have multiple companies',
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'idx': 61,
+		'in_filter': 1,
+		'label': 'Company',
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 62,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Today',
+		'description': 'The date at which current entry will get or has actually executed.',
+		'doctype': 'DocField',
+		'fieldname': 'posting_date',
+		'fieldtype': 'Date',
+		'idx': 63,
+		'in_filter': 1,
+		'label': 'Posting Date',
+		'no_copy': 1,
+		'oldfieldname': 'posting_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Time at which items were delivered from warehouse',
+		'doctype': 'DocField',
+		'fieldname': 'posting_time',
+		'fieldtype': 'Time',
+		'idx': 64,
+		'in_filter': 0,
+		'label': 'Posting Time',
+		'oldfieldname': 'posting_time',
+		'oldfieldtype': 'Time',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Track this Delivery Note against any Project',
+		'doctype': 'DocField',
+		'fieldname': 'project_name',
+		'fieldtype': 'Link',
+		'idx': 65,
+		'in_filter': 1,
+		'label': 'Project Name',
+		'oldfieldname': 'project_name',
+		'oldfieldtype': 'Link',
+		'options': 'Project',
+		'permlevel': 0,
+		'search_index': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Required only for sample item.',
+		'doctype': 'DocField',
+		'fieldname': 'to_warehouse',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 66,
+		'label': 'To Warehouse',
+		'no_copy': 1,
+		'oldfieldname': 'to_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 67,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'billing_status',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'idx': 68,
+		'label': 'Billing Status',
+		'no_copy': 1,
+		'options': '\nNot Billed\nPartly Billed\nFully Billed',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'installation_status',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'idx': 69,
+		'label': 'Installation Status',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'po_no',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 70,
+		'label': 'P.O. No',
+		'no_copy': 0,
+		'oldfieldname': 'po_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'po_date',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 71,
+		'label': 'P.O. Date',
+		'no_copy': 0,
+		'oldfieldname': 'po_date',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldname': 'letter_head',
+		'fieldtype': 'Select',
+		'idx': 72,
+		'label': 'Letter Head',
+		'oldfieldname': 'letter_head',
+		'oldfieldtype': 'Link',
+		'options': 'link:Letter Head',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'source',
+		'fieldtype': 'Select',
+		'idx': 73,
+		'label': 'Source',
+		'oldfieldname': 'source',
+		'oldfieldtype': 'Select',
+		'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign",
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': "eval:doc.source == 'Campaign'",
+		'doctype': 'DocField',
+		'fieldname': 'campaign',
+		'fieldtype': 'Link',
+		'idx': 74,
+		'label': 'Campaign',
+		'oldfieldname': 'campaign',
+		'oldfieldtype': 'Link',
+		'options': 'Campaign',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'select_print_heading',
+		'fieldtype': 'Link',
+		'idx': 75,
+		'label': 'Select Print Heading',
+		'no_copy': 1,
+		'oldfieldname': 'select_print_heading',
+		'oldfieldtype': 'Link',
+		'options': 'Print Heading',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldname': 'print_without_amount',
+		'fieldtype': 'Check',
+		'idx': 76,
+		'label': 'Print Without Amount',
+		'oldfieldname': 'print_without_amount',
+		'oldfieldtype': 'Check',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'instructions',
+		'fieldtype': 'Text',
+		'idx': 77,
+		'label': 'Instructions',
+		'oldfieldname': 'instructions',
+		'oldfieldtype': 'Text',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': 'eval:!doc.__islocal',
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 78,
+		'label': 'Cancel Reason',
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'excise_page',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 79,
+		'label': 'Excise Page Number',
+		'oldfieldname': 'excise_page',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 80,
+		'label': 'Sales Team',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 81,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sales_partner',
+		'fieldtype': 'Link',
+		'idx': 82,
+		'label': 'Sales Partner',
+		'no_copy': 0,
+		'oldfieldname': 'sales_partner',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Partner',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'commission_rate',
+		'fieldtype': 'Currency',
+		'idx': 83,
+		'label': 'Commission Rate (%)',
+		'no_copy': 0,
+		'oldfieldname': 'commission_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'total_commission',
+		'fieldtype': 'Currency',
+		'idx': 84,
+		'label': 'Total Commission',
+		'no_copy': 0,
+		'oldfieldname': 'total_commission',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 85,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sales_team',
+		'fieldtype': 'Table',
+		'idx': 86,
+		'label': 'Sales Team1',
+		'oldfieldname': 'sales_team',
+		'oldfieldtype': 'Table',
+		'options': 'Sales Team',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'hidden': 1,
+		'idx': 87,
+		'label': 'Supplier Details',
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 88,
+		'label': 'Supplier',
+		'oldfieldname': 'supplier',
+		'oldfieldtype': 'Link',
+		'options': 'Supplier',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier_address',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'idx': 89,
+		'label': 'Supplier Address',
+		'oldfieldname': 'supplier_address',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 0,
+		'doctype': 'DocField',
+		'fieldname': 'purchase_receipt_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 90,
+		'label': 'Purchase Receipt No',
+		'no_copy': 1,
+		'oldfieldname': 'purchase_receipt_no',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Receipt',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_order_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 91,
+		'label': 'Purchase Order',
+		'no_copy': 1,
+		'oldfieldname': 'purchase_order_no',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Order',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 92,
+		'label': 'Packing List',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'packing_details',
+		'fieldtype': 'Table',
+		'idx': 93,
+		'label': 'Packing Details',
+		'oldfieldname': 'packing_details',
+		'oldfieldtype': 'Table',
+		'options': 'Delivery Note Packing Detail',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 94,
+		'label': 'Repair Delivery Note',
+		'oldfieldtype': 'Button',
+		'options': 'repair_delivery_note',
+		'permlevel': 0,
+		'print_hide': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/tests.py b/stock/doctype/delivery_note/tests.py
new file mode 100644
index 0000000..df04c41
--- /dev/null
+++ b/stock/doctype/delivery_note/tests.py
@@ -0,0 +1,25 @@
+import unittest
+import webnotes
+
+from webnotes.model.code import get_obj
+
+class SubmissionTest(unittest.TestCase):
+	def setUp(self):
+		self.dn = webnotes.testing.create('Delivery Note')
+		self.dn_items = []
+		
+		# get a line item for testing
+		for d in self.dn.doclist:
+			if d.doctype=='Delivery Note Detail':
+				self.dn_items.append(d)
+				
+		self.old_bin = get_obj('Warehouse', self.line_item[0].warehouse).get_bin(self.line_item[0].item_code)
+		self.dn.on_submit()
+
+	def test_bin_is_updated(self):
+		"tests if bin quantity is affected when on submission"
+		bin = get_obj('Warehouse', self.line_item.warehouse).get_bin(self.line_item[0].item_code)
+		self.assertTrue(bin.actual_qty == self.old_bin.actual_qty - self.line_item[0].qty)
+		
+	def test_sales_order_is_updated(self):
+		"tests if"
\ No newline at end of file
diff --git a/stock/doctype/delivery_note_detail/__init__.py b/stock/doctype/delivery_note_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/delivery_note_detail/__init__.py
diff --git a/stock/doctype/delivery_note_detail/delivery_note_detail.txt b/stock/doctype/delivery_note_detail/delivery_note_detail.txt
new file mode 100644
index 0000000..f5dd8bf
--- /dev/null
+++ b/stock/doctype/delivery_note_detail/delivery_note_detail.txt
@@ -0,0 +1,489 @@
+# DocType, Delivery Note Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:08:58',
+		'docstatus': 0,
+		'modified': '2011-03-01 10:35:06',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'DND/.#######',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 35
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Delivery Note Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# DocType, Delivery Note Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Delivery Note Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'label': 'Item Name',
+		'oldfieldname': 'item_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Small Text',
+		'idx': 3,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 0,
+		'reqd': 1,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Data',
+		'idx': 4,
+		'label': 'UOM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 0,
+		'reqd': 1,
+		'width': '50px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'no_of_packs',
+		'fieldtype': 'Int',
+		'idx': 5,
+		'label': 'No of Packs',
+		'oldfieldname': 'no_of_packs',
+		'oldfieldtype': 'Int',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Currency',
+		'idx': 6,
+		'label': 'Quantity',
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'ref_rate',
+		'fieldtype': 'Currency',
+		'idx': 7,
+		'label': 'Ref Rate',
+		'no_copy': 0,
+		'oldfieldname': 'ref_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'adj_rate',
+		'fieldtype': 'Float',
+		'idx': 8,
+		'label': 'Discount (%)',
+		'oldfieldname': 'adj_rate',
+		'oldfieldtype': 'Float',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'export_rate',
+		'fieldtype': 'Currency',
+		'idx': 9,
+		'label': 'Rate',
+		'oldfieldname': 'export_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 0,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'export_amount',
+		'fieldtype': 'Currency',
+		'idx': 10,
+		'label': 'Amount',
+		'oldfieldname': 'export_amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 0,
+		'reqd': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'base_ref_rate',
+		'fieldtype': 'Currency',
+		'idx': 11,
+		'label': 'Ref Rate*',
+		'oldfieldname': 'base_ref_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'basic_rate',
+		'fieldtype': 'Currency',
+		'idx': 12,
+		'label': 'Rate*',
+		'oldfieldname': 'basic_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amount',
+		'fieldtype': 'Currency',
+		'idx': 13,
+		'label': 'Amount*',
+		'oldfieldname': 'amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse',
+		'fieldtype': 'Link',
+		'idx': 14,
+		'label': 'Warehouse',
+		'oldfieldname': 'warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Text',
+		'idx': 15,
+		'label': 'Serial No',
+		'no_copy': 1,
+		'oldfieldname': 'serial_no',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'batch_no',
+		'fieldtype': 'Link',
+		'idx': 16,
+		'label': 'Batch No',
+		'oldfieldname': 'batch_no',
+		'oldfieldtype': 'Link',
+		'options': 'Batch',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_group',
+		'fieldtype': 'Link',
+		'idx': 17,
+		'label': 'Item Group',
+		'oldfieldname': 'item_group',
+		'oldfieldtype': 'Link',
+		'options': 'Item Group',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'brand',
+		'fieldtype': 'Link',
+		'idx': 18,
+		'label': 'Brand Name',
+		'oldfieldname': 'brand',
+		'oldfieldtype': 'Link',
+		'options': 'Brand',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'pack_unit',
+		'fieldtype': 'Data',
+		'idx': 19,
+		'label': 'Pack Unit',
+		'oldfieldname': 'pack_unit',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'installed_qty',
+		'fieldtype': 'Currency',
+		'idx': 20,
+		'label': 'Installed Qty',
+		'no_copy': 1,
+		'oldfieldname': 'installed_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'actual_qty',
+		'fieldtype': 'Currency',
+		'idx': 21,
+		'label': 'Available Qty at Warehouse',
+		'no_copy': 1,
+		'oldfieldname': 'actual_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'billed_qty',
+		'fieldtype': 'Currency',
+		'idx': 22,
+		'label': 'Billed Qty',
+		'no_copy': 1,
+		'oldfieldname': 'billed_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'billed_amt',
+		'fieldtype': 'Currency',
+		'idx': 23,
+		'label': 'Billed Amt',
+		'no_copy': 1,
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_docname',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 24,
+		'in_filter': 1,
+		'label': 'Against Document No',
+		'no_copy': 1,
+		'oldfieldname': 'prevdoc_docname',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_doctype',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 25,
+		'in_filter': 1,
+		'label': 'Document Type',
+		'oldfieldname': 'prevdoc_doctype',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'idx': 26,
+		'in_filter': 1,
+		'label': 'Against Document Date',
+		'oldfieldname': 'prevdoc_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_detail_docname',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 27,
+		'in_filter': 1,
+		'label': 'Against Document Detail No',
+		'oldfieldname': 'prevdoc_detail_docname',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_tax_rate',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'idx': 28,
+		'label': 'Item Tax Rate',
+		'oldfieldname': 'item_tax_rate',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldname': 'page_break',
+		'fieldtype': 'Check',
+		'idx': 29,
+		'label': 'Page Break',
+		'oldfieldname': 'page_break',
+		'oldfieldtype': 'Check',
+		'permlevel': 0,
+		'print_hide': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/delivery_note_packing_detail/__init__.py b/stock/doctype/delivery_note_packing_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/delivery_note_packing_detail/__init__.py
diff --git a/stock/doctype/delivery_note_packing_detail/delivery_note_packing_detail.txt b/stock/doctype/delivery_note_packing_detail/delivery_note_packing_detail.txt
new file mode 100644
index 0000000..10fdfda
--- /dev/null
+++ b/stock/doctype/delivery_note_packing_detail/delivery_note_packing_detail.txt
@@ -0,0 +1,285 @@
+# DocType, Delivery Note Packing Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:08:58',
+		'docstatus': 0,
+		'modified': '2011-03-14 14:50:55',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 17
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Delivery Note Packing Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# DocType, Delivery Note Packing Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Delivery Note Packing Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'parent_item',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'label': 'Parent Item',
+		'oldfieldname': 'parent_item',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 2,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Item Name',
+		'oldfieldname': 'item_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'parent_detail_docname',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 4,
+		'label': 'Parent Detail docname',
+		'no_copy': 1,
+		'oldfieldname': 'parent_detail_docname',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 5,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 1,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse',
+		'fieldtype': 'Link',
+		'idx': 6,
+		'label': 'Warehouse',
+		'oldfieldname': 'warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Currency',
+		'idx': 7,
+		'label': 'Qty',
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Text',
+		'idx': 8,
+		'label': 'Serial No',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'actual_qty',
+		'fieldtype': 'Currency',
+		'idx': 9,
+		'label': 'Actual Qty',
+		'no_copy': 1,
+		'oldfieldname': 'actual_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'projected_qty',
+		'fieldtype': 'Currency',
+		'idx': 10,
+		'label': 'Projected Qty',
+		'no_copy': 1,
+		'oldfieldname': 'projected_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'uom',
+		'fieldtype': 'Link',
+		'idx': 11,
+		'label': 'UOM',
+		'oldfieldname': 'uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'planned_qty',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 12,
+		'label': 'Planned Qty ',
+		'no_copy': 1,
+		'oldfieldname': 'planned_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'produced_qty',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 13,
+		'label': 'Produced Qty',
+		'no_copy': 1,
+		'oldfieldname': 'produced_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_doctype',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 14,
+		'label': 'Prevdoc DocType',
+		'oldfieldname': 'prevdoc_doctype',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry is made in system.',
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'hidden': 0,
+		'idx': 15,
+		'label': 'Sales Order Date',
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_date',
+		'fieldtype': 'Date',
+		'hidden': 0,
+		'idx': 16,
+		'label': 'Expected Delivery Date',
+		'oldfieldname': 'delivery_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'confirmation_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'idx': 17,
+		'label': 'Confirmed delivery date',
+		'no_copy': 1,
+		'oldfieldname': 'confirmation_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldname': 'page_break',
+		'fieldtype': 'Check',
+		'idx': 18,
+		'label': 'Page Break',
+		'oldfieldname': 'page_break',
+		'oldfieldtype': 'Check',
+		'permlevel': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/item/__init__.py b/stock/doctype/item/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/item/__init__.py
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
new file mode 100644
index 0000000..115ced5
--- /dev/null
+++ b/stock/doctype/item/item.js
@@ -0,0 +1,87 @@
+cur_frm.cscript.refresh = function(doc) {
+  if(cint(doc.is_local) && doc.has_serial_no) set_field_permlevel('has_serial_no', 1);
+  if(cint(doc.is_local) && doc.is_stock_item) set_field_permlevel('is_stock_item', 1);
+}
+
+
+cur_frm.fields_dict['default_bom'].get_query = function(doc) {
+   //var d = locals[this.doctype][this.docname];
+   return 'SELECT DISTINCT `tabBill Of Materials`.`name` FROM `tabBill Of Materials` WHERE `tabBill Of Materials`.`item` = "' + doc.item_code + '"  AND `tabBill Of Materials`.`is_active` = "No" and `tabBill Of Materials`.docstatus != 2 AND `tabBill Of Materials`.%(key)s LIKE "%s" ORDER BY `tabBill Of Materials`.`name` LIMIT 50'
+}
+
+
+// Expense Account
+// ---------------------------------
+cur_frm.fields_dict['purchase_account'].get_query = function(doc){ 
+  return 'SELECT DISTINCT `tabAccount`.`name` FROM `tabAccount` WHERE `tabAccount`.`debit_or_credit`="Debit" AND `tabAccount`.`group_or_ledger`="Ledger" AND `tabAccount`.`docstatus`!=2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50'
+}
+
+// Income Account 
+// --------------------------------
+cur_frm.fields_dict['default_income_account'].get_query = function(doc) {
+  return 'SELECT DISTINCT `tabAccount`.`name` FROM `tabAccount` WHERE `tabAccount`.`debit_or_credit`="Credit" AND `tabAccount`.`group_or_ledger`="Ledger" AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.`docstatus`!=2 AND `tabAccount`.`account_type` ="Income Account" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50'
+}
+
+
+// Purchase Cost Center 
+// -----------------------------
+cur_frm.fields_dict['cost_center'].get_query = function(doc) {
+  return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY  `tabCost Center`.`name` ASC LIMIT 50'
+}
+
+
+// Sales Cost Center 
+// -----------------------------
+cur_frm.fields_dict['default_sales_cost_center'].get_query = function(doc) {
+  return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY  `tabCost Center`.`name` ASC LIMIT 50'
+}
+
+
+cur_frm.fields_dict['item_tax'].grid.get_field("tax_type").get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabAccount`.`name` FROM `tabAccount` WHERE `tabAccount`.`account_type` in ("Tax", "Chargeable") and `tabAccount`.`docstatus` != 2 and `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.`name` DESC LIMIT 50'
+}
+
+cur_frm.cscript.tax_type = function(doc, cdt, cdn){
+  var d = locals[cdt][cdn];
+  get_server_fields('get_tax_rate',d.tax_type,'item_tax',doc, cdt, cdn, 1);
+}
+
+
+//get query select item group
+cur_frm.fields_dict['item_group'].get_query = function(doc,cdt,cdn) {
+  return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "No" AND `tabItem Group`.`docstatus`!= 2 AND `tabItem Group`.%(key)s LIKE "%s"  ORDER BY  `tabItem Group`.`name` ASC LIMIT 50'
+}
+
+cur_frm.cscript.IGHelp = function(doc,dt,dn){
+  var call_back = function(){
+    var sb_obj = new SalesBrowser();        
+    sb_obj.set_val('Item Group');
+
+  }
+  loadpage('Sales Browser',call_back);
+}
+
+// for description from attachment
+// takes the first attachment and creates
+// a table with both image and attachment in HTML
+// in the "alternate_description" field
+cur_frm.cscript['Add Image'] = function(doc, dt, dn) {
+	if(!doc.file_list) {
+		msgprint('Please attach a file first!'); 
+	}
+	
+	var f = doc.file_list.split('\n')[0];
+	var fname = f.split(',')[0];
+	var fid = f.split(',')[1];
+	if(!in_list(['jpg','jpeg','gif','png'], fname.split('.')[1].toLowerCase())) {
+		msgprint('File must be of extension jpg, jpeg, gif or png'); return;
+	}
+	
+	doc.description_html = repl('<table style="width: 100%; table-layout: fixed;">'+
+	'<tr><td style="width:110px"><img src="%(imgurl)s" width="100px"></td>'+
+	'<td>%(desc)s</td></tr>'+
+	'</table>', {imgurl: wn.urllib.get_file_url(fid), desc:doc.description});
+	
+	refresh_field('description_html');
+}
+
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
new file mode 100644
index 0000000..a2fbf01
--- /dev/null
+++ b/stock/doctype/item/item.py
@@ -0,0 +1,172 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		
+	def get_tax_rate(self, tax_type):
+		rate = sql("select tax_rate from tabAccount where name = %s", tax_type)
+		ret = {
+			'tax_rate'	:	rate and flt(rate[0][0]) or 0
+		}
+		return str(ret)
+
+	def on_update(self):
+		bin = sql("select stock_uom from `tabBin` where item_code = '%s' " % self.doc.item_code)
+		if bin and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
+			msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.")
+			raise Exception
+		check_list = []
+		for d in getlist(self.doclist,'uom_conversion_details'):
+			if not self.doc.stock_uom:
+				msgprint("Please enter Stock UOM first.")
+				raise Exception
+			
+			if cstr(d.uom) in check_list:
+				msgprint("UOM %s has been entered more than once in Conversion Factor Details." % cstr(d.uom))
+				raise Exception
+			
+			if not cstr(d.uom) in check_list:
+				check_list.append(cstr(d.uom))
+							
+			if cstr(d.uom) == cstr(self.doc.stock_uom):
+				if flt(d.conversion_factor) != 1:
+					msgprint("Conversion Fator of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
+					raise Exception
+				# else set uom_exist as true
+				uom_exist='true'
+			elif cstr(d.uom) != cstr(self.doc.stock_uom) and flt(d.conversion_factor) == 1:
+				msgprint("Conversion Factor of UOM : %s should not be equal to 1. As UOM : %s is not Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
+				raise Exception
+		
+		if not cstr(self.doc.stock_uom) in check_list :
+			child = addchild( self.doc, 'uom_conversion_details', 'UOM Conversion Detail', 1, self.doclist)
+			child.uom = self.doc.stock_uom
+			child.conversion_factor = 1
+			child.save()
+
+	
+	# Check whether Ref Rate is not entered twice for same Price List and Currency
+	def check_ref_rate_detail(self):
+		check_list=[]
+		for d in getlist(self.doclist,'ref_rate_details'):
+			if [cstr(d.price_list_name),cstr(d.ref_currency)] in check_list:
+				msgprint("Ref Rate is entered twice for Price List : '%s' and Currency : '%s'." % (d.price_list_name,d.ref_currency))
+				raise Exception
+			else:
+				check_list.append([cstr(d.price_list_name),cstr(d.ref_currency)])
+				
+
+	# Check whether Tax Rate is not entered twice for same Tax Type
+	def check_item_tax(self):
+		check_list=[]
+		for d in getlist(self.doclist,'item_tax'):
+			account_type = sql("select account_type from tabAccount where name = %s",d.tax_type)
+			account_type = account_type and account_type[0][0] or ''
+			if account_type not in ['Tax', 'Chargeable']:
+				msgprint("'%s' is not Tax / Chargeable Account"%(d.tax_type))
+				raise Exception, "Tax Account validation"
+			else:
+				if d.tax_type in check_list:
+					msgprint("Rate is entered twice for Tax : '%s'." % (d.tax_type))
+					raise Exception
+				else:
+					check_list.append(d.tax_type)				
+
+	def check_for_active_boms(self, check):
+		if check in ['Is Active', 'Is Purchase Item']:
+			bom_mat = sql("select distinct t1.parent from `tabBOM Material` t1, `tabBill Of Materials` t2 where t1.item_code ='%s' and (t1.bom_no = '' or t1.bom_no is NULL) and t2.name = t1.parent and t2.is_active = 'Yes' and t2.docstatus = 1 and t1.docstatus =1 " % self.doc.name )
+			if bom_mat and bom_mat[0][0]:
+				msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(check), cstr(self.doc.name)))
+				raise Exception
+		if check == 'Is Active' or ( check == 'Is Manufactured Item' and self.doc.is_sub_contracted_item != 'Yes') or (check ==	'Is Sub Contracted Item' and self.doc.is_manufactured_item != 'Yes') :
+			bom = sql("select name from `tabBill Of Materials` where item = '%s' and is_active ='Yes'" % cstr(self.doc.name))
+			if bom and bom[0][0]:
+				msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(check), cstr(self.doc.name)))
+				raise Exception
+		
+	def validate(self):
+		fl = {'is_manufactured_item'	:'Is Manufactured Item',
+					'is_sub_contracted_item':'Is Sub Contracted Item',
+					'is_purchase_item'			:'Is Purchase Item',
+					'is_pro_applicable'		 :'Is Pro Applicable'}
+		for d in fl:
+			if cstr(self.doc.fields[d]) != 'Yes':
+				self.check_for_active_boms(check = fl[d])
+		self.check_ref_rate_detail()
+		self.check_item_tax()
+		if not self.doc.min_order_qty:
+			self.doc.min_order_qty = 0
+		self.check_non_asset_warehouse()
+		
+		if self.doc.is_pro_applicable == 'Yes' and self.doc.is_manufactured_item != 'Yes':
+			msgprint("If making Production Order is allowed then, it should also allow to make Bill of Materials. Refer Manufacturing section.")
+			raise Exception
+			
+		if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No':
+			msgprint("As Production Order can be made for this Item, then Is Stock Item Should be 'Yes' as we maintain it's stock. Refer Manufacturing and Inventory section.", raise_exception=1)
+			
+		if self.doc.is_stock_item == "Yes" and not self.doc.default_warehouse:
+			msgprint("As we maintain stock of this item, its better to maintain default warehouse. To add default warehouse please go to 'Inventory' section. It will be fetched automatically while making Sales Order, Delivery Note, etc.. ", 1)
+
+		if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
+			msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
+
+	def check_non_asset_warehouse(self):
+		if self.doc.is_asset_item == "Yes":
+			existing_qty = sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
+			for e in existing_qty:
+				msgprint("%s Units exist in Warehouse %s, which is not an Asset Warehouse." % (e[1],e[0]))
+			if existing_qty:
+				msgprint("Please transfer the above quantities to an asset warehouse before changing this item to an asset item.")
+				self.doc.is_asset_item = 'No'
+				raise Exception
+
+	def check_min_inventory_level(self):
+		if self.doc.minimum_inventory_level:
+			total_qty = sql("select sum(projected_qty) from tabBin where item_code = %s",self.doc.name)
+			if flt(total_qty) < flt(self.doc.minimum_inventory_level):
+				msgprint("Your minimum inventory level is reached")
+				send_to = []
+				send = sql("select t1.email from `tabProfile` t1,`tabUserRole` t2 where t2.role IN ('Material Master Manager','Purchase Manager') and t2.parent = t1.name") 
+				for d in send:
+					send_to.append(d[0])
+				msg = '''
+Minimum Inventory Level Reached
+
+Item Code: %s
+Item Name: %s
+Minimum Inventory Level: %s
+Total Available Qty: %s
+
+''' % (self.doc.item_code, self.doc.item_name, self.doc.minimum_inventory_level, total_qty)
+
+				sendmail(send_to, sender='automail@webnotestech.com', subject='Minimum Inventory Level Reached', parts=[['text/plain', msg]])
+
+	def get_file_details(self, arg = ''):
+		file = sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
+
+		ret = {
+			'file_group'	:	file and file[0]['file_group'] or '',
+			'description'	:	file and file[0]['description'] or ''
+			
+		}
+		return str(ret)
diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt
new file mode 100644
index 0000000..a20c968
--- /dev/null
+++ b/stock/doctype/item/item.txt
@@ -0,0 +1,936 @@
+# DocType, Item
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:05',
+		'docstatus': 0,
+		'modified': '2011-05-30 15:22:32',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1308741898',
+		'allow_attach': 1,
+		'allow_trash': 1,
+		'autoname': 'field:item_code',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'max_attachments': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'search_fields': 'item_name,description,item_group',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'subject': '%(item_name)s',
+		'tag_fields': 'item_group',
+		'version': 153
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Item',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'amend': 0,
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Item',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1,
+		'submit': 0
+	},
+
+	# DocType, Item
+	{
+		'doctype': 'DocType',
+		'name': 'Item'
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'permlevel': 0,
+		'role': 'Material User',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Material User',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'Material Master Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Material Master Manager',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 1,
+		'role': 'System Manager',
+		'write': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 1,
+		'label': 'Item',
+		'no_copy': 0,
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'idx': 2,
+		'label': 'Trash Reason',
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Item will be saved by this name in the data base.',
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Data',
+		'idx': 3,
+		'in_filter': 0,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Item Name',
+		'oldfieldname': 'item_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Classify your item in any one item group by clicking on the magnifying glass',
+		'doctype': 'DocField',
+		'fieldname': 'item_group',
+		'fieldtype': 'Link',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Item Group',
+		'oldfieldname': 'item_group',
+		'oldfieldtype': 'Link',
+		'options': 'Item Group',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 6,
+		'label': 'IGHelp',
+		'oldfieldtype': 'HTML',
+		'options': '<a href="javascript:cur_frm.cscript.IGHelp();">To manage Item Group, click here</a>',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'brand',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 7,
+		'label': 'Brand',
+		'oldfieldname': 'brand',
+		'oldfieldtype': 'Link',
+		'options': 'Brand',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 8,
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 9,
+		'in_filter': 0,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 0,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description_html',
+		'fieldtype': 'Text',
+		'idx': 10,
+		'label': 'Description HTML',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Generates HTML to include image (1st attachment) in the description',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 12,
+		'label': 'Add Image',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 13,
+		'label': 'Inventory',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Enter unit of measurement in which stock of this item is maintained in your warehouse.',
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Link',
+		'idx': 14,
+		'label': 'Default UoM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Yes',
+		'description': 'Select "Yes" if you are maintaining stock of this item in your Inventory.',
+		'doctype': 'DocField',
+		'fieldname': 'is_stock_item',
+		'fieldtype': 'Select',
+		'idx': 15,
+		'label': 'Is Stock Item',
+		'oldfieldname': 'is_stock_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'valuation_method',
+		'fieldtype': 'Select',
+		'idx': 16,
+		'label': 'Valuation Method',
+		'oldfieldname': 'valuation_method',
+		'oldfieldtype': 'Select',
+		'options': '\nFIFO\nMoving Average',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'default_warehouse',
+		'fieldtype': 'Link',
+		'idx': 17,
+		'label': 'Default Warehouse',
+		'oldfieldname': 'default_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Percentage variation in quantity to be allowed while receiving or delivering this item.',
+		'doctype': 'DocField',
+		'fieldname': 'tolerance',
+		'fieldtype': 'Currency',
+		'idx': 18,
+		'label': 'Allowance Percent',
+		'oldfieldname': 'tolerance',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 're_order_level',
+		'fieldtype': 'Currency',
+		'idx': 19,
+		'label': 'Re-Order Level',
+		'oldfieldname': 're_order_level',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '0.00',
+		'description': 'If stock level for this item has reached the minimum inventory level, system will prompt you to raise an Indent (Purchase Requisition).',
+		'doctype': 'DocField',
+		'fieldname': 'minimum_inventory_level',
+		'fieldtype': 'Currency',
+		'idx': 20,
+		'label': 'Minimum Inventory Level',
+		'oldfieldname': 'minimum_inventory_level',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '0.00',
+		'description': 'You can enter the minimum quantity of this item to be ordered.',
+		'doctype': 'DocField',
+		'fieldname': 'min_order_qty',
+		'fieldtype': 'Currency',
+		'hidden': 0,
+		'idx': 21,
+		'label': 'Minimum Order Qty',
+		'oldfieldname': 'min_order_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 22,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Select "Yes" if this item is used for some internal purpose in your company.',
+		'doctype': 'DocField',
+		'fieldname': 'is_asset_item',
+		'fieldtype': 'Select',
+		'idx': 23,
+		'label': 'Is Asset Item',
+		'oldfieldname': 'is_asset_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'doctype': 'DocField',
+		'fieldname': 'has_batch_no',
+		'fieldtype': 'Select',
+		'idx': 24,
+		'label': 'Has Batch No',
+		'oldfieldname': 'has_batch_no',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Selecting "Yes" will give a unique identity to each entity of this item which can be viewed in the Serial No master.',
+		'doctype': 'DocField',
+		'fieldname': 'has_serial_no',
+		'fieldtype': 'Select',
+		'idx': 25,
+		'label': 'Has Serial No',
+		'oldfieldname': 'has_serial_no',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warranty_period',
+		'fieldtype': 'Data',
+		'idx': 26,
+		'label': 'Warranty Period (in days)',
+		'oldfieldname': 'warranty_period',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'end_of_life',
+		'fieldtype': 'Date',
+		'idx': 27,
+		'label': 'End of Life',
+		'oldfieldname': 'end_of_life',
+		'oldfieldtype': 'Date',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 28,
+		'label': 'Purchase Details',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Yes',
+		'description': 'Selecting "Yes" will allow this item to appear in Purchase Order , Purchase Receipt.',
+		'doctype': 'DocField',
+		'fieldname': 'is_purchase_item',
+		'fieldtype': 'Select',
+		'idx': 29,
+		'label': 'Is Purchase Item',
+		'oldfieldname': 'is_purchase_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Lead Time days is number of days by which this item is expected in your warehouse. This days is fetched in Indent when you select this item.',
+		'doctype': 'DocField',
+		'fieldname': 'lead_time_days',
+		'fieldtype': 'Int',
+		'idx': 30,
+		'label': 'Lead Time Days',
+		'no_copy': 1,
+		'oldfieldname': 'lead_time_days',
+		'oldfieldtype': 'Int',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Default Purchase Account in which cost of the item will be debited.',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_account',
+		'fieldtype': 'Link',
+		'idx': 31,
+		'label': 'Default Expense Account',
+		'oldfieldname': 'purchase_account',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Default Cost Center for tracking expense for this item.',
+		'doctype': 'DocField',
+		'fieldname': 'cost_center',
+		'fieldtype': 'Link',
+		'idx': 32,
+		'label': 'Default Cost Center',
+		'oldfieldname': 'cost_center',
+		'oldfieldtype': 'Link',
+		'options': 'Cost Center',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Buying Cost will be updated from Purchase Orders and Purchase Receipts. <br>The buying cost will calculated by moving average method.',
+		'doctype': 'DocField',
+		'fieldname': 'buying_cost',
+		'fieldtype': 'Currency',
+		'idx': 33,
+		'label': 'Buying Cost',
+		'no_copy': 1,
+		'oldfieldname': 'buying_cost',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'last_purchase_rate',
+		'fieldtype': 'Currency',
+		'idx': 34,
+		'label': 'Last Purchase Rate',
+		'no_copy': 1,
+		'oldfieldname': 'last_purchase_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'standard_rate',
+		'fieldtype': 'Currency',
+		'idx': 35,
+		'label': 'Standard Rate',
+		'oldfieldname': 'standard_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 36,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'uom_conversion_details',
+		'fieldtype': 'Table',
+		'idx': 37,
+		'label': 'UOM Conversion Details',
+		'oldfieldname': 'uom_conversion_details',
+		'oldfieldtype': 'Table',
+		'options': 'UOM Conversion Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 38,
+		'label': 'Sales Details',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'Yes',
+		'description': 'Selecting "Yes" will allow this item to figure in Sales Order, Delivery Note',
+		'doctype': 'DocField',
+		'fieldname': 'is_sales_item',
+		'fieldtype': 'Select',
+		'idx': 39,
+		'label': 'Is Sales Item',
+		'oldfieldname': 'is_sales_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Select "Yes" if this item represents some work like training, designing, consulting etc.',
+		'doctype': 'DocField',
+		'fieldname': 'is_service_item',
+		'fieldtype': 'Select',
+		'idx': 40,
+		'label': 'Is Service Item',
+		'oldfieldname': 'is_service_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Select "Yes" if this item is to be sent to a customer or received from a supplier as a sample. Delivery notes and Purchase Receipts will update stock levels but there will be no invoice against this item.',
+		'doctype': 'DocField',
+		'fieldname': 'is_sample_item',
+		'fieldtype': 'Select',
+		'idx': 41,
+		'label': 'Allow Samples',
+		'oldfieldname': 'is_sample_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'max_discount',
+		'fieldtype': 'Currency',
+		'idx': 42,
+		'label': 'Max Discount (%)',
+		'oldfieldname': 'max_discount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'default_income_account',
+		'fieldtype': 'Link',
+		'idx': 43,
+		'label': 'Default Income Account',
+		'options': 'Account',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'default_sales_cost_center',
+		'fieldtype': 'Link',
+		'idx': 44,
+		'label': 'Cost Center',
+		'options': 'Cost Center',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sales_rate',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 45,
+		'label': 'Sales Rate',
+		'oldfieldname': 'sales_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 46,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.',
+		'doctype': 'DocField',
+		'fieldname': 'ref_rate_details',
+		'fieldtype': 'Table',
+		'idx': 47,
+		'label': 'Ref Rate Details',
+		'oldfieldname': 'ref_rate_details',
+		'oldfieldtype': 'Table',
+		'options': 'Ref Rate Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 48,
+		'label': 'Item Tax',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_tax',
+		'fieldtype': 'Table',
+		'idx': 49,
+		'label': 'Item Tax1',
+		'oldfieldname': 'item_tax',
+		'oldfieldtype': 'Table',
+		'options': 'Item Tax',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 50,
+		'label': 'Inspection Criteria',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'default': 'No',
+		'doctype': 'DocField',
+		'fieldname': 'inspection_required',
+		'fieldtype': 'Select',
+		'idx': 51,
+		'label': 'Inspection Required',
+		'no_copy': 0,
+		'oldfieldname': 'inspection_required',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_specification_details',
+		'fieldtype': 'Table',
+		'idx': 52,
+		'label': 'Item Specification Detail',
+		'oldfieldname': 'item_specification_details',
+		'oldfieldtype': 'Table',
+		'options': 'Item Specification Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 53,
+		'label': 'Manufacturing',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Selecting "Yes" will allow you to create Bill of Material showing raw material and operational costs incurred to manufacture this item.',
+		'doctype': 'DocField',
+		'fieldname': 'is_manufactured_item',
+		'fieldtype': 'Select',
+		'idx': 54,
+		'label': 'Allow Bill of Materials',
+		'oldfieldname': 'is_manufactured_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'default_bom',
+		'fieldtype': 'Link',
+		'idx': 55,
+		'label': 'Default BOM',
+		'no_copy': 1,
+		'oldfieldname': 'default_bom',
+		'oldfieldtype': 'Link',
+		'options': 'Bill Of Materials',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Selecting "Yes" will allow you to make a Production Order for this item.',
+		'doctype': 'DocField',
+		'fieldname': 'is_pro_applicable',
+		'fieldtype': 'Select',
+		'idx': 56,
+		'label': 'Allow Production Order',
+		'oldfieldname': 'is_pro_applicable',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': 'No',
+		'description': 'Select "Yes" if you supply raw materials to your supplier to manufacture this item.',
+		'doctype': 'DocField',
+		'fieldname': 'is_sub_contracted_item',
+		'fieldtype': 'Select',
+		'idx': 57,
+		'label': 'Is Sub Contracted Item',
+		'oldfieldname': 'is_sub_contracted_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_attachments_details',
+		'fieldtype': 'Table',
+		'idx': 58,
+		'label': 'Item Attachments Details',
+		'oldfieldname': 'item_attachments_details',
+		'oldfieldtype': 'Table',
+		'options': 'Item Attachments Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'file_list',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'idx': 59,
+		'label': 'File List',
+		'permlevel': 0,
+		'print_hide': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/item_specification_detail/__init__.py b/stock/doctype/item_specification_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/item_specification_detail/__init__.py
diff --git a/stock/doctype/item_specification_detail/item_specification_detail.txt b/stock/doctype/item_specification_detail/item_specification_detail.txt
new file mode 100644
index 0000000..7173b09
--- /dev/null
+++ b/stock/doctype/item_specification_detail/item_specification_detail.txt
@@ -0,0 +1,66 @@
+# DocType, Item Specification Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:06',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'IISD/.#####',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 1
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Data',
+		'name': '__common__',
+		'oldfieldtype': 'Data',
+		'parent': 'Item Specification Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# DocType, Item Specification Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Item Specification Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'specification',
+		'idx': 1,
+		'in_filter': 0,
+		'label': 'Parameter',
+		'oldfieldname': 'specification',
+		'reqd': 1,
+		'search_index': 0,
+		'width': '200px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'value',
+		'idx': 2,
+		'label': 'Acceptance Criteria',
+		'oldfieldname': 'value'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/item_tax/__init__.py b/stock/doctype/item_tax/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/item_tax/__init__.py
diff --git a/stock/doctype/item_tax/item_tax.txt b/stock/doctype/item_tax/item_tax.txt
new file mode 100644
index 0000000..1d4adb7
--- /dev/null
+++ b/stock/doctype/item_tax/item_tax.txt
@@ -0,0 +1,66 @@
+# DocType, Item Tax
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:06',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Item Tax',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# DocType, Item Tax
+	{
+		'doctype': 'DocType',
+		'name': 'Item Tax'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'tax_type',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'label': 'Tax',
+		'oldfieldname': 'tax_type',
+		'oldfieldtype': 'Link',
+		'options': 'Account',
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'tax_rate',
+		'fieldtype': 'Currency',
+		'idx': 2,
+		'label': 'Tax Rate',
+		'oldfieldname': 'tax_rate',
+		'oldfieldtype': 'Currency',
+		'reqd': 0
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_detail/__init__.py b/stock/doctype/landed_cost_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/landed_cost_detail/__init__.py
diff --git a/stock/doctype/landed_cost_detail/landed_cost_detail.txt b/stock/doctype/landed_cost_detail/landed_cost_detail.txt
new file mode 100644
index 0000000..16fadba
--- /dev/null
+++ b/stock/doctype/landed_cost_detail/landed_cost_detail.txt
@@ -0,0 +1,77 @@
+# DocType, Landed Cost Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:06',
+		'docstatus': 0,
+		'modified': '2011-06-30 18:47:46',
+		'modified_by': 'Administrator',
+		'owner': 'wasim@webnotestech.com'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 2
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Landed Cost Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocType, Landed Cost Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Landed Cost Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'account_head',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'label': 'Account Head',
+		'oldfieldname': 'account_head',
+		'oldfieldtype': 'Link',
+		'options': 'Account'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Data',
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amount',
+		'fieldtype': 'Currency',
+		'idx': 3,
+		'label': 'Amount',
+		'oldfieldname': 'amount',
+		'oldfieldtype': 'Currency'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master/__init__.py b/stock/doctype/landed_cost_master/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/landed_cost_master/__init__.py
diff --git a/stock/doctype/landed_cost_master/landed_cost_master.js b/stock/doctype/landed_cost_master/landed_cost_master.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/stock/doctype/landed_cost_master/landed_cost_master.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/stock/doctype/landed_cost_master/landed_cost_master.txt b/stock/doctype/landed_cost_master/landed_cost_master.txt
new file mode 100644
index 0000000..e405274
--- /dev/null
+++ b/stock/doctype/landed_cost_master/landed_cost_master.txt
@@ -0,0 +1,167 @@
+# DocType, Landed Cost Master
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'field:title',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'version': 2
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Landed Cost Master',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Landed Cost Master',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Landed Cost Master
+	{
+		'doctype': 'DocType',
+		'name': 'Landed Cost Master'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Purchase Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
+		'role': 'Purchase User',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 1,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'System Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 1,
+		'role': 'Purchase User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 1,
+		'role': 'Purchase Manager'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'idx': 1,
+		'label': 'Trash Reason',
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'title',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'label': 'Title',
+		'oldfieldname': 'title',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 3,
+		'label': 'Landed Cost Details',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'landed_cost',
+		'fieldtype': 'Table',
+		'idx': 4,
+		'label': 'Landed Cost',
+		'oldfieldname': 'landed_cost',
+		'oldfieldtype': 'Table',
+		'options': 'Landed Cost Master Detail',
+		'permlevel': 0
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master_detail/__init__.py b/stock/doctype/landed_cost_master_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/landed_cost_master_detail/__init__.py
diff --git a/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.txt b/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.txt
new file mode 100644
index 0000000..bc752d9
--- /dev/null
+++ b/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.txt
@@ -0,0 +1,61 @@
+# DocType, Landed Cost Master Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'version': 2
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Data',
+		'name': '__common__',
+		'oldfieldtype': 'Data',
+		'parent': 'Landed Cost Master Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# DocType, Landed Cost Master Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Landed Cost Master Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'account_head',
+		'idx': 1,
+		'label': 'Account Head',
+		'oldfieldname': 'account_head'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'idx': 2,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'width': '300px'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_wizard/__init__.py b/stock/doctype/landed_cost_wizard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/landed_cost_wizard/__init__.py
diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.js b/stock/doctype/landed_cost_wizard/landed_cost_wizard.js
new file mode 100644
index 0000000..5209d1a
--- /dev/null
+++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.js
@@ -0,0 +1,11 @@
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+if(!doc.currency){doc.currency = sys_defaults.currency;}
+}
+
+cur_frm.fields_dict['landed_cost_details'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
+  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.account_type = "Chargeable" AND  tabAccount.name LIKE "%s"'
+}
+
+cur_frm.fields_dict['landed_cost_details'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
+  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND  tabAccount.name LIKE "%s"'
+}
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
new file mode 100644
index 0000000..d339e18
--- /dev/null
+++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
@@ -0,0 +1,241 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+
+
+  def get_purchase_receipts(self):
+    self.doc.clear_table(self.doclist,'lc_pr_details',1)
+    if not self.doc.from_pr_date or not self.doc.to_pr_date:
+      msgprint("Please enter From and To PR Date")
+      raise Exception
+    if not self.doc.currency:
+      msgprint("Please enter Currency.")
+      raise Exception
+    pr = sql("select name from `tabPurchase Receipt` where docstatus = 1 and posting_date >= '%s' and posting_date <= '%s' and currency = '%s' order by name "%(self.doc.from_pr_date,self.doc.to_pr_date,self.doc.currency), as_dict = 1)
+    if len(pr)>200:
+      msgprint("Please enter date of shorter duration as there are too many purchase receipt, hence it cannot be loaded.")
+      raise Exception
+    for i in pr:
+      if i and i['name']:
+        pr_no = addchild(self.doc, 'lc_pr_details', 'LC PR Detail', 1, self.doclist)
+        pr_no.purchase_receipt_no = i and i['name'] or ''
+        pr_no.save()
+
+
+  def update_pr_lc_se(self):
+    lst = []
+    condition = ' name in('
+    
+    amt = 0
+    for d in getlist(self.doclist, 'lc_pr_details'):
+      
+      if cint(d.include_in_landed_cost) == 1:
+        condition += '"'+d.purchase_receipt_no+'",'
+        lst.append(d.purchase_receipt_no) 
+    condition += '"")'
+    
+    amount = sql("SELECT SUM(net_total) FROM `tabPurchase Receipt` WHERE docstatus = 1 AND %s"%condition)
+    amt = amount and flt(amount[0][0]) or 0
+    for lc in getlist(self.doclist, 'landed_cost_details'):
+      for name in lst:
+        pr_oc_det = sql("select name from `tabPurchase Tax Detail` where parent = %s and category = 'For Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s ",(name, lc.account_head))
+        #obj = get_obj('Purchase Receipt', name, with_children = 1)
+        if not pr_oc_det:
+          obj = get_obj('Purchase Receipt', name, with_children = 1)
+          lgth = cint(sql("select count(name) from `tabPurchase Tax Detail` where parent = '%s' "%(name))[0][0])
+          pr_oc = addchild(obj.doc, 'purchase_tax_details', 'Purchase Tax Detail', 1)
+          pr_oc.category = 'For Valuation'
+          pr_oc.add_deduct_tax = 'Add'
+          pr_oc.charge_type = 'Actual'
+          pr_oc.description = lc.description
+          pr_oc.account_head = lc.account_head
+          pr_oc.rate = flt(flt(lc.amount) * flt(obj.doc.net_total/ amt))
+          pr_oc.tax_amount = flt(flt(lc.amount) * flt(obj.doc.net_total/ amt))
+          pr_oc.total = obj.doc.grand_total
+          pr_oc.docstatus = 1
+          pr_oc.idx = cint(lgth)
+          pr_oc.save()
+        else:
+          obj = get_obj('Purchase Receipt', name)
+          sql("update `tabPurchase Tax Detail` set rate = %s, tax_amount = %s where name = %s and parent = %s",(flt(flt(lc.amount) * flt(obj.doc.net_total/ amt)),flt(flt(lc.amount) * flt(obj.doc.net_total/ amt)),pr_oc_det[0][0],name))
+        self.calc_pr_other_charges(name)
+        obj = get_obj('Purchase Receipt', name, with_children = 1)
+        for d in getlist(obj.doclist, 'purchase_receipt_details'):
+          if flt(d.qty):
+            d.valuation_rate = (flt(d.purchase_rate) + (flt(d.rm_supp_cost) / flt(d.qty)) + (flt(d.item_tax_amount)/flt(d.qty))) / flt(d.conversion_factor)
+            d.save()
+          sql("update `tabStock Ledger Entry` set incoming_rate = '%s' where voucher_detail_no = '%s'"%(flt(d.valuation_rate), d.name))
+          bin_name = sql("select t1.name, t2.name, t2.posting_date, t2.posting_time from `tabBin` t1, `tabStock Ledger Entry` t2 where t2.voucher_detail_no = '%s' and t2.item_code = t1.item_code and t2.warehouse = t1.warehouse LIMIT 1"%(d.name))
+          if bin_name and bin_name[0][0]:
+            obj = get_obj('Bin', bin_name[0][0]).update_item_valuation(bin_name[0][1], bin_name[0][2], bin_name[0][3])
+
+		# now distribute the taxes among the PRs
+		for lc in getlist(self.doclist, 'landed_cost_details'):
+			for d in lst:
+				pr_id = d.purchase_receipt_no
+				
+				# load the purchase receipt object
+				pr = get_obj('Purchase Receipt', pr_id, with_children = 1)
+				
+				# get the tax detail (for valuation) in the PR if it exists 
+				pr_oc_det = sql("select name from `tabPurchase Tax Detail` where parent = %s and category = 'For Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s ",(pr_id, lc.account_head))
+				
+				# update tax rate and tax amount
+				tax_amount = flt(flt(lc.amount) * flt(pr.doc.net_total/ amt))
+				
+				# for display
+				d.net_total = pr.doc.net_total
+				d.added_cost = tax_amount
+				d.save()
+				
+				# if not exist, create the tax detail for valuation
+				if not pr_oc_det:
+					lgth = cint(sql("select count(name) from `tabPurchase Tax Detail` where parent = '%s' "%(pr_id))[0][0])
+					pr_oc = addchild(pr.doc, 'purchase_tax_details', 'Purchase Tax Detail', 1)
+					pr_oc.category = 'For Valuation'
+					pr_oc.add_deduct_tax = 'Add'
+					pr_oc.charge_type = 'Actual'
+					pr_oc.description = lc.description
+					pr_oc.account_head = lc.account_head
+					pr_oc.rate = tax_amount
+					pr_oc.tax_amount = tax_amount
+					pr_oc.total = obj.doc.grand_total
+					pr_oc.docstatus = 1
+					pr_oc.idx = cint(lgth)
+					pr_oc.save()
+				else:
+					obj = get_obj('Purchase Receipt', name)
+					sql("update `tabPurchase Tax Detail` set rate = %s, tax_amount = %s where name = %s and parent = %s", \
+						(tax_amount, tax_amount, pr_oc_det[0][0], pr_id))
+					
+				self.calc_pr_other_charges(name)
+				
+				# reload - and update the stock entries with the
+				# additional valuations
+				
+				obj = get_obj('Purchase Receipt', name, with_children = 1)
+				for d in getlist(obj.doclist, 'purchase_receipt_details'):
+					if flt(d.qty):
+						d.valuation_rate = (flt(d.purchase_rate) + (flt(d.rm_supp_cost) / flt(d.qty)) + (flt(d.item_tax_amount)/flt(d.qty))) / flt(d.conversion_factor)
+						d.save()
+					sql("update `tabStock Ledger Entry` set incoming_rate = '%s' where voucher_detail_no = '%s'"%(flt(d.valuation_rate), d.name))
+					bin_name = sql("select t1.name, t2.name, t2.posting_date, t2.posting_time from `tabBin` t1, `tabStock Ledger Entry` t2 where t2.voucher_detail_no = '%s' and t2.item_code = t1.item_code and t2.warehouse = t1.warehouse LIMIT 1"%(d.name))
+
+					# update valuation of the item
+					if bin_name and bin_name[0][0]:
+						obj = get_obj('Bin', bin_name[0][0]).update_item_valuation(bin_name[0][1], bin_name[0][2], bin_name[0][3])
+
+	def add_deduct_taxes(self, ocd, oc, tax_amount, total_amount, total, prev_total, f=1):
+		ocd[oc].total_amount = flt(tax_amount.toFixed(2))		 
+		ocd[oc].total_tax_amount = flt(prev_total.toFixed(2))
+		ocd[oc].tax_amount += flt(tax_amount.toFixed(2))
+			 
+		total_amount = flt(ocd[oc].tax_amount)
+		total_tax_amount = flt(ocd[oc].total_tax_amount) + (f * flt(total_amount))
+		
+		if ocd[oc].category != "For Valuation":	
+			prev_total += f * flt(ocd[oc].total_amount)
+			total += f * flt(ocd[oc].tax_amount)
+			ocd[oc].total = flt(total) + (f * flt(tax[t].tax_amount))
+		else:
+			prev_total = prev_total				
+			ocd[oc].total = flt(total)
+		if ocd[oc].category != "For Total":
+			item_tax += f * ocd[oc].total_amount
+		ocd[oc].save()
+		
+		return total, prev_total
+		
+	# calculate the taxes for these PRs		
+	def calc_pr_other_charges(self, name):
+		
+		# re-calculate other charges
+		obj = get_obj('Purchase Receipt', name, with_children = 1)
+		total = 0
+		net_total = obj.doc.net_total
+
+
+		for prd in getlist(obj.doclist, 'purchase_receipt_details'):
+			prev_total, item_tax = flt(prd.amount), 0
+			total += flt(flt(prd.qty) * flt(prd.purchase_rate))
+			
+			check_tax = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
+			ocd = getlist(obj.doclist, 'purchase_tax_details')
+			
+			# calculate tax for other charges
+			for oc in range(len(ocd)):
+				if check_tax.get(ocd[oc].account_head) and ocd[oc].charge_type != 'Actual':
+					rate = check_tax[ocd[oc].account_head]
+				else:
+					rate = flt(ocd[oc].rate)
+				
+				tax_amount = self.cal_tax(ocd, prd, rate, net_total, oc)
+				if ocd[oc].add_deduct_tax == 'Add':
+					add_deduct_taxes(self, ocd, oc, tax_amount, total_amount, total, prev_total, f=1)
+											
+				elif ocd[oc].add_deduct_tax == 'Deduct':
+					add_deduct_taxes(self, ocd, oc, tax_amount, total_amount, total, prev_total, f=-1)
+
+			prd.item_tax_amount = flt(item_tax)
+			prd.save()
+		obj.doc.save()
+					
+	def cal_tax(self, ocd, prd, rate, net_total, oc):
+		tax_amount = 0
+		if ocd[oc].charge_type == 'Actual':
+			value = flt(flt(rate) / flt(net_total))
+			return flt(flt(value) * flt(prd.amount))
+			
+		elif ocd[oc].charge_type == 'On Net Total':
+			return flt(flt(rate) * flt(prd.amount) / 100)
+			
+		elif ocd[oc].charge_type == 'On Previous Row Amount':
+			
+			row_no = cstr(ocd[oc].row_id)
+			row = (row_no).split("+")
+			for r in range(0, len(row.length)):
+				id = cint(row[r])
+				tax_amount += flt((flt(rate) * flt(ocd[id-1].total_amount) / 100))
+			row_id = row_no.find("/")
+			if row_id != -1:
+				rate = ''
+				row = (row_no).split("/")
+				
+				id1 = cint(row[0])
+				id2 = cint(row[1])
+				tax_amount = flt(flt(ocd[id1-1].total_amount) / flt(ocd[id2-1].total_amount))
+				
+			return tax_amount
+
+  # get details for landed cost table from master
+  # ---------------------------------------------
+  def get_landed_cost_master_details(self):
+    msgprint('fetching details.....' + self.doc.landed_cost)
+    self.doc.clear_table(self.doclist, 'landed_cost_details')
+    idx = 0
+    landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
+    msgprint(landed_cost)
+    for cost in landed_cost:
+      lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Detail', 1, self.doclist)
+      lct.account_head = cost['account_head']
+      lct.description = cost['description']
diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt b/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt
new file mode 100644
index 0000000..90c570a
--- /dev/null
+++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt
@@ -0,0 +1,232 @@
+# DocType, Landed Cost Wizard
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'modified': '2011-06-30 18:47:46',
+		'modified_by': 'Administrator',
+		'owner': 'wasim@webnotestech.com'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'issingle': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 1,
+		'version': 31
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Landed Cost Wizard',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Landed Cost Wizard',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Landed Cost Wizard
+	{
+		'doctype': 'DocType',
+		'name': 'Landed Cost Wizard'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'All',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Purchase Manager',
+		'submit': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
+		'role': 'Purchase User',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 1,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'System Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 1,
+		'role': 'Purchase User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 1,
+		'role': 'Purchase Manager'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'from_pr_date',
+		'fieldtype': 'Date',
+		'idx': 1,
+		'label': 'From PR Date',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'to_pr_date',
+		'fieldtype': 'Date',
+		'idx': 2,
+		'label': 'To PR Date',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'currency',
+		'fieldtype': 'Select',
+		'idx': 3,
+		'label': 'Currency',
+		'options': 'link:Currency',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 4,
+		'label': 'Get Purchase Receipt',
+		'options': 'get_purchase_receipts'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 5,
+		'label': 'LC PR Detail',
+		'options': 'Simple'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'lc_pr_details',
+		'fieldtype': 'Table',
+		'idx': 6,
+		'label': 'LC PR Details',
+		'options': 'LC PR Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 7,
+		'label': 'Landed Cost Detail',
+		'options': 'Simple'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'landed_cost',
+		'fieldtype': 'Link',
+		'idx': 8,
+		'label': 'Select Landed Cost Details Master',
+		'options': 'Landed Cost Master'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 9,
+		'label': 'Get Details',
+		'options': 'get_landed_cost_master_details'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'landed_cost_details',
+		'fieldtype': 'Table',
+		'idx': 10,
+		'label': 'Landed Cost Details',
+		'options': 'Landed Cost Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 11,
+		'label': 'Update PR',
+		'options': 'update_pr_lc_se'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/lc_pr_detail/__init__.py b/stock/doctype/lc_pr_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/lc_pr_detail/__init__.py
diff --git a/stock/doctype/lc_pr_detail/lc_pr_detail.txt b/stock/doctype/lc_pr_detail/lc_pr_detail.txt
new file mode 100644
index 0000000..555f88e
--- /dev/null
+++ b/stock/doctype/lc_pr_detail/lc_pr_detail.txt
@@ -0,0 +1,65 @@
+# DocType, LC PR Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:07',
+		'docstatus': 0,
+		'modified': '2011-06-30 18:47:22',
+		'modified_by': 'Administrator',
+		'owner': 'wasim@webnotestech.com'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 2
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'LC PR Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# DocType, LC PR Detail
+	{
+		'doctype': 'DocType',
+		'name': 'LC PR Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_receipt_no',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'label': 'Purchase Receipt No',
+		'oldfieldname': 'purchase_receipt_no',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Receipt'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'include_in_landed_cost',
+		'fieldtype': 'Check',
+		'idx': 2,
+		'label': 'Include In Landed Cost',
+		'oldfieldname': 'include_in_landed_cost',
+		'oldfieldtype': 'Check',
+		'width': '150px'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt/__init__.py b/stock/doctype/purchase_receipt/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/purchase_receipt/__init__.py
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js
new file mode 100644
index 0000000..e060e3c
--- /dev/null
+++ b/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -0,0 +1,287 @@
+cur_frm.cscript.tname = "Purchase Receipt Detail";
+cur_frm.cscript.fname = "purchase_receipt_details";
+cur_frm.cscript.other_fname = "purchase_tax_details";
+
+$import(Purchase Common)
+$import(Purchase Other Charges)
+$import(SMS Control)
+
+//========================== On Load ================================================================
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+
+  if(!doc.fiscal_year && doc.__islocal){ set_default_values(doc);}
+  if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
+  if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
+  if (!doc.status) doc.status = 'Draft';
+  
+  if(doc.__islocal){
+    hide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
+  }
+  
+  if(doc.supplier) unhide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
+  
+}
+
+cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
+	if(doc.__islocal){ 
+		cur_frm.cscript.get_default_schedule_date(doc);
+	}	
+}
+
+//========================== Refresh ===============================================================
+cur_frm.cscript.refresh = function(doc, cdt, cdn) { 
+
+  // Unhide Fields in Next Steps
+  // ---------------------------------
+  cur_frm.clear_custom_buttons();
+  if(doc.docstatus == 1){
+    var ch = getchildren('Purchase Receipt Detail',doc.name,'purchase_receipt_details');
+    allow_billing = 0;
+    for(var i in ch){
+      if(ch[i].qty > ch[i].billed_qty) allow_billing = 1;
+    }
+   cur_frm.add_custom_button('Make Purchase Invoice', cur_frm.cscript['Make Purchase Invoice']);
+   cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+  }
+  else{
+    hide_field(['Repair Purchase Receipt']);
+  }
+}
+
+
+//Supplier
+cur_frm.cscript.supplier = function(doc,dt,dn) {
+  if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1);
+  if(doc.supplier) unhide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
+}
+
+cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {    
+  if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+}
+
+cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT name,address_line1,city FROM tabAddress WHERE supplier = "'+ doc.supplier +'" 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 supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+}
+
+
+cur_frm.fields_dict.supplier_address.on_new = function(dn) {
+  locals['Address'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
+  locals['Address'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
+}
+
+cur_frm.fields_dict.contact_person.on_new = function(dn) {
+  locals['Contact'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
+  locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
+}
+
+// Get Purchase Order Button
+// -----------------
+cur_frm.cscript['Pull Purchase Order Details'] = function(doc, dt, dn) {
+  var callback = function(r,rt) { 
+	  unhide_field(['supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email']);			  
+	  refresh_many(['supplier','supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email','purchase_receipt_details']);
+  }
+  get_server_fields('get_po_details','','',doc, dt, dn,1,callback);
+}
+
+
+//================ create new contact ============================================================================
+cur_frm.cscript.new_contact = function(){
+  tn = createLocal('Contact');
+  locals['Contact'][tn].is_supplier = 1;
+  if(doc.supplier) locals['Contact'][tn].supplier = doc.supplier;
+  loaddoc('Contact', tn);
+}
+
+//======================= posting date =============================
+cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
+  if(doc.__islocal){ 
+    cur_frm.cscript.get_default_schedule_date(doc);
+  }
+}
+
+// ***************** Get project name *****************
+cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
+}
+
+
+//========================= Overloaded query for link batch_no =============================================================
+cur_frm.fields_dict['purchase_receipt_details'].grid.get_field('batch_no').get_query= function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(d.item_code){
+    return "SELECT tabBatch.name, tabBatch.description FROM tabBatch WHERE tabBatch.docstatus != 2 AND tabBatch.item = '"+ d.item_code +"' AND `tabBatch`.`name` like '%s' ORDER BY `tabBatch`.`name` DESC LIMIT 50"
+  }
+  else{
+    alert("Please enter Item Code.");
+  }
+}
+
+cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
+  if(doc.select_print_heading){
+    // print heading
+    cur_frm.pformat.print_heading = doc.select_print_heading;
+  }
+  else
+    cur_frm.pformat.print_heading = "Purchase Receipt";
+}
+// ***************** Get Print Heading  *****************
+cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
+  return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
+}
+
+//========================= Received Qty =============================================================
+
+cur_frm.cscript.received_qty = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  ret = {
+      'qty' : 0,
+      'stock_qty': 0,
+      'rejected_qty' : 0
+    }
+  set_multiple('Purchase Receipt Detail', cdn, ret, 'purchase_receipt_details');
+  cur_frm.cscript.calc_amount(doc, 2);
+}
+
+//======================== Qty (Accepted Qty) =========================================================
+
+cur_frm.cscript.qty = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  // Step 1 :=> Check If Qty > Received Qty
+  if (flt(d.qty) > flt(d.received_qty)) {
+    alert("Accepted Qty cannot be greater than Received Qty")
+    ret = {
+      'qty' : 0,
+      'stock_qty': 0,
+      'rejected_qty' : 0
+    }
+    // => Set Qty = 0 and rejected_qty = 0
+    set_multiple('Purchase Receipt Detail', cdn, ret, 'purchase_receipt_details');
+    cur_frm.cscript.calc_amount(doc, 2);
+    // => Return
+    return
+  }
+  // Step 2 :=> Check IF Qty <= REceived Qty
+  else {
+    ret = {
+      'rejected_qty':flt(d.received_qty) - flt(d.qty)
+    }
+    // => Set Rejected Qty = Received Qty - Qty
+    set_multiple('Purchase Receipt Detail', cdn, ret, 'purchase_receipt_details');
+    // => Calculate Amount
+    cur_frm.cscript.calc_amount(doc, 2);
+    cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
+  }  
+}
+
+//======================== Rejected Qty =========================================================
+cur_frm.cscript.rejected_qty = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  // Step 1 :=> Check If Rejected Qty > Received Qty
+  if (flt(d.rejected_qty) > flt(d.received_qty)) {
+    alert("Rejected Qty cannot be greater than Received Qty") 
+    ret = {
+      'qty' : 0,
+      'stock_qty': 0,
+      'rejected_qty' : 0
+    }
+    // => Set Qty = 0 and rejected_qty = 0
+    set_multiple('Purchase Receipt Detail', cdn, ret, 'purchase_receipt_details');
+    cur_frm.cscript.calc_amount(doc, 2);
+    // => Return
+    return
+  }
+  // Step 2 :=> Check IF Rejected Qty <= REceived Qty
+  else {
+    ret = {
+      'qty':flt(d.received_qty) - flt(d.rejected_qty)
+    }
+    // => Set Qty = Received Qty - Rejected Qty
+    set_multiple('Purchase Receipt Detail', cdn, ret, 'purchase_receipt_details');
+    // Calculate Amount
+    cur_frm.cscript.calc_amount(doc, 2);
+    cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
+  }
+}
+
+//================================= Purchase Order No Get Query ====================================
+cur_frm.fields_dict['purchase_order_no'].get_query = function(doc) {
+  if (doc.supplier)
+    return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`supplier` = "' +doc.supplier + '" and`tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 100  and `tabPurchase Order`.`currency` = ifnull("' +doc.currency+ '","") and `tabPurchase Order`.company = "'+ doc.company +'" and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50';
+  else
+    return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`company` = "'+ doc.company +'" and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 100 and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50';
+}
+
+// QA INspection report get_query
+//---------------------------------
+
+cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query = function(doc) {
+  return 'SELECT `tabQA Inspection Report`.name FROM `tabQA Inspection Report` WHERE `tabQA Inspection Report`.docstatus = 1 AND `tabQA Inspection Report`.%(key)s LIKE "%s"';
+}
+
+// On Button Click Functions
+// ------------------------------------------------------------------------------
+
+
+// ================================ Make Purchase Invoice ==========================================
+cur_frm.cscript['Make Purchase Invoice'] = function() {
+  n = createLocal('Payable Voucher');
+  $c('dt_map', args={
+    'docs':compress_doclist([locals['Payable Voucher'][n]]),
+    'from_doctype': cur_frm.doc.doctype,
+    'to_doctype':'Payable Voucher',
+    'from_docname': cur_frm.doc.name,
+    'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail']]"
+    }, function(r,rt) {
+       loaddoc('Payable Voucher', n);
+    }
+  );
+}
+
+
+
+
+//****************** For print sales order no and date*************************
+cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){
+  //function to make row of table
+  
+  var make_row = function(title,val1, val2, bold){
+    var bstart = '<b>'; var bend = '</b>';
+
+    return '<tr><td style="width:39%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+     +'<td style="width:61%;text-align:left;">'+val1+(val2?' ('+dateutil.str_to_user(val2)+')':'')+'</td>'
+     +'</tr>'
+  }
+
+  out ='';
+  
+  var cl = getchildren('Purchase Receipt Detail',doc.name,'purchase_receipt_details');
+
+  // outer table  
+  var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';
+  
+  // main table
+  out +='<table class="noborder" style="width:100%">';
+
+  // add rows
+  if(cl.length){
+    prevdoc_list = new Array();
+    for(var i=0;i<cl.length;i++){
+      if(cl[i].prevdoc_doctype == 'Purchase Order' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
+        prevdoc_list.push(cl[i].prevdoc_docname);
+        if(prevdoc_list.length ==1)
+          out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
+        else
+          out += make_row('', cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
+      }
+    }
+  }
+
+  out +='</table></td></tr></table></div>';
+
+  return out;
+}
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
new file mode 100644
index 0000000..44cd2c7
--- /dev/null
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -0,0 +1,434 @@
+# 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.defaults = get_defaults()
+    self.tname = 'Purchase Receipt Detail'
+    self.fname = 'purchase_receipt_details'
+    self.count = 0
+
+  # Autoname
+  # ---------
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+
+
+  # Client Trigger Functions
+  #----------------------------------------------------------------------------------------------------
+
+  def get_default_schedule_date(self):
+    get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
+    
+#-----------------Validation For Fiscal Year------------------------
+  def validate_fiscal_year(self):
+    get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Transaction Date')
+    
+  # Get Supplier Details 
+  #def get_supplier_details(self, name = ''):
+  #  return cstr(get_obj(dt='Purchase Common').get_supplier_details(name))
+  
+  # Get Item Details
+  def get_item_details(self, arg = ''):
+    return cstr(get_obj(dt='Purchase Common').get_item_details(self,arg))
+  
+  # Get UOM Details
+  def get_uom_details(self, arg = ''):
+    return cstr(get_obj(dt='Purchase Common').get_uom_details(arg))
+  
+  # GET TERMS & CONDITIONS
+  # =====================================================================================
+  def get_tc_details(self):
+    return get_obj('Purchase Common').get_tc_details(self)
+
+  # get available qty at warehouse
+  def get_bin_details(self, arg = ''):
+    return cstr(get_obj(dt='Purchase Common').get_bin_details(arg))
+
+  # Pull Purchase Order
+  def get_po_details(self):
+    self.validate_prev_docname()
+    get_obj('DocType Mapper', 'Purchase Order-Purchase Receipt').dt_map('Purchase Order', 'Purchase Receipt', self.doc.purchase_order_no, self.doc, self.doclist, "[['Purchase Order','Purchase Receipt'],['PO Detail', 'Purchase Receipt Detail'],['Purchase Tax Detail','Purchase Tax Detail']]")
+  
+  # validate if PO has been pulled twice
+  def validate_prev_docname(self):
+    for d in getlist(self.doclist, 'purchase_receipt_details'): 
+      if self.doc.purchase_order_no and d.prevdoc_docname and self.doc.purchase_order_no == d.prevdoc_docname:
+        msgprint(cstr(self.doc.purchase_order_no) + " Purchase Order details have already been pulled. ")
+        raise Exception
+
+
+  # validation
+  #-------------------------------------------------------------------------------------------------------------
+  # validate accepted and rejected qty
+  def validate_accepted_rejected_qty(self):
+    for d in getlist(self.doclist, "purchase_receipt_details"):
+      
+      # If Reject Qty than Rejected warehouse is mandatory    
+      if flt(d.rejected_qty) and (not self.doc.rejected_warehouse):
+        msgprint("Rejected Warehouse is necessary if there are rejections. See 'Receipt Items'")
+        raise Exception
+
+      # Check Received Qty = Accepted Qty + Rejected Qty 
+      if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
+        
+        msgprint("Sum of Accepted Qty and Rejected Qty must be equal to Received quantity. Error for Item: " + cstr(d.item_code))
+        raise Exception
+
+
+  # update valuation rate
+  def update_valuation_rate(self):
+    total_b_cost = flt(self.doc.buying_cost_transport) + flt(self.doc.buying_cost_taxes) + flt(self.doc.buying_cost_other)
+    for d in getlist(self.doclist, 'purchase_receipt_details'):
+      if flt(self.doc.net_total) and flt(d.qty):
+        #d.valuation_rate = (flt(d.purchase_rate) + ((flt(d.amount) * (total_b_cost)) / (self.doc.net_total * flt(d.qty))) + (flt(d.rm_supp_cost) / flt(d.qty))) / flt(d.conversion_factor)
+        d.valuation_rate = (flt(d.purchase_rate) + ((flt(d.amount) * (total_b_cost)) / (self.doc.net_total * flt(d.qty))) + (flt(d.rm_supp_cost) / flt(d.qty)) + (flt(d.item_tax_amount)/flt(d.qty))) / flt(d.conversion_factor)
+  
+  # Check for Stopped status 
+  def check_for_stopped_status(self, pc_obj):
+    check_list =[]
+    for d in getlist(self.doclist, 'purchase_receipt_details'):
+      if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
+        check_list.append(d.prevdoc_docname)
+        pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
+
+  #check in manage account if purchase order required or not.
+  # ====================================================================================
+  def po_required(self):
+    res = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'po_required'")
+    if res and res[0][0]== 'Yes':
+       for d in getlist(self.doclist,'purchase_receipt_details'):
+         if not d.prevdoc_docname:
+           msgprint("Purchse Order No. required against item %s"%d.item_code)
+           raise Exception
+    
+   
+  # validate
+  def validate(self):
+    self.po_required()
+    self.validate_fiscal_year()
+    set(self.doc, 'status', 'Draft')       # set status as "Draft"
+    self.validate_accepted_rejected_qty()
+    self.validate_inspection()             # Validate Inspection
+    get_obj('Stock Ledger').validate_serial_no(self, 'purchase_receipt_details')
+
+    pc_obj = get_obj(dt='Purchase Common')
+    pc_obj.validate_for_items(self)
+    pc_obj.validate_mandatory(self)
+    pc_obj.validate_conversion_rate(self)
+    pc_obj.get_prevdoc_date(self)
+    pc_obj.validate_reference_value(self)
+    self.check_for_stopped_status(pc_obj)
+
+    # get total in words
+    self.doc.in_words = pc_obj.get_total_in_words(get_defaults().get('currency') or 'INR', self.doc.grand_total)
+    self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
+    # update valuation rate
+    self.update_valuation_rate()
+
+  
+  # On Update
+  # ----------------------------------------------------------------------------------------------------    
+  def on_update(self):
+    if self.doc.rejected_warehouse:
+      for d in getlist(self.doclist,'purchase_receipt_details'):
+        d.rejected_warehouse = self.doc.rejected_warehouse
+    
+    self.update_rw_material_detail()
+    get_obj('Stock Ledger').scrub_serial_nos(self)
+
+
+  # On Submit
+  # -----------------------------------------------------------------------------------------------------
+
+ # Update Stock
+  def update_stock(self, is_submit):
+    pc_obj = get_obj('Purchase Common')
+    self.values = []
+    for d in getlist(self.doclist, 'purchase_receipt_details'):
+      # Check if is_stock_item == 'Yes'
+      if sql("select is_stock_item from tabItem where name=%s", d.item_code)[0][0]=='Yes':
+        ord_qty = 0
+        pr_qty = flt(d.qty) * flt(d.conversion_factor) 
+        
+        # Check If Prevdoc Doctype is Purchase Order  
+        if cstr(d.prevdoc_doctype) == 'Purchase Order':
+          # get qty and pending_qty of prevdoc 
+          curr_ref_qty = pc_obj.get_qty( d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'PO Detail', 'Purchase Order - Purchase Receipt', self.doc.name)
+          max_qty, qty, curr_qty = flt(curr_ref_qty.split('~~~')[1]), flt(curr_ref_qty.split('~~~')[0]), 0
+          
+          if flt(qty) + flt(pr_qty) > flt(max_qty):
+            curr_qty = (flt(max_qty) - flt(qty)) * flt(d.conversion_factor)
+          else:
+            curr_qty = flt(pr_qty)
+          
+          ord_qty = -flt(curr_qty)
+          # update order qty in bin
+          bin = get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(ord_qty), 0, 0, d.item_code, self.doc.transaction_date)
+        
+        # UPDATE actual qty to warehouse by pr_qty
+        self.make_sl_entry(d, d.warehouse, flt(pr_qty), d.valuation_rate, is_submit)
+        # UPDATE actual to rejected warehouse by rejected qty
+        if flt(d.rejected_qty) > 0:
+          self.make_sl_entry(d, self.doc.rejected_warehouse, flt(d.rejected_qty) * flt(d.conversion_factor), d.valuation_rate, is_submit)
+
+    self.bk_flush_supp_wh(is_submit)
+
+    if self.values:
+      get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
+
+
+  # make Stock Entry
+  def make_sl_entry(self, d, wh, qty, in_value, is_submit):
+    self.values.append({
+      'item_code'           : d.fields.has_key('item_code') and d.item_code or d.rm_item_code,
+      'warehouse'           : wh,
+      'transaction_date'    : self.doc.transaction_date,
+      'posting_date'        : self.doc.posting_date,
+      'posting_time'        : self.doc.posting_time,
+      'voucher_type'        : 'Purchase Receipt',
+      'voucher_no'          : self.doc.name,
+      'voucher_detail_no'   : d.name, 
+      'actual_qty'          : qty, 
+      'stock_uom'           : d.stock_uom,
+      'incoming_rate'       : in_value,
+      'company'             : self.doc.company,
+      'fiscal_year'         : self.doc.fiscal_year,
+      'is_cancelled'        : (is_submit==1) and 'No' or 'Yes',
+      'batch_no'            : d.batch_no,
+      'serial_no'           : d.serial_no
+      })
+
+
+  def validate_inspection(self):
+    for d in getlist(self.doclist, 'purchase_receipt_details'):     #Enter inspection date for all items that require inspection
+      ins_reqd = sql("select inspection_required from `tabItem` where name = %s", (d.item_code), as_dict = 1)
+      ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No'        
+      if ins_reqd == 'Yes' and not d.qa_no:
+        msgprint("Item: " + d.item_code + " requires QA Inspection. Please enter QA No or report to authorized person to create QA Inspection Report")
+
+  # Check for Stopped status 
+  def check_for_stopped_status(self, pc_obj):
+    check_list =[]
+    for d in getlist(self.doclist, 'purchase_receipt_details'):
+      if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
+        check_list.append(d.prevdoc_docname)
+        pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
+
+
+  # on submit        
+  def on_submit(self):
+    # Check for Approving Authority
+    get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total)
+
+    # Set status as Submitted
+    set(self.doc,'status', 'Submitted')
+    pc_obj = get_obj('Purchase Common')
+      
+    # Update Previous Doc i.e. update pending_qty and Status accordingly
+    pc_obj.update_prevdoc_detail(self, is_submit = 1)
+        
+    # Update Serial Record
+    get_obj('Stock Ledger').update_serial_record(self, 'purchase_receipt_details', is_submit = 1, is_incoming = 1)
+
+    # Update Stock 
+    self.update_stock(is_submit = 1)
+    
+    # Update last purchase rate 
+    pc_obj.update_last_purchase_rate(self, 1)
+  
+    # on submit notification
+    get_obj('Notification Control').notify_contact('Purchase Receipt', self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
+
+
+
+
+  #On Cancel
+  #----------------------------------------------------------------------------------------------------
+  def check_next_docstatus(self):
+    submit_rv = sql("select t1.name from `tabPayable Voucher` t1,`tabPV Detail` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % (self.doc.name))
+    if submit_rv:
+      msgprint("Purchase Invoice : " + cstr(self.submit_rv[0][0]) + " has already been submitted !")
+      raise Exception , "Validation Error."
+
+
+  def on_cancel(self):
+    pc_obj = get_obj('Purchase Common')
+    
+    self.check_for_stopped_status(pc_obj)
+    # 1.Check if Payable Voucher has been submitted against current Purchase Order
+    # pc_obj.check_docstatus(check = 'Next', doctype = 'Payable Voucher', docname = self.doc.name, detail_doctype = 'PV Detail')
+    
+    submitted = sql("select t1.name from `tabPayable Voucher` t1,`tabPV Detail` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % self.doc.name)
+    if submitted:
+      msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
+      raise Exception
+
+    # 2.Set Status as Cancelled
+    set(self.doc,'status','Cancelled')
+    
+    # 3. Cancel Serial No   
+    get_obj('Stock Ledger').update_serial_record(self, 'purchase_receipt_details', is_submit = 0, is_incoming = 1)
+
+    # 4.Update Bin  
+    self.update_stock(is_submit = 0)
+    
+    # 5.Update Indents Pending Qty and accordingly it's Status 
+    pc_obj.update_prevdoc_detail(self, is_submit = 0)
+
+    # 6. Update last purchase rate 
+    pc_obj.update_last_purchase_rate(self, 0)
+
+        
+#----------- code for Sub-contracted Items -------------------
+  #--------check for sub-contracted items and accordingly update PR raw material detail table--------
+  def update_rw_material_detail(self):
+  
+    for d in getlist(self.doclist,'purchase_receipt_details'):
+      item_det = sql("select is_sub_contracted_item, is_purchase_item from `tabItem` where name = '%s'"%(d.item_code))
+      
+      if item_det[0][0] == 'Yes':
+        if item_det[0][1] == 'Yes':
+          if not self.doc.is_subcontracted:
+            msgprint("Please enter whether purchase receipt to be made for subcontracting or for purchase in 'Is Subcontracted' field .")
+            raise Exception
+          if self.doc.is_subcontracted == 'Yes':
+            if not self.doc.supplier_warehouse:
+              msgprint("Please Enter Supplier Warehouse for subcontracted Items")
+              raise Exception         
+            self.add_bom(d)
+          else:
+            self.doc.clear_table(self.doclist,'pr_raw_material_details',1)
+            self.doc.save()
+        elif item_det[0][1] == 'No':
+          if not self.doc.supplier_warehouse:
+            msgprint("Please Enter Supplier Warehouse for subcontracted Items")
+            raise Exception
+          self.add_bom(d)
+        
+      self.delete_irrelevant_raw_material()
+      #---------------calculate amt in  PR Raw Material Detail-------------
+      self.calculate_amount(d)
+
+
+  def add_bom(self, d):
+    #----- fetching default bom from Bill of Materials instead of Item Master --
+    bom_det = sql("select t1.item, t2.item_code, t2.qty_consumed_per_unit, t2.moving_avg_rate, t2.value_as_per_mar, t2.stock_uom, t2.name, t2.description from `tabBill Of Materials` t1, `tabBOM Material` t2 where t2.parent = t1.name and t1.item = '%s' and ifnull(t1.is_default,0) = 1 and t1.docstatus = 1 and t2.docstatus =1" % d.item_code)
+    if not bom_det:
+      msgprint("No default BOM exists for item: %s" % d.item_code)
+      raise Exception
+    else:
+      #-------------- add child function--------------------
+      chgd_rqd_qty = []
+      for i in bom_det:
+        
+        if i and not sql("select name from `tabPR Raw Material Detail` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)):
+
+          rm_child = addchild(self.doc, 'pr_raw_material_details', 'PR Raw Material Detail', 1, self.doclist)
+
+          rm_child.reference_name = d.name
+          rm_child.bom_detail_no = i and i[6] or ''
+          rm_child.main_item_code = i and i[0] or ''
+          rm_child.rm_item_code = i and i[1] or ''
+          rm_child.description = i and i[7] or ''          
+          rm_child.stock_uom = i and i[5] or ''
+          rm_child.rate = i and flt(i[3]) or flt(i[4])
+          rm_child.conversion_factor = d.conversion_factor
+          rm_child.required_qty = flt(i  and flt(i[2]) or 0) * flt(d.qty) * flt(d.conversion_factor)
+          rm_child.consumed_qty = flt(i  and flt(i[2]) or 0) * flt(d.qty) * flt(d.conversion_factor)
+          rm_child.amount = flt(flt(rm_child.consumed_qty)*flt(rm_child.rate))
+          rm_child.save()
+          chgd_rqd_qty.append(cstr(i[1]))
+        else:
+          act_qty = flt(i  and flt(i[2]) or 0) * flt(d.qty) * flt(d.conversion_factor)
+          for pr_rmd in getlist(self.doclist, 'pr_raw_material_details'):
+            if i and i[6] == pr_rmd.bom_detail_no and (flt(act_qty) != flt(pr_rmd.required_qty) or i[1] != pr_rmd.rm_item_code or i[7] != pr_rmd.description):
+              chgd_rqd_qty.append(cstr(i[1]))
+              pr_rmd.main_item_code = i[0]
+              pr_rmd.rm_item_code = i[1]
+              pr_rmd.description = i[7]              
+              pr_rmd.stock_uom = i[5]
+              pr_rmd.required_qty = flt(act_qty)
+              pr_rmd.consumed_qty = flt(act_qty)
+              pr_rmd.rate = i and flt(i[3]) or flt(i[4])
+              pr_rmd.amount = flt(flt(pr_rmd.consumed_qty)*flt(pr_rmd.rate))
+              pr_rmd.save()
+      if chgd_rqd_qty:
+        msgprint("Please check consumed quantity for Raw Material Item Code: '%s'in Raw materials Detail Table" % ((len(chgd_rqd_qty) > 1 and ','.join(chgd_rqd_qty[:-1]) +' and ' + cstr(chgd_rqd_qty[-1:][0]) ) or cstr(chgd_rqd_qty[0])))
+              
+
+  # Delete irrelevant raw material from PR Raw material details
+  #--------------------------------------------------------------  
+  def delete_irrelevant_raw_material(self):
+    for d in getlist(self.doclist,'pr_raw_material_details'):
+      if not sql("select name from `tabPurchase Receipt Detail` where name = '%s' and parent = '%s' and item_code = '%s'" % (d.reference_name, self.doc.name, d.main_item_code)):
+        d.parent = 'old_par:'+self.doc.name
+        d.save()
+    
+  def calculate_amount(self, d):
+    amt = 0
+    for i in getlist(self.doclist,'pr_raw_material_details'):
+      
+      if(i.reference_name == d.name):
+        #if i.consumed_qty == 0:
+         # msgprint("consumed qty cannot be 0. Please Enter consumed qty ")
+          #raise Exception
+        i.amount = flt(i.consumed_qty)* flt(i.rate)
+        amt += i.amount
+    d.rm_supp_cost = amt
+    d.save()
+    
+
+  # --------------- Back Flush function called on submit and on cancel from update stock
+  def bk_flush_supp_wh(self, is_submit):
+    for d in getlist(self.doclist, 'pr_raw_material_details'):
+      #--------- -ve quantity is passed as raw material qty has to be decreased when PR is submitted and it has to be increased when PR is cancelled
+      consumed_qty = - flt(d.consumed_qty)
+      self.make_sl_entry(d, self.doc.supplier_warehouse, flt(consumed_qty), 0, is_submit)
+      
+
+  # get current_stock
+  # ----------------
+  def get_current_stock(self):
+    for d in getlist(self.doclist, 'pr_raw_material_details'):
+      if self.doc.supplier_warehouse:
+        bin = sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1)
+        d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
+        
+        
+        
+
+# OTHER CHARGES TRIGGER FUNCTIONS
+# ====================================================================================
+  
+  # *********** Get Tax rate if account type is TAX ********************
+  def get_rate(self,arg):
+    return get_obj('Purchase Common').get_rate(arg,self)
+
+  # **** Pull details from other charges master (Get Other Charges) ****
+  def get_purchase_tax_details(self):
+    return get_obj('Purchase Common').get_purchase_tax_details(self)
+
+  # Repair Purchase Order
+  # ===========================================
+  def repair_purchase_receipt(self):
+    get_obj('Purchase Common').repair_curr_doctype_details(self)
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt
new file mode 100644
index 0000000..9759630
--- /dev/null
+++ b/stock/doctype/purchase_receipt/purchase_receipt.txt
@@ -0,0 +1,1262 @@
+# DocType, Purchase Receipt
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:15',
+		'docstatus': 0,
+		'modified': '2011-05-17 16:33:17',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1305630198',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Transaction',
+		'is_transaction_doc': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'read_only_onload': 1,
+		'search_fields': 'status, transaction_date, supplier',
+		'section_style': 'Tabbed',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'subject': 'From %(supplier_name)s against %(purchase_order)s on %(transaction_date)s',
+		'version': 318
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Purchase Receipt',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Purchase Receipt',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Purchase Receipt
+	{
+		'doctype': 'DocType',
+		'name': 'Purchase Receipt'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'Purchase User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Purchase User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'match': 'supplier',
+		'permlevel': 0,
+		'role': 'Supplier'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 2,
+		'role': 'All',
+		'write': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Enter Basic Information about the Purchase Receipt',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 1,
+		'label': 'Basic Info',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 2,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'idx': 3,
+		'label': 'Series',
+		'no_copy': 1,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': '\nGRN',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 0,
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'supplier',
+		'fieldtype': 'Link',
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Supplier',
+		'oldfieldname': 'supplier',
+		'oldfieldtype': 'Link',
+		'options': 'Supplier',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier_address',
+		'fieldtype': 'Link',
+		'idx': 5,
+		'label': 'Supplier Address',
+		'options': 'Address',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_person',
+		'fieldtype': 'Link',
+		'idx': 6,
+		'label': 'Contact Person',
+		'options': 'Contact',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier_name',
+		'fieldtype': 'Data',
+		'idx': 7,
+		'label': 'Name',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Small Text',
+		'idx': 8,
+		'label': 'Address',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_display',
+		'fieldtype': 'Small Text',
+		'idx': 9,
+		'label': 'Contact',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_mobile',
+		'fieldtype': 'Text',
+		'idx': 10,
+		'label': 'Mobile No',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'contact_email',
+		'fieldtype': 'Text',
+		'idx': 11,
+		'label': 'Contact Email',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 12,
+		'label': 'Amended From',
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry is corrected in the system.',
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'idx': 13,
+		'label': 'Amendment Date',
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 14,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'The date at which current entry is made in system.',
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'idx': 15,
+		'in_filter': 1,
+		'label': 'Transaction Date',
+		'no_copy': 1,
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'idx': 16,
+		'in_filter': 1,
+		'label': 'Status',
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nDraft\nSubmitted\nCancelled',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': '% of materials billed against this Purchase Receipt',
+		'doctype': 'DocField',
+		'fieldname': 'per_billed',
+		'fieldtype': 'Currency',
+		'idx': 17,
+		'label': '% Billed',
+		'no_copy': 1,
+		'oldfieldname': 'per_billed',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'bill_no',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 18,
+		'label': 'Bill No',
+		'oldfieldname': 'bill_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'bill_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'idx': 19,
+		'label': 'Bill Date',
+		'oldfieldname': 'bill_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'range',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 20,
+		'label': 'Range',
+		'oldfieldname': 'range',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 21,
+		'label': 'Transporter Info',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'transporter_name',
+		'fieldtype': 'Data',
+		'idx': 22,
+		'label': 'Transporter Name',
+		'oldfieldname': 'transporter_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Transporter lorry number',
+		'doctype': 'DocField',
+		'fieldname': 'lr_no',
+		'fieldtype': 'Data',
+		'idx': 23,
+		'label': 'LR No',
+		'no_copy': 1,
+		'oldfieldname': 'lr_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Date on which lorry started from supplier warehouse',
+		'doctype': 'DocField',
+		'fieldname': 'lr_date',
+		'fieldtype': 'Date',
+		'idx': 24,
+		'label': 'LR Date',
+		'no_copy': 1,
+		'oldfieldname': 'lr_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 25,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'challan_no',
+		'fieldtype': 'Data',
+		'idx': 26,
+		'label': 'Challan No',
+		'no_copy': 1,
+		'oldfieldname': 'challan_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'challan_date',
+		'fieldtype': 'Date',
+		'idx': 27,
+		'label': 'Challan Date',
+		'no_copy': 1,
+		'oldfieldname': 'challan_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 28,
+		'label': 'Items',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'You can make a purchase receipt from multiple purchase orders. Select purchase orders one by one and click on the button below.',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_order_no',
+		'fieldtype': 'Link',
+		'idx': 29,
+		'label': 'Purchase Order',
+		'no_copy': 1,
+		'oldfieldname': 'purchase_order_no',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Order',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 30,
+		'label': 'Pull Purchase Order Details',
+		'oldfieldtype': 'Button',
+		'options': 'get_po_details',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': "Supplier's currency",
+		'doctype': 'DocField',
+		'fieldname': 'currency',
+		'fieldtype': 'Select',
+		'idx': 31,
+		'label': 'Currency',
+		'oldfieldname': 'currency',
+		'oldfieldtype': 'Select',
+		'options': 'link:Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '1.00',
+		'description': "Rate at which supplier's currency is converted to your currency",
+		'doctype': 'DocField',
+		'fieldname': 'conversion_rate',
+		'fieldtype': 'Currency',
+		'idx': 32,
+		'label': 'Conversion Rate',
+		'oldfieldname': 'conversion_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 33,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Select "Yes" for sub - contracting items',
+		'doctype': 'DocField',
+		'fieldname': 'is_subcontracted',
+		'fieldtype': 'Select',
+		'idx': 34,
+		'label': 'Is Subcontracted',
+		'oldfieldname': 'is_subcontracted',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Warehouse where you are maintaining stock of rejected items',
+		'doctype': 'DocField',
+		'fieldname': 'rejected_warehouse',
+		'fieldtype': 'Link',
+		'idx': 35,
+		'label': 'Rejected Warehouse',
+		'no_copy': 1,
+		'oldfieldname': 'rejected_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Supplier warehouse where you have issued raw materials for sub - contracting',
+		'doctype': 'DocField',
+		'fieldname': 'supplier_warehouse',
+		'fieldtype': 'Link',
+		'idx': 36,
+		'label': 'Supplier Warehouse',
+		'no_copy': 1,
+		'oldfieldname': 'supplier_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '50px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 37,
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_receipt_details',
+		'fieldtype': 'Table',
+		'idx': 38,
+		'label': 'Purchase Receipt Details',
+		'oldfieldname': 'purchase_receipt_details',
+		'oldfieldtype': 'Table',
+		'options': 'Purchase Receipt Detail',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'net_total',
+		'fieldtype': 'Currency',
+		'idx': 39,
+		'label': 'Net Total',
+		'oldfieldname': 'net_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 40,
+		'label': 'Re-Calculate Values',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Add / Edit taxes and other charges',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 41,
+		'label': 'Taxes',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'If you have created a standard template in Other Charges master, select one and click on the button below.',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_other_charges',
+		'fieldtype': 'Link',
+		'idx': 42,
+		'label': 'Purchase Other Charges',
+		'oldfieldname': 'purchase_other_charges',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Other Charges',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 43,
+		'label': 'Get Tax Detail',
+		'oldfieldtype': 'Button',
+		'options': 'get_purchase_tax_details',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_tax_details',
+		'fieldtype': 'Table',
+		'idx': 44,
+		'label': 'Purchase Tax Details',
+		'oldfieldname': 'purchase_tax_details',
+		'oldfieldtype': 'Table',
+		'options': 'Purchase Tax Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 45,
+		'label': 'Calculate Tax',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'total_tax',
+		'fieldtype': 'Currency',
+		'idx': 46,
+		'label': 'Total Tax',
+		'oldfieldname': 'total_tax',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 47,
+		'label': 'Tax Calculation',
+		'oldfieldtype': 'HTML',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Add Terms and Conditions for the Purchase Receipt. You can also prepare a master Term Sheet and use the Template.',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 48,
+		'label': 'Terms',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'tc_name',
+		'fieldtype': 'Link',
+		'idx': 49,
+		'label': 'Select Terms',
+		'oldfieldname': 'tc_name',
+		'oldfieldtype': 'Link',
+		'options': 'Term',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 50,
+		'label': 'Get Terms',
+		'oldfieldtype': 'Button',
+		'options': 'get_tc_details',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 51,
+		'label': 'Terms HTML',
+		'oldfieldtype': 'HTML',
+		'options': 'You can add Terms and Notes that will be printed in the Transaction',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'terms',
+		'fieldtype': 'Text Editor',
+		'idx': 52,
+		'label': 'Terms1',
+		'oldfieldname': 'terms',
+		'oldfieldtype': 'Text Editor',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Filing in Additional Information about the Purchase Receipt will help you analyze your data better.',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 53,
+		'label': 'More Info',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Select the relevant company name if you have multiple companies',
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 54,
+		'in_filter': 1,
+		'label': 'Company',
+		'no_copy': 0,
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 55,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'The date at which current entry will get or has actually executed.',
+		'doctype': 'DocField',
+		'fieldname': 'posting_date',
+		'fieldtype': 'Date',
+		'idx': 56,
+		'in_filter': 1,
+		'label': 'Posting Date',
+		'no_copy': 1,
+		'oldfieldname': 'posting_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Time at which materials were received',
+		'doctype': 'DocField',
+		'fieldname': 'posting_time',
+		'fieldtype': 'Time',
+		'idx': 57,
+		'in_filter': 0,
+		'label': 'Posting Time',
+		'no_copy': 1,
+		'oldfieldname': 'posting_time',
+		'oldfieldtype': 'Time',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Track this Purchase Receipt against any Project',
+		'doctype': 'DocField',
+		'fieldname': 'project_name',
+		'fieldtype': 'Link',
+		'idx': 58,
+		'in_filter': 1,
+		'label': 'Project Name',
+		'oldfieldname': 'project_name',
+		'oldfieldtype': 'Link',
+		'options': 'Project',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 59,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'hidden': 1,
+		'idx': 60,
+		'label': 'Other Details',
+		'oldfieldtype': 'HTML',
+		'options': "<div class='columnHeading'>Other Details</div>",
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '30%'
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'select_print_heading',
+		'fieldtype': 'Link',
+		'idx': 61,
+		'label': 'Select Print Heading',
+		'no_copy': 1,
+		'oldfieldname': 'select_print_heading',
+		'oldfieldtype': 'Link',
+		'options': 'Print Heading',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'instructions',
+		'fieldtype': 'Small Text',
+		'idx': 62,
+		'label': 'Instructions',
+		'oldfieldname': 'instructions',
+		'oldfieldtype': 'Text',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'remarks',
+		'fieldtype': 'Small Text',
+		'idx': 63,
+		'label': 'Remarks',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'depends_on': 'eval:!doc.__islocal',
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 64,
+		'label': 'Cancel Reason',
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Detailed Breakup of the totals',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 65,
+		'label': 'Totals',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'rounded_total',
+		'fieldtype': 'Currency',
+		'idx': 66,
+		'label': 'Rounded Total',
+		'oldfieldname': 'rounded_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'grand_total',
+		'fieldtype': 'Currency',
+		'idx': 67,
+		'label': 'Grand Total',
+		'oldfieldname': 'grand_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'other_charges_added',
+		'fieldtype': 'Currency',
+		'idx': 68,
+		'label': 'Other Charges Added',
+		'oldfieldname': 'other_charges_added',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'other_charges_deducted',
+		'fieldtype': 'Currency',
+		'idx': 69,
+		'label': 'Other Charges Deducted',
+		'oldfieldname': 'other_charges_deducted',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'In Words will be visible once you save the Purchase Receipt.',
+		'doctype': 'DocField',
+		'fieldname': 'in_words',
+		'fieldtype': 'Data',
+		'idx': 70,
+		'label': 'In Words',
+		'oldfieldname': 'in_words',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 71,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'net_total_import',
+		'fieldtype': 'Currency',
+		'idx': 72,
+		'label': 'Net Total (Import)',
+		'oldfieldname': 'net_total_import',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'grand_total_import',
+		'fieldtype': 'Currency',
+		'idx': 73,
+		'label': 'Grand Total (Import)',
+		'oldfieldname': 'grand_total_import',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'other_charges_added_import',
+		'fieldtype': 'Currency',
+		'idx': 74,
+		'label': 'Other Charges Added (Import)',
+		'oldfieldname': 'other_charges_added_import',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'other_charges_deducted_import',
+		'fieldtype': 'Currency',
+		'idx': 75,
+		'label': 'Other Charges Deducted (Import)',
+		'oldfieldname': 'other_charges_deducted_import',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'In Words (Import) will be visible once you save the Purchase Receipt.',
+		'doctype': 'DocField',
+		'fieldname': 'in_words_import',
+		'fieldtype': 'Data',
+		'idx': 76,
+		'label': 'In Words (Import)',
+		'oldfieldname': 'in_words_import',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Following table will show values if items are sub - contracted. These values will be fetched from the master of "Bill of Materials" of sub - contracted items.',
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 77,
+		'label': 'Raw Material Details',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 78,
+		'label': 'Get Current Stock',
+		'oldfieldtype': 'Button',
+		'options': 'get_current_stock',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'pr_raw_material_details',
+		'fieldtype': 'Table',
+		'idx': 79,
+		'label': 'PR Raw Material Details',
+		'no_copy': 1,
+		'oldfieldname': 'pr_raw_material_details',
+		'oldfieldtype': 'Table',
+		'options': 'PR Raw Material Detail',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 80,
+		'label': 'Repair Purchase Receipt',
+		'oldfieldtype': 'Button',
+		'options': 'repair_purchase_receipt',
+		'permlevel': 0,
+		'print_hide': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt_detail/__init__.py b/stock/doctype/purchase_receipt_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/purchase_receipt_detail/__init__.py
diff --git a/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt b/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt
new file mode 100644
index 0000000..d030b9e
--- /dev/null
+++ b/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt
@@ -0,0 +1,563 @@
+# DocType, Purchase Receipt Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:16',
+		'docstatus': 0,
+		'modified': '2011-03-16 17:12:38',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'GRND/.#######',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 61
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Purchase Receipt Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# DocType, Purchase Receipt Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Purchase Receipt Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'in_filter': 0,
+		'label': 'Item Name',
+		'oldfieldname': 'item_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 3,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'reqd': 1,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'uom',
+		'fieldtype': 'Link',
+		'idx': 4,
+		'label': 'UOM',
+		'oldfieldname': 'uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'received_qty',
+		'fieldtype': 'Currency',
+		'idx': 5,
+		'label': 'Recd Quantity',
+		'oldfieldname': 'received_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Currency',
+		'idx': 6,
+		'label': 'Accepted Quantity',
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'rejected_qty',
+		'fieldtype': 'Currency',
+		'idx': 7,
+		'in_filter': 0,
+		'label': 'Rejected Quantity',
+		'oldfieldname': 'rejected_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'search_index': 0,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_rate',
+		'fieldtype': 'Currency',
+		'idx': 8,
+		'label': 'Rate (Default Curr.)',
+		'oldfieldname': 'purchase_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'amount',
+		'fieldtype': 'Currency',
+		'idx': 9,
+		'label': 'Amount (Default Curr.)',
+		'oldfieldname': 'amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'schedule_date',
+		'fieldtype': 'Date',
+		'idx': 10,
+		'label': 'Schedule date',
+		'no_copy': 1,
+		'oldfieldname': 'schedule_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 11,
+		'label': 'Accepted Warehouse',
+		'oldfieldname': 'warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'import_rate',
+		'fieldtype': 'Currency',
+		'idx': 12,
+		'label': 'Rate',
+		'oldfieldname': 'import_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 0,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'import_amount',
+		'fieldtype': 'Currency',
+		'idx': 13,
+		'label': 'Amount',
+		'oldfieldname': 'import_amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'conversion_factor',
+		'fieldtype': 'Currency',
+		'idx': 14,
+		'label': 'Conversion Factor',
+		'oldfieldname': 'conversion_factor',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Data',
+		'idx': 15,
+		'label': 'Stock UOM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_qty',
+		'fieldtype': 'Currency',
+		'idx': 16,
+		'label': 'Stock Qty',
+		'oldfieldname': 'stock_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client',
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Text',
+		'idx': 17,
+		'label': 'Serial No',
+		'no_copy': 1,
+		'oldfieldname': 'serial_no',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'batch_no',
+		'fieldtype': 'Link',
+		'idx': 18,
+		'label': 'Batch No',
+		'oldfieldname': 'batch_no',
+		'oldfieldtype': 'Link',
+		'options': 'Batch',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'rejected_warehouse',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 19,
+		'label': 'Rejected Warehouse',
+		'no_copy': 1,
+		'oldfieldname': 'rejected_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'qa_no',
+		'fieldtype': 'Link',
+		'idx': 20,
+		'label': 'QA No',
+		'no_copy': 1,
+		'oldfieldname': 'qa_no',
+		'oldfieldtype': 'Link',
+		'options': 'QA Inspection Report',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'brand',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 21,
+		'label': 'Brand',
+		'oldfieldname': 'brand',
+		'oldfieldtype': 'Link',
+		'options': 'Brand',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_group',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 22,
+		'in_filter': 1,
+		'label': 'Item Group',
+		'oldfieldname': 'item_group',
+		'oldfieldtype': 'Link',
+		'options': 'Item Group',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_doctype',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 23,
+		'label': 'Prevdoc Doctype',
+		'oldfieldname': 'prevdoc_doctype',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_docname',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 24,
+		'in_filter': 1,
+		'label': 'PO No',
+		'no_copy': 0,
+		'oldfieldname': 'prevdoc_docname',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Order',
+		'permlevel': 1,
+		'print_hide': 0,
+		'reqd': 0,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'idx': 25,
+		'in_filter': 1,
+		'label': 'PO Date',
+		'oldfieldname': 'prevdoc_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'rm_supp_cost',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 26,
+		'in_filter': 0,
+		'label': 'Raw Materials Supplied Cost',
+		'oldfieldname': 'rm_supp_cost',
+		'oldfieldtype': 'Currency',
+		'permlevel': 2,
+		'print_hide': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_tax_amount',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 27,
+		'label': 'Item Tax Amount',
+		'no_copy': 1,
+		'oldfieldname': 'item_tax_amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'prevdoc_detail_docname',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 28,
+		'in_filter': 1,
+		'label': 'PO Detail No',
+		'no_copy': 0,
+		'oldfieldname': 'prevdoc_detail_docname',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'default': '0.00',
+		'doctype': 'DocField',
+		'fieldname': 'billed_qty',
+		'fieldtype': 'Currency',
+		'idx': 29,
+		'label': 'Billed Quantity',
+		'no_copy': 1,
+		'oldfieldname': 'billed_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'valuation_rate',
+		'fieldtype': 'Currency',
+		'hidden': 0,
+		'idx': 30,
+		'in_filter': 0,
+		'label': 'Valuation Rate',
+		'no_copy': 1,
+		'oldfieldname': 'valuation_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'width': '80px'
+	},
+
+	# DocField
+	{
+		'description': 'Tax detail table fetched from item master as a string and stored in this field.\nUsed for Purchase Other Charges',
+		'doctype': 'DocField',
+		'fieldname': 'item_tax_rate',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'idx': 31,
+		'in_filter': 0,
+		'label': 'Item Tax Rate',
+		'oldfieldname': 'item_tax_rate',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 1,
+		'doctype': 'DocField',
+		'fieldname': 'page_break',
+		'fieldtype': 'Check',
+		'idx': 32,
+		'label': 'Page Break',
+		'oldfieldname': 'page_break',
+		'oldfieldtype': 'Check',
+		'permlevel': 0,
+		'print_hide': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/ref_rate_detail/__init__.py b/stock/doctype/ref_rate_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/ref_rate_detail/__init__.py
diff --git a/stock/doctype/ref_rate_detail/ref_rate_detail.txt b/stock/doctype/ref_rate_detail/ref_rate_detail.txt
new file mode 100644
index 0000000..078fadc
--- /dev/null
+++ b/stock/doctype/ref_rate_detail/ref_rate_detail.txt
@@ -0,0 +1,84 @@
+# DocType, Ref Rate Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:19',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'RFD/.#####',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'in_create': 1,
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'read_only': 0,
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 2
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'in_filter': 1,
+		'name': '__common__',
+		'parent': 'Ref Rate Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocType, Ref Rate Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Ref Rate Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'price_list_name',
+		'fieldtype': 'Select',
+		'idx': 1,
+		'label': 'Price List Name',
+		'oldfieldname': 'price_list_name',
+		'oldfieldtype': 'Select',
+		'options': 'link:Price List',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'ref_rate',
+		'fieldtype': 'Currency',
+		'idx': 2,
+		'label': 'Ref Rate',
+		'oldfieldname': 'ref_rate',
+		'oldfieldtype': 'Currency',
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'ref_currency',
+		'fieldtype': 'Select',
+		'idx': 3,
+		'label': 'Currency',
+		'oldfieldname': 'ref_currency',
+		'oldfieldtype': 'Select',
+		'options': 'link:Currency',
+		'reqd': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/sales_and_purchase_return_wizard/__init__.py b/stock/doctype/sales_and_purchase_return_wizard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/sales_and_purchase_return_wizard/__init__.py
diff --git a/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.js b/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.js
new file mode 100644
index 0000000..ed071fa
--- /dev/null
+++ b/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.js
@@ -0,0 +1,176 @@
+// Onload
+//-------------------------------
+cur_frm.cscript.onload = function(doc,dt,dn){
+  if(!doc.return_date) set_multiple(dt,dn,{return_date:get_today()});
+  doc.delivery_note_no = '';
+  doc.purchase_receipt_no = '';
+  doc.sales_invoice_no = '';
+  doc.return_type ='';
+  refresh_many(['delivery_note_no', 'sales_invoice_no', 'purchase_receipt_no', 'return_type']);
+}
+
+// Link field query
+//--------------------------------
+cur_frm.fields_dict.delivery_note_no.get_query = function(doc) {
+  return 'SELECT DISTINCT `tabDelivery Note`.name FROM `tabDelivery Note` WHERE `tabDelivery Note`.docstatus = 1 AND `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.name desc LIMIT 50';
+}
+
+cur_frm.fields_dict.sales_invoice_no.get_query = function(doc) {
+  return 'SELECT DISTINCT `tabReceivable Voucher`.name FROM `tabReceivable Voucher` WHERE `tabReceivable Voucher`.docstatus = 1 AND `tabReceivable Voucher`.%(key)s LIKE "%s" ORDER BY `tabReceivable Voucher`.name desc LIMIT 50';
+}
+
+cur_frm.fields_dict.purchase_receipt_no.get_query = function(doc) {
+  return 'SELECT DISTINCT `tabPurchase Receipt`.name FROM `tabPurchase Receipt` WHERE `tabPurchase Receipt`.docstatus = 1 AND `tabPurchase Receipt`.%(key)s LIKE "%s" ORDER BY `tabPurchase Receipt`.name desc LIMIT 50';
+}
+
+// Hide/unhide based on return type
+//----------------------------------
+cur_frm.cscript.return_type = function(doc, cdt, cdn) {
+  hide_field(['purchase_receipt_no', 'delivery_note_no', 'sales_invoice_no', 'return_details', 'Get Items', 'Make Excise Invoice', 'Make Stock Entry', 'Make Debit Note', 'Make Credit Note']);
+  if(doc.return_type == 'Sales Return')
+    unhide_field(['delivery_note_no', 'sales_invoice_no', 'Get Items', 'return_details', 'Make Credit Note', 'Make Stock Entry', 'Make Excise Invoice']);
+  else if(doc.return_type == 'Purchase Return')
+    unhide_field(['purchase_receipt_no', 'Get Items', 'return_details', 'Make Debit Note', 'Make Stock Entry', 'Make Excise Invoice']);
+
+  cur_frm.cscript.clear_fields(doc);
+}
+
+// Create item table
+//-------------------------------
+cur_frm.cscript['Get Items'] = function(doc, cdt, cdn) {
+  flag = 0
+  if(doc.return_type == 'Sales Return') {
+    if (doc.delivery_note_no && doc.sales_invoice_no) {
+      msgprint("You can not enter both Delivery Note No and Sales Invoice No. Please enter any one.");
+      flag = 1;
+    } else if (!doc.delivery_note_no && !doc.sales_invoice_no) {
+      msgprint("Please enter Delivery Note No or Sales Invoice No to proceed");
+      flag = 1;
+    }
+  } else if (doc.return_type == 'Purchase Return' && !doc.purchase_receipt_no) {
+    msgprint("Please enter Purchase Receipt No to proceed");
+    flag = 1;
+  }
+  if (!flag)
+    $c_obj(make_doclist(doc.doctype, doc.name),'pull_item_details','', function(r, rt) {
+      refresh_many(['return_details', 'cust_supp', 'cust_supp_name', 'cust_supp_address']);
+    });
+}
+
+// Clear fields
+//-------------------------------
+cur_frm.cscript.clear_fields = function(doc) {
+  doc.purchase_receipt_no, doc.delivery_note_no, doc.sales_invoice_no = '', '', '';
+  var cl = getchildren('Return Detail', doc.name, 'return_details')
+  if(cl.length) $c_obj(make_doclist(doc.doctype, doc.name),'clear_return_table','', function(r, rt) {refresh_field('return_details')});
+  refresh_many(['delivery_note_no', 'sales_invoice_no', 'purchase_receipt_no', 'return_details']);
+}
+
+// Make Stock Entry
+//-------------------------------
+cur_frm.cscript['Make Stock Entry'] = function(doc, cdt, cdn) {
+  var cl = getchildren('Return Detail', doc.name, 'return_details');
+  if (!cl.length)
+    msgprint("Item table can not be blank. Please click on 'Get Items'.");
+  else if (!cur_frm.cscript.validate_returned_qty(cl)) {
+    se = cur_frm.cscript.map_parent_fields(doc,cdt,cdn);
+    cur_frm.cscript.map_child_fields(cl, se);
+    loaddoc('Stock Entry', se.name);
+  }
+}
+
+// Validate returned qty
+//---------------------------
+cur_frm.cscript.validate_returned_qty = function(cl) {
+  flag = 0
+  for(var i = 0; i<cl.length; i++){
+    if(cl[i].returned_qty > cl[i].qty) {
+      msgprint("Returned Qty can not be greater than qty. Please check for item: " + cl[i].item_code);
+      flag = 1
+    }
+  }
+  return flag
+}
+
+
+// map parent fields of stock entry
+//----------------------------------
+cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
+  var se = LocalDB.create('Stock Entry');
+  se = locals['Stock Entry'][se];
+  se.posting_date = dateutil.obj_to_str(new Date());
+  se.transfer_date = dateutil.obj_to_str(new Date());
+  se.fiscal_year = sys_defaults.fiscal_year;
+  se.purpose = doc.return_type;
+  se.remarks = doc.return_type + ' of ' + (doc.delivery_note_no || doc.sales_invoice_no || doc.purchase_receipt_no);
+  if(doc.return_type == 'Sales Return'){
+    se.delivery_note_no = doc.delivery_note_no;
+    se.sales_invoice_no = doc.sales_invoice_no;
+    se.customer = doc.cust_supp_name;
+    se.customer_name = doc.cust_supp_name;
+    se.customer_address = doc.cust_supp_address;
+  }
+  else if(doc.return_type == 'Purchase Return'){
+    se.purchase_receipt_no = doc.purchase_receipt_no;
+    se.supplier = doc.cust_supp_name;
+    se.supplier_name = doc.cust_supp_name;
+    se.supplier_address = doc.cust_supp_address;
+  }
+  return se
+}
+
+// map child fields of stock entry
+//---------------------------------
+cur_frm.cscript.map_child_fields = function(cl, se) {
+  for(var i = 0; i<cl.length; i++){
+    if (cl[i].returned_qty) {
+      var d1 = LocalDB.add_child(se, 'Stock Entry Detail', 'mtn_details');
+      d1.detail_name = cl[i].detail_name;
+      d1.item_code = cl[i].item_code;
+      d1.description = cl[i].description;
+      d1.transfer_qty = cl[i].returned_qty;
+      d1.qty = cl[i].returned_qty;
+      d1.stock_uom = cl[i].uom;
+      d1.uom = cl[i].uom;
+      d1.conversion_factor = 1;
+      d1.incoming_rate = cl[i].rate;
+      d1.serial_no = cl[i].serial_no;
+      d1.batch_no = cl[i].batch_no;
+    }
+  }
+}
+
+// Make excise voucher
+//-------------------------------
+cur_frm.cscript['Make Excise Invoice'] = function(doc) {
+  var excise = LocalDB.create('Journal Voucher');
+  excise = locals['Journal Voucher'][excise];
+  excise.voucher_type = 'Excise Voucher';
+  loaddoc('Journal Voucher',excise.name);
+}
+// Make debit note
+//------------------------------
+cur_frm.cscript['Make Debit Note'] = function(doc) {
+  cur_frm.cscript.make_jv(doc, 'Debit Note');
+}
+// Make credit note
+//------------------------------
+cur_frm.cscript['Make Credit Note'] = function(doc) {
+  cur_frm.cscript.make_jv(doc, 'Credit Note');
+}
+
+// Make JV
+//--------------------------------
+cur_frm.cscript.make_jv = function(doc, dr_or_cr) {
+  var jv = LocalDB.create('Journal Voucher');
+  jv = locals['Journal Voucher'][jv];
+  
+  jv.voucher_type = dr_or_cr;
+  jv.company = sys_defaults.company;
+  jv.fiscal_year = sys_defaults.fiscal_year;
+  jv.is_opening = 'No';
+  jv.posting_date = dateutil.obj_to_str(new Date());
+  jv.voucher_date = dateutil.obj_to_str(new Date());
+
+  loaddoc('Journal Voucher',jv.name);
+}
diff --git a/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.py b/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.py
new file mode 100644
index 0000000..ca6761e
--- /dev/null
+++ b/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.py
@@ -0,0 +1,61 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+class DocType :
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+
+  # Pull Item Details
+  # ---------------------------
+  def pull_item_details(self):
+    if self.doc.return_type == 'Sales Return':
+      if self.doc.delivery_note_no:
+        det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.basic_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Detail` t1, `tabDelivery Note Detail` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
+      elif self.doc.sales_invoice_no:
+        det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.basic_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabRV Detail` t1, `tabReceivable Voucher` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
+    elif self.doc.return_type == 'Purchase Return' and self.doc.purchase_receipt_no:
+      det = sql("select t1.name, t1.item_code, t1.description, t1.received_qty, t1.uom, t1.purchase_rate, t2.supplier, t2.supplier_name, t2.supplier_address, t1.serial_no, t1.batch_no from `tabPurchase Receipt Detail` t1, `tabPurchase Receipt` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.purchase_receipt_no)
+
+    self.doc.cust_supp = det and det[0][6] or ''
+    self.doc.cust_supp_name = det and det[0][7] or ''
+    self.doc.cust_supp_address = det and det[0][8] or ''
+    self.create_item_table(det)
+    self.doc.save()
+ 
+  # Create Item Table
+  # -----------------------------
+  def create_item_table(self, det):
+    self.doc.clear_table(self.doclist, 'return_details', 1)
+    for i in det:
+      ch = addchild(self.doc, 'return_details', 'Return Detail', 1, self.doclist)
+      ch.detail_name = i and i[0] or ''
+      ch.item_code = i and i[1] or ''
+      ch.description = i and i[2] or ''
+      ch.qty = i and flt(i[3]) or 0
+      ch.uom = i and i[4] or ''
+      ch.rate = i and flt(i[5]) or 0
+      ch.serial_no = i and i[9] or ''
+      ch.batch_no = (len(i) == 11) and i[10] or ''
+      ch.save()
+
+  # Clear return table
+  # --------------------------------
+  def clear_return_table(self):
+    self.doc.clear_table(self.doclist, 'return_details', 1)
+    self.doc.save()
diff --git a/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.txt b/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.txt
new file mode 100644
index 0000000..bc6d6fa
--- /dev/null
+++ b/stock/doctype/sales_and_purchase_return_wizard/sales_and_purchase_return_wizard.txt
@@ -0,0 +1,443 @@
+# DocType, Sales and Purchase Return Wizard
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'modified': '2011-02-23 19:09:18',
+		'modified_by': 'Administrator',
+		'owner': 'wasim@webnotestech.com'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'is_transaction_doc': 0,
+		'issingle': 1,
+		'istable': 0,
+		'menu_index': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'parent_node': 'Materials',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 1,
+		'version': 46
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Sales and Purchase Return Wizard',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Sales and Purchase Return Wizard',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Sales and Purchase Return Wizard
+	{
+		'doctype': 'DocType',
+		'name': 'Sales and Purchase Return Wizard'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'All',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'submit': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 0,
+		'role': 'Accounts Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 0,
+		'role': 'Accounts User',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 9,
+		'permlevel': 0,
+		'role': 'Sales User',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 10,
+		'permlevel': 0,
+		'role': 'Sales Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 11,
+		'permlevel': 0,
+		'role': 'Purchase User',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 12,
+		'permlevel': 0,
+		'role': 'Purchase Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 13,
+		'permlevel': 1,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 14,
+		'permlevel': 1,
+		'role': 'System Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 15,
+		'permlevel': 1,
+		'role': 'Accounts Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 16,
+		'permlevel': 1,
+		'role': 'Accounts User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 17,
+		'permlevel': 1,
+		'role': 'Sales User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 18,
+		'permlevel': 1,
+		'role': 'Sales Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 19,
+		'permlevel': 1,
+		'role': 'Purchase User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 20,
+		'permlevel': 1,
+		'role': 'Purchase Manager'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'return_date',
+		'fieldtype': 'Date',
+		'idx': 1,
+		'label': 'Return Date',
+		'no_copy': 1,
+		'oldfieldname': 'return_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'return_type',
+		'fieldtype': 'Select',
+		'idx': 2,
+		'label': 'Return Type',
+		'no_copy': 1,
+		'oldfieldname': 'return_type',
+		'oldfieldtype': 'Select',
+		'options': '\nSales Return\nPurchase Return',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_note_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 3,
+		'label': 'Delivery Note No',
+		'no_copy': 1,
+		'oldfieldname': 'delivery_note_no',
+		'oldfieldtype': 'Link',
+		'options': 'Delivery Note',
+		'permlevel': 0,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sales_invoice_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 4,
+		'label': 'Sales Invoice No',
+		'options': 'Receivable Voucher',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_receipt_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 5,
+		'label': 'Purchase Receipt No',
+		'no_copy': 1,
+		'oldfieldname': 'purchase_receipt_no',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Receipt',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cust_supp',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 6,
+		'label': 'Customer/Supplier',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cust_supp_name',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 7,
+		'label': 'Cust/Supp Name',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cust_supp_address',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'idx': 8,
+		'label': 'Cust/Supp Address',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 1,
+		'idx': 9,
+		'label': 'Get Items',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'return_details',
+		'fieldtype': 'Table',
+		'hidden': 1,
+		'idx': 10,
+		'label': 'Return Details',
+		'no_copy': 1,
+		'oldfieldname': 'return_details',
+		'oldfieldtype': 'Table',
+		'options': 'Return Detail',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 1,
+		'idx': 11,
+		'label': 'Make Stock Entry',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 1,
+		'idx': 12,
+		'label': 'Make Excise Invoice',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 1,
+		'idx': 13,
+		'label': 'Make Credit Note',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 1,
+		'idx': 14,
+		'label': 'Make Debit Note',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/sales_bom/__init__.py b/stock/doctype/sales_bom/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/sales_bom/__init__.py
diff --git a/stock/doctype/sales_bom/sales_bom.js b/stock/doctype/sales_bom/sales_bom.js
new file mode 100644
index 0000000..0581325
--- /dev/null
+++ b/stock/doctype/sales_bom/sales_bom.js
@@ -0,0 +1,30 @@
+$import(Tips Common)
+
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn); 
+  if(!doc.price_list) set_multiple(cdt,cdn,{price_list:sys_defaults.price_list_name});
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+/* Get Item Code */
+cur_frm.cscript.item_code = function(doc, dt, dn) {
+  var d = locals[dt][dn];
+  if (d.item_code){
+    get_server_fields('get_item_details', d.item_code, 'sales_bom_items', doc ,dt, dn, 1);
+  }
+}
+
+cur_frm.cscript.price_list = function(doc, cdt, cdn) {
+  $c_obj(make_doclist(cdt,cdn), 'get_rates', '', function(r,rt){refresh_field('sales_bom_items');});
+}
+
+cur_frm.cscript.currency = function(doc, cdt, cdn) {
+  $c_obj(make_doclist(cdt,cdn), 'get_rates', '', function(r,rt){refresh_field('sales_bom_items');});
+}
+
+cur_frm.cscript['Find Sales BOM'] = function(doc, dt, dn) {
+  $c_obj(make_doclist(dt,dn), 'check_duplicate', 1, '');
+}
\ No newline at end of file
diff --git a/stock/doctype/sales_bom/sales_bom.py b/stock/doctype/sales_bom/sales_bom.py
new file mode 100644
index 0000000..3bd6fa5
--- /dev/null
+++ b/stock/doctype/sales_bom/sales_bom.py
@@ -0,0 +1,205 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self,d,dl):
+    self.doc, self.doclist = d,dl
+
+  def autoname(self):
+    self.doc.name = make_autoname(self.doc.new_item_code)
+
+  
+  # Get Ref Rates
+  # --------------
+  def get_rates(self):
+    for d in getlist(self.doclist, "sales_bom_items"):
+      r = sql("select ref_rate from `tabRef Rate Detail` where price_list_name=%s and parent=%s and ref_currency = %s", (self.doc.price_list, d.item_code, self.doc.currency))
+      d.rate = r and flt(r[0][0]) or 0.00
+
+
+  # Get Item Details
+  # -----------------
+  def get_item_details(self, name):
+    det = sql("select description, stock_uom from `tabItem` where name = '%s' " % cstr(name))
+    rate = sql("select ref_rate from `tabRef Rate Detail` where price_list_name = %s and parent = %s and ref_currency = %s", (self.doc.price_list, name, self.doc.currency))
+    return cstr({'description' : det and det[0][0] or '', 'uom': det and det[0][1] or '', 'rate': rate and flt(rate[0][0]) or 0.00})
+
+
+  def get_main_item(self):
+    is_main_item = []
+    for d in getlist(self.doclist,'sales_bom_items'):
+      if d.is_main_item == 'Yes':
+        is_main_item.append(d.item_code)
+      # Check that Sales Bom Item cannot be child of Sales Bom.
+      if sql("select name from `tabSales BOM` where name = '%s' " % d.item_code):
+        msgprint("Sales Bom Item " + d.item_code +" cannot be child item.")
+        raise Exception
+      # Check if is_main_item is modified once saved
+      if not self.doc.fields.get('__islocal') and d.is_main_item == "Yes" and cstr(d.item_code) != cstr(self.doc.name)[:-3] :
+        msgprint("Modifying the main item is not allowed.")
+        raise Exception
+    if len(is_main_item) > 1:
+      msgprint('Main item cannot be more than one.')
+      raise Exception , " Validation Error."
+    if len(is_main_item) == 0:
+      msgprint("At least one item should be main item.")
+      raise Exception , " Validation Error."
+    return is_main_item[0]
+
+
+  # Make Item
+  # ---------
+  def create_new_item(self):
+    i = Document("Item")
+    
+    i.item_code = self.doc.new_item_code
+    i.item_name = self.doc.new_item_name
+    i.name = i.item_code
+    i.is_sales_item = 'Yes'
+    i.is_stock_item = 'No'
+    i.save(1)
+
+# This function is deprecated as we will see only pricelist which is selected 
+#  def get_price_lists(self):
+#    return [i[0] for i in sql("select name from `tabPrice List` where docstatus != 2")]
+
+  # Update Rate
+  # -----------
+  
+  def update_ref_rate(self, i):
+    ref_rate,count, p, currency  =  0,0, self.doc.price_list, self.doc.currency
+    if not cstr(self.doc.price_list):
+      msgprint("Please enter Price List.")
+      raise Exception
+    if not cstr(self.doc.currency):
+      msgprint("Please enter Currency.")
+      raise Exception
+    for d in getlist(self.doclist, "sales_bom_items"):
+      item_rate = sql("select ref_rate,ref_currency from `tabRef Rate Detail` where price_list_name=%s and parent=%s", (p, d.item_code))      
+      if not item_rate:
+        msgprint("Item %s does not have a rate for Price List %s. Did not update rates for this Price List" % (d.item_code, p))
+        raise Exception
+      # if count == 0 : currency = cstr(item_rate[0][1])
+      if not cstr(currency) == cstr(item_rate[0][1]):
+        msgprint("Item %s currency %s does not match with other items currency i.e. %s " %(d.item_code,item_rate[0][1],currency))
+        raise Exception
+      count += 1
+      ref_rate += (flt(d.qty) * flt(item_rate[0][0]))
+      
+    pld = addchild(i,"ref_rate_details", "Ref Rate Detail")
+    pld.price_list_name = p
+    pld.ref_rate = flt(ref_rate)
+    pld.ref_currency = currency
+    pld.save()
+
+      
+  # Update Items
+  # ------------
+  def update_item(self):
+    i = Document("Item", self.doc.new_item_code)
+    
+    # update fields
+    i.brand = self.doc.new_item_brand
+    i.stock_uom = self.doc.stock_uom 
+    i.item_group = self.doc.item_group
+	
+    # clear old rates
+    sql("delete from `tabRef Rate Detail` where parent=%s", i.name)
+    
+    # update rates
+    new_rates = {}
+    # pl_list = self.get_price_lists()
+    #for p in self.get_price_lists():
+    self.update_ref_rate(i)
+
+    # update description and item name
+    n1, n2 = [], []
+    for d in getlist(self.doclist, "sales_bom_items"):
+      n, desc = sql("select item_name, description from tabItem where name=%s", d.item_code)[0]
+      n1.append(n)
+      n2.append(desc)
+    
+    self.doc.new_item_name = (' ').join(n1)
+    self.doc.description = ("\n" + "\n").join(n2)
+
+    i.item_name = self.doc.new_item_name
+    i.description = self.doc.description
+
+    # set default as 'No' or 0 in Item Master  as per TIC/3456
+    i.is_sample_item = 'No'
+    i.is_asset_item = 'No'
+    i.is_purchase_item = 'No'
+    i.is_manufactured_item = 'No'
+    i.is_sub_contracted_item = 'No'
+    i.is_service_item = 'No'
+    i.inspection_required = 'No'
+    i.has_serial_no = 'No'
+    i.lead_time_days = flt(0)
+    i.save()
+    msgprint("Items updated successfully.")
+
+
+  def validate(self):
+    # check for duplicate
+    self.check_duplicate()
+    item_code = self.get_main_item()
+    if not self.doc.new_item_code:
+      self.doc.new_item_code = make_autoname(item_code +'.###')
+
+ 
+  def on_update(self):
+    # if no item code, create new item code
+    if not sql("select name from tabItem where name=%s", self.doc.new_item_code):
+      self.create_new_item()
+    self.update_item()
+
+
+  def check_duplicate(self, finder=0):
+    il = getlist(self.doclist, "sales_bom_items")
+    if not il:
+      msgprint("Add atleast one item")
+      return
+    
+    # get all Sales BOM that have the first item  
+    sbl = sql("select distinct parent from `tabSales BOM Detail` where item_code=%s", il[0].item_code)
+    
+    # check all siblings
+    sub_items = [[d.item_code, flt(d.qty)] for d in il]
+    
+    for s in sbl:
+      if not cstr(s[0]) == cstr(self.doc.name) :
+        t = sql("select item_code, qty from `tabSales BOM Detail` where parent=%s", s[0])
+        t = [[d[0], flt(d[1])] for d in t]
+  
+        if self.has_same_items(sub_items, t):
+          msgprint("%s has the same Sales BOM details" % s[0])
+          raise Exception
+    if finder:
+      msgprint("There is no Sales BOM present with the following Combination.")
+
+
+  def has_same_items(self, l1, l2):
+    if len(l1)!=len(l2): return 0
+    for l in l2:
+      if l not in l1:
+        return 0
+    for l in l1:
+      if l not in l2:
+        return 0
+    return 1
\ No newline at end of file
diff --git a/stock/doctype/sales_bom/sales_bom.txt b/stock/doctype/sales_bom/sales_bom.txt
new file mode 100644
index 0000000..8863eb2
--- /dev/null
+++ b/stock/doctype/sales_bom/sales_bom.txt
@@ -0,0 +1,273 @@
+# DocType, Sales BOM
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'modified': '2010-12-23 11:43:34',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'allow_trash': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 37
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Sales BOM',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Sales BOM',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Sales BOM
+	{
+		'doctype': 'DocType',
+		'name': 'Sales BOM'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Sales User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'idx': 1,
+		'label': 'Trash Reason',
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'new_item_code',
+		'fieldtype': 'Data',
+		'idx': 2,
+		'label': 'New Item Code',
+		'no_copy': 1,
+		'oldfieldname': 'new_item_code',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'new_item_name',
+		'fieldtype': 'Data',
+		'idx': 3,
+		'label': 'New Item Name',
+		'oldfieldname': 'new_item_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'new_item_brand',
+		'fieldtype': 'Data',
+		'idx': 4,
+		'label': 'New Item Brand',
+		'oldfieldname': 'new_item_brand',
+		'oldfieldtype': 'Data',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 5,
+		'label': 'New Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 1,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_group',
+		'fieldtype': 'Link',
+		'idx': 7,
+		'label': 'Item Group',
+		'oldfieldname': 'item_group',
+		'oldfieldtype': 'Link',
+		'options': 'Item Group',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'price_list',
+		'fieldtype': 'Select',
+		'idx': 8,
+		'label': 'Price List',
+		'oldfieldname': 'price_list',
+		'oldfieldtype': 'Select',
+		'options': 'link:Price List',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'currency',
+		'fieldtype': 'Select',
+		'idx': 9,
+		'label': 'Currency',
+		'oldfieldname': 'currency',
+		'oldfieldtype': 'Select',
+		'options': 'link:Currency',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 10,
+		'label': 'Find Sales BOM',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sales_bom_items',
+		'fieldtype': 'Table',
+		'idx': 11,
+		'label': 'Sales BOM Items',
+		'oldfieldname': 'sales_bom_items',
+		'oldfieldtype': 'Table',
+		'options': 'Sales BOM Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Link',
+		'idx': 12,
+		'label': 'Stock UOM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 0
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/sales_bom_detail/__init__.py b/stock/doctype/sales_bom_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/sales_bom_detail/__init__.py
diff --git a/stock/doctype/sales_bom_detail/sales_bom_detail.txt b/stock/doctype/sales_bom_detail/sales_bom_detail.txt
new file mode 100644
index 0000000..31d2f1a
--- /dev/null
+++ b/stock/doctype/sales_bom_detail/sales_bom_detail.txt
@@ -0,0 +1,119 @@
+# DocType, Sales BOM Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:21',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 3
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Sales BOM Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# DocType, Sales BOM Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Sales BOM Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'is_main_item',
+		'fieldtype': 'Select',
+		'idx': 1,
+		'label': 'Is Main Item',
+		'oldfieldname': 'is_main_item',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 2,
+		'label': 'Item',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 3,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'rate',
+		'fieldtype': 'Currency',
+		'idx': 6,
+		'label': 'Rate',
+		'oldfieldname': 'rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Currency',
+		'idx': 9,
+		'label': 'Qty',
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'uom',
+		'fieldtype': 'Link',
+		'idx': 10,
+		'label': 'UOM',
+		'oldfieldname': 'uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/serial_no/__init__.py b/stock/doctype/serial_no/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/serial_no/__init__.py
diff --git a/stock/doctype/serial_no/serial_no.js b/stock/doctype/serial_no/serial_no.js
new file mode 100644
index 0000000..32620dd
--- /dev/null
+++ b/stock/doctype/serial_no/serial_no.js
@@ -0,0 +1,57 @@
+// ************************************** onload ****************************************************
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  if(!doc.status) set_multiple(cdt, cdn, {status:'In Store'});
+  if(doc.__islocal) hide_field(['supplier_name','address_display'])
+}
+
+
+// ************************************** refresh ***************************************************
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  if(!doc.__islocal && doc.warehouse) set_field_permlevel('warehouse', 1);
+  if(!doc.__islocal && doc.item_code) set_field_permlevel('item_code', 1);
+  if(doc.__islocal) set_field_permlevel('status', 0);
+}
+
+
+// ************************************** triggers **************************************************
+
+// -------------
+// item details
+// -------------
+cur_frm.add_fetch('item_code', 'item_name', 'item_name')
+cur_frm.add_fetch('item_code', 'item_group', 'item_group')
+cur_frm.add_fetch('item_code', 'brand', 'brand')
+cur_frm.add_fetch('item_code', 'description', 'description')
+cur_frm.add_fetch('item_code', 'warranty_period', 'warranty_period')
+
+
+// ---------
+// customer
+// ---------
+cur_frm.add_fetch('customer', 'customer_name', 'customer_name')
+cur_frm.add_fetch('customer', 'address', 'delivery_address')
+cur_frm.add_fetch('customer', 'territory', 'territory')
+
+
+// ---------
+// supplier
+// ---------
+//cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name')
+//cur_frm.add_fetch('customer', 'address', 'supplier_address')
+
+
+// ----------
+// 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';
+}
+
+// Supplier
+cur_frm.cscript.supplier = function(doc,dt,dn) {
+  if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1);
+  if(doc.supplier) unhide_field(['supplier_name','address_display']);
+}
+
+
+
diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py
new file mode 100644
index 0000000..9c99357
--- /dev/null
+++ b/stock/doctype/serial_no/serial_no.py
@@ -0,0 +1,127 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import cint, flt, cstr, getdate, nowdate
+import datetime
+
+sql = webnotes.conn.sql
+msgprint = webnotes.msgprint
+	
+# -----------------------------------------------------------------------------------------
+
+from utilities.transaction_base import TransactionBase
+
+class DocType(TransactionBase):
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+
+
+# ********************************* validate warranty / amc status ***************************************
+
+	# --------------------
+	# validate amc status
+	# --------------------
+	def validate_amc_status(self):
+		if self.doc.amc_expiry_date and getdate(self.doc.amc_expiry_date) >= datetime.date.today() and self.doc.maintenance_status == 'Out of AMC':
+			msgprint("AMC expiry date and maintenance status mismatch. Please verify")
+			raise Exception
+		elif (not self.doc.amc_expiry_date or getdate(self.doc.amc_expiry_date) < datetime.date.today()) and self.doc.maintenance_status == 'Under AMC':
+			msgprint("AMC expiry date and maintenance status mismatch. Please verify")
+			raise Exception
+
+
+	# -------------------------
+	# validate warranty status
+	# -------------------------
+	def validate_warranty_status(self):
+		if self.doc.warranty_expiry_date and getdate(self.doc.warranty_expiry_date) >= datetime.date.today() and self.doc.maintenance_status == 'Out of Warranty':
+			msgprint("Warranty expiry date and maintenance status mismatch. Please verify")
+			raise Exception
+		elif (not self.doc.warranty_expiry_date or getdate(self.doc.warranty_expiry_date) < datetime.date.today()) and self.doc.maintenance_status == 'Under Warranty':
+			msgprint("Warranty expiry date and maintenance status mismatch. Please verify")
+			raise Exception
+
+
+	# -------------------------------
+	# validate warranty / amc status
+	# -------------------------------
+	def validate_warranty_amc_status(self):
+		self.validate_warranty_status()
+		self.validate_amc_status()
+
+
+	def validate_warehouse(self):
+		if self.doc.status=='In Store' and not self.doc.warehouse:
+			msgprint("Warehouse is mandatory if this Serial No is <b>In Store</b>", raise_exception=1)
+
+	def validate_item(self):
+		item = sql("select name, has_serial_no from tabItem where name = '%s'" % self.doc.item_code)
+		if not item:
+			msgprint("Item is not exists in the system", raise_exception=1)
+		elif item[0][1] == 'No':
+			msgprint("To proceed please select 'Yes' in 'Has Serial No' in Item master: '%s'" % self.doc.item_code, raise_exception=1)
+			
+
+	# ---------
+	# validate
+	# ---------
+	def validate(self):
+		self.validate_warranty_amc_status()
+		self.validate_warehouse()
+		self.validate_item()
+
+
+	# ------------------------
+	# make stock ledger entry
+	# ------------------------
+	def make_stock_ledger_entry(self, update_stock):
+		from webnotes.model.code import get_obj
+		values = [{
+			'item_code'				: self.doc.item_code,
+			'warehouse'				: self.doc.warehouse,
+			'transaction_date'		: nowdate(),
+			'posting_date'			: self.doc.purchase_date or (self.doc.creation and self.doc.creation.split(' ')[0]) or nowdate(),
+			'posting_time'			: self.doc.purchase_time or '00:00',
+			'voucher_type'			: 'Serial No',
+			'voucher_no'			: self.doc.name,
+			'voucher_detail_no'	 	: '', 
+			'actual_qty'			: 1, 
+			'stock_uom'				: webnotes.conn.get_value('Item', self.doc.item_code, 'stock_uom'),
+			'incoming_rate'			: self.doc.purchase_rate,
+			'company'				: self.doc.company,
+			'fiscal_year'			: self.doc.fiscal_year,
+			'is_cancelled'			: update_stock and 'No' or 'Yes',
+			'batch_no'				: '',
+			'serial_no'				: self.doc.name
+		}]
+		get_obj('Stock Ledger', 'Stock Ledger').update_stock(values)
+
+
+	# ----------
+	# on update
+	# ----------
+	def on_update(self):
+		if self.doc.warehouse and not sql("select name from `tabStock Ledger Entry` where serial_no = '%s'" % (self.doc.name)) and self.doc.status == 'In Store':
+			self.make_stock_ledger_entry(update_stock = 1)
+
+
+	# ---------
+	# on trash
+	# ---------
+	def on_trash(self):
+		if self.doc.status == 'Delivered':
+			msgprint("Cannot trash Serial No : %s as it is already Delivered" % (self.doc.name), raise_exception = 1)
+		else:
+			webnotes.conn.set(self.doc, 'status', 'Not in Use')
+			self.make_stock_ledger_entry(update_stock = 0)
+
+
+	def on_cancel(self):
+		self.on_trash()
+
+	# -----------
+	# on restore
+	# -----------
+	def on_restore(self):
+		self.make_stock_ledger_entry(update_stock = 1)
diff --git a/stock/doctype/serial_no/serial_no.txt b/stock/doctype/serial_no/serial_no.txt
new file mode 100644
index 0000000..dd250ee
--- /dev/null
+++ b/stock/doctype/serial_no/serial_no.txt
@@ -0,0 +1,746 @@
+# DocType, Serial No
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:23',
+		'docstatus': 0,
+		'modified': '2011-05-17 12:38:15',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1305616095',
+		'allow_trash': 1,
+		'autoname': 'field:serial_no',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'module': 'Stock',
+		'name': '__common__',
+		'search_fields': 'item_code,status',
+		'section_style': 'Tabbed',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'subject': '%(item_code)s',
+		'tag_fields': 'status',
+		'version': 188
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Serial No',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Serial No',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Serial No
+	{
+		'doctype': 'DocType',
+		'name': 'Serial No'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 0,
+		'role': 'Material Master Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 1,
+		'role': 'System Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 1,
+		'role': 'Sales Master Manager'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 1,
+		'label': 'Details',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 2,
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'default': 'In Store',
+		'doctype': 'DocField',
+		'fieldname': 'status',
+		'fieldtype': 'Select',
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'Status',
+		'no_copy': 1,
+		'oldfieldname': 'status',
+		'oldfieldtype': 'Select',
+		'options': '\nIn Store\nDelivered\nNot in Use',
+		'permlevel': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Data',
+		'idx': 4,
+		'in_filter': 0,
+		'label': 'Serial No',
+		'no_copy': 1,
+		'oldfieldname': 'serial_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 6,
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'idx': 7,
+		'label': 'Item Name',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 1,
+		'reqd': 1,
+		'search_index': 0,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_group',
+		'fieldtype': 'Link',
+		'idx': 9,
+		'in_filter': 0,
+		'label': 'Item Group',
+		'oldfieldname': 'item_group',
+		'oldfieldtype': 'Link',
+		'options': 'Item Group',
+		'permlevel': 1,
+		'reqd': 0,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'brand',
+		'fieldtype': 'Link',
+		'idx': 10,
+		'in_filter': 0,
+		'label': 'Brand',
+		'oldfieldname': 'brand',
+		'oldfieldtype': 'Link',
+		'options': 'Brand',
+		'permlevel': 1,
+		'reqd': 0,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 11,
+		'label': 'Purchase Details',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 12,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_document_type',
+		'fieldtype': 'Select',
+		'idx': 13,
+		'label': 'Purchase Document Type',
+		'no_copy': 1,
+		'options': '\nPurchase Receipt\nStock Entry',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_document_no',
+		'fieldtype': 'Data',
+		'hidden': 0,
+		'idx': 14,
+		'label': 'Purchase Document No',
+		'no_copy': 1,
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_date',
+		'fieldtype': 'Date',
+		'idx': 15,
+		'in_filter': 1,
+		'label': 'Purchase Date',
+		'no_copy': 1,
+		'oldfieldname': 'purchase_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_time',
+		'fieldtype': 'Time',
+		'idx': 16,
+		'label': 'Incoming Time',
+		'no_copy': 1,
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'purchase_rate',
+		'fieldtype': 'Currency',
+		'idx': 17,
+		'in_filter': 0,
+		'label': 'Incoming Rate',
+		'no_copy': 1,
+		'oldfieldname': 'purchase_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 18,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse',
+		'fieldtype': 'Link',
+		'idx': 19,
+		'in_filter': 1,
+		'label': 'Warehouse',
+		'no_copy': 1,
+		'oldfieldname': 'warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'reqd': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier',
+		'fieldtype': 'Link',
+		'idx': 20,
+		'in_filter': 1,
+		'label': 'Supplier',
+		'no_copy': 1,
+		'options': 'Supplier',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier_name',
+		'fieldtype': 'Data',
+		'idx': 21,
+		'in_filter': 1,
+		'label': 'Supplier Name',
+		'no_copy': 1,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'address_display',
+		'fieldtype': 'Text',
+		'idx': 22,
+		'label': 'Supplier Address',
+		'no_copy': 1,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 23,
+		'label': 'Delivery Details',
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 24,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_document_type',
+		'fieldtype': 'Select',
+		'idx': 25,
+		'in_filter': 1,
+		'label': 'Delivery Document Type',
+		'no_copy': 1,
+		'options': '\nDelivery Note\nReceivable Voucher\nStock Entry',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_document_no',
+		'fieldtype': 'Data',
+		'idx': 26,
+		'in_filter': 1,
+		'label': 'Delivery Document No',
+		'no_copy': 1,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Text',
+		'idx': 27,
+		'label': 'Customer Address',
+		'oldfieldname': 'customer_address',
+		'oldfieldtype': 'Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_date',
+		'fieldtype': 'Date',
+		'idx': 28,
+		'label': 'Delivery Date',
+		'no_copy': 1,
+		'oldfieldname': 'delivery_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_time',
+		'fieldtype': 'Time',
+		'idx': 29,
+		'label': 'Delivery Time',
+		'no_copy': 1,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'is_cancelled',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'idx': 30,
+		'label': 'Is Cancelled',
+		'oldfieldname': 'is_cancelled',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 31,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'idx': 32,
+		'in_filter': 1,
+		'label': 'Customer',
+		'no_copy': 1,
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'permlevel': 1,
+		'print_hide': 1,
+		'search_index': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'idx': 33,
+		'in_filter': 1,
+		'label': 'Customer Name',
+		'no_copy': 1,
+		'oldfieldname': 'customer_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'delivery_address',
+		'fieldtype': 'Text',
+		'idx': 34,
+		'label': 'Delivery Address',
+		'no_copy': 1,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'territory',
+		'fieldtype': 'Link',
+		'idx': 35,
+		'in_filter': 1,
+		'label': 'Territory',
+		'no_copy': 1,
+		'oldfieldname': 'territory',
+		'oldfieldtype': 'Link',
+		'options': 'Territory',
+		'permlevel': 1,
+		'print_hide': 1,
+		'report_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 36,
+		'label': 'Warranty / AMC Details',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 37,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'maintenance_status',
+		'fieldtype': 'Select',
+		'idx': 38,
+		'in_filter': 1,
+		'label': 'Maintenance Status',
+		'no_copy': 0,
+		'oldfieldname': 'maintenance_status',
+		'oldfieldtype': 'Select',
+		'options': '\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC',
+		'permlevel': 0,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'warranty_period',
+		'fieldtype': 'Int',
+		'idx': 39,
+		'label': 'Warranty Period (Days)',
+		'oldfieldname': 'warranty_period',
+		'oldfieldtype': 'Int',
+		'permlevel': 0,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 40,
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warranty_expiry_date',
+		'fieldtype': 'Date',
+		'idx': 41,
+		'in_filter': 1,
+		'label': 'Warranty Expiry Date',
+		'oldfieldname': 'warranty_expiry_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amc_expiry_date',
+		'fieldtype': 'Date',
+		'idx': 42,
+		'in_filter': 1,
+		'label': 'AMC Expiry Date',
+		'oldfieldname': 'amc_expiry_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'search_index': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 43,
+		'label': 'More Info',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'serial_no_details',
+		'fieldtype': 'Text Editor',
+		'idx': 44,
+		'label': 'Serial No Details',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Select',
+		'idx': 45,
+		'in_filter': 1,
+		'label': 'Company',
+		'options': 'link:Company',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 46,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'options': 'link:Fiscal Year',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'idx': 47,
+		'label': 'Trash Reason',
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/stock_entry/__init__.py b/stock/doctype/stock_entry/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/stock_entry/__init__.py
diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js
new file mode 100644
index 0000000..161e094
--- /dev/null
+++ b/stock/doctype/stock_entry/stock_entry.js
@@ -0,0 +1,192 @@
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
+  if (!doc.transfer_date) doc.transfer_date = dateutil.obj_to_str(new Date());
+  cfn_set_fields(doc, cdt, cdn);
+}
+
+
+var cfn_set_fields = function(doc, cdt, cdn) {
+  lst = ['supplier','supplier_name','supplier_address','customer','customer_name','customer_address']; 
+  if (doc.purpose == 'Production Order'){
+    unhide_field(['production_order', 'process', 'Get Items']);
+    hide_field(['from_warehouse', 'to_warehouse','purchase_receipt_no','delivery_note_no', 'sales_invoice_no','Warehouse HTML']);
+    doc.from_warehouse = '';
+    doc.to_warehosue = '';
+    if (doc.process == 'Backflush'){
+      unhide_field('fg_completed_qty');
+    }
+    else{
+      hide_field('fg_completed_qty');
+      doc.fg_completed_qty = 0;
+    }
+  }
+  else{
+    unhide_field(['from_warehouse', 'to_warehouse']);
+    hide_field(['production_order', 'process', 'Get Items', 'fg_completed_qty','purchase_receipt_no','delivery_note_no', 'sales_invoice_no']);
+    hide_field(lst);
+    doc.production_order = '';
+    doc.process = '';
+    doc.fg_completed_qty = 0;
+  }
+  
+ 
+  if(doc.purpose == 'Purchase Return'){
+    doc.customer=doc.customer_name = doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no='';
+    hide_field(lst);
+    unhide_field(['supplier','supplier_name','supplier_address','purchase_receipt_no']);
+  }
+  if(doc.purpose == 'Sales Return'){
+    doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
+    hide_field(lst);
+    unhide_field(['customer','customer_name','customer_address','delivery_note_no', 'sales_invoice_no']);
+  } else{
+    doc.customer=doc.customer_name=doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no=doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
+  }
+  refresh_many(lst);
+}
+
+cur_frm.cscript.delivery_note_no = function(doc,cdt,cdn){
+  if(doc.delivery_note_no) get_server_fields('get_cust_values','','',doc,cdt,cdn,1);
+}
+
+cur_frm.cscript.sales_invoice_no = function(doc,cdt,cdn){
+  if(doc.sales_invoice_no) get_server_fields('get_cust_values','','',doc,cdt,cdn,1);
+}
+
+cur_frm.cscript.customer = function(doc,cdt,cdn){
+  if(doc.customer)  get_server_fields('get_cust_addr','','',doc,cdt,cdn,1);
+}
+
+cur_frm.cscript.purchase_receipt_no = function(doc,cdt,cdn){
+  if(doc.purchase_receipt_no)  get_server_fields('get_supp_values','','',doc,cdt,cdn,1);
+}
+
+cur_frm.cscript.supplier = function(doc,cdt,cdn){
+  if(doc.supplier)  get_server_fields('get_supp_addr','','',doc,cdt,cdn,1);
+
+}
+
+cur_frm.fields_dict['production_order'].get_query = function(doc) {
+   return 'SELECT DISTINCT `tabProduction Order`.`name` FROM `tabProduction Order` WHERE `tabProduction Order`.`docstatus` = 1 AND `tabProduction Order`.`qty` > ifnull(`tabProduction Order`.`produced_qty`,0) AND `tabProduction Order`.`name` like "%s" ORDER BY `tabProduction Order`.`name` DESC LIMIT 50';
+}
+
+cur_frm.cscript.purpose = function(doc, cdt, cdn) {
+  cfn_set_fields(doc, cdt, cdn);
+}
+
+
+cur_frm.cscript.process = function(doc, cdt, cdn) {
+  cfn_set_fields(doc, cdt, cdn);
+}
+
+//
+// item code - only if quantity present in source warehosue
+//
+var fld = cur_frm.fields_dict['mtn_details'].grid.get_field('item_code');
+fld.query_description = "If Source Warehouse is selected, only items present in the warehouse with actual qty > 0 will be selected"
+fld.get_query = function(doc, cdt, cdn) {
+	var d = locals[cdt][cdn];
+		
+	if(d.s_warehouse) {
+		return 'SELECT tabItem.name, tabItem.description, tabBin.actual_qty '
+		+'FROM tabItem, tabBin '
+		+'WHERE tabItem.name = tabBin.item_code '
+		+'AND ifnull(`tabBin`.`actual_qty`,0) > 0 '
+		+'AND tabBin.warehouse="'+ d.s_warehouse +'" '
+		+'AND tabItem.docstatus < 2 '
+		+'AND tabItem.%(key)s LIKE "%s" '
+		+'ORDER BY tabItem.name ASC '
+		+'LIMIT 50'
+	} else {
+		return 'SELECT tabItem.name, tabItem.description '
+		+'FROM tabItem '
+		+'WHERE tabItem.docstatus < 2 '
+		+'AND tabItem.%(key)s LIKE "%s" '
+		+'ORDER BY tabItem.name ASC '
+		+'LIMIT 50'
+	}
+}
+
+//
+// copy over source and target warehouses
+//
+cur_frm.fields_dict['mtn_details'].grid.onrowadd = function(doc, cdt, cdn){
+	var d = locals[cdt][cdn];
+	if(!d.s_warehouse && doc.from_warehouse) {
+		d.s_warehouse = doc.from_warehouse
+		refresh_field('s_warehouse', cdn, 'mtn_details')
+	}
+	if(!d.t_warehouse && doc.to_warehouse) {
+		d.t_warehouse = doc.to_warehouse
+		refresh_field('t_warehouse', cdn, 'mtn_details')
+	}
+}
+
+//========================= Overloaded query for link batch_no =============================================================
+cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query= function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(d.item_code){
+    return "SELECT tabBatch.name, tabBatch.description FROM tabBatch WHERE tabBatch.docstatus != 2 AND tabBatch.item = '"+ d.item_code +"' AND `tabBatch`.`name` like '%s' ORDER BY `tabBatch`.`name` DESC LIMIT 50"
+  }
+  else{
+    alert("Please enter Item Code.");
+  }
+}
+
+//==================================================================================================================
+
+cur_frm.cscript.item_code = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  // get values
+  args = {
+  	'item_code'		: d.item_code,
+  	'warehouse'		: cstr(d.s_warehouse),
+  	'transfer_qty'	: d.transfer_qty,
+  	'serial_no'		: d.serial_no
+  };
+  get_server_fields('get_item_details',JSON.stringify(args),'mtn_details',doc,cdt,cdn,1);
+}
+
+//==================================================================================================================
+
+cur_frm.cscript.transfer_qty = function(doc,cdt,cdn) {
+  var d = locals[cdt][cdn];
+  if (doc.from_warehouse && (flt(d.transfer_qty) > flt(d.actual_qty))) {
+    alert("Transfer Quantity is more than Available Qty");
+  }
+}
+
+
+//==================================================================================================================
+
+cur_frm.cscript.qty = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  set_multiple('Stock Entry Detail', d.name, {'transfer_qty': flt(d.qty) * flt(d.conversion_factor)}, 'mtn_details');
+  refresh_field('mtn_details');
+}
+
+//==================================================================================================================
+
+cur_frm.cscript.uom = function(doc, cdt, cdn) {
+  var d = locals[cdt][cdn];
+  if(d.uom && d.item_code){
+    var arg = {'item_code':d.item_code, 'uom':d.uom, 'qty':d.qty}
+    get_server_fields('get_uom_details',JSON.stringify(arg),'mtn_details', doc, cdt, cdn, 1);
+  }
+}
+
+//==================================================================================================================
+//validate
+cur_frm.cscript.validate = function(doc, cdt, cdn) {
+  cur_frm.cscript.validate_items(doc);
+}
+
+//==================================================================================================================
+//validate items
+cur_frm.cscript.validate_items = function(doc) {
+  cl =  getchildren('Stock Entry Detail',doc.name,'mtn_details');
+  if (!cl.length) {
+    alert("Item table can not be blank");
+    validated = false;
+  }
+}
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
new file mode 100644
index 0000000..a07f769
--- /dev/null
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -0,0 +1,426 @@
+# 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, delete_doc
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		self.item_dict = {}
+		self.fname = 'mtn_details' 
+
+	# Autoname
+	# ---------
+	def autoname(self):
+		self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+
+  
+	# get item details
+	# ----------------
+	def get_item_details(self, arg):
+		arg, actual_qty, in_rate = eval(arg), 0, 0
+
+		item = sql("select stock_uom, description, item_name from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00' or end_of_life >	now())", (arg.get('item_code')), as_dict = 1)
+		if not item: 
+			msgprint("Item is not active", raise_exception=1)
+			
+		if arg.get('warehouse'):
+			actual_qty = self.get_as_on_stock(arg.get('item_code'), arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time)
+			in_rate = self.get_incoming_rate(arg.get('item_code'), arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time, arg.get('transfer_qty'), arg.get('serial_no')) or 0
+			
+		ret = {
+			'uom'			      	: item and item[0]['stock_uom'] or '',
+			'stock_uom'			  	: item and item[0]['stock_uom'] or '',
+			'description'		  	: item and item[0]['description'] or '',
+			'item_name' 		  	: item and item[0]['item_name'] or '',
+			'actual_qty'		  	: actual_qty,
+			'qty'					: 0,
+			'transfer_qty'			: 0,
+			'incoming_rate'	  		: in_rate,
+			'conversion_factor'		: 1,
+     		'batch_no'          	: ''
+		}
+		return str(ret)
+
+
+	# Get UOM Details
+	# ----------------
+	def get_uom_details(self, arg = ''):
+		arg, ret = eval(arg), {}
+		uom = sql("select conversion_factor from `tabUOM Conversion Detail` where parent = %s and uom = %s", (arg['item_code'],arg['uom']), as_dict = 1)
+		if not uom:
+			msgprint("There is no Conversion Factor for UOM '%s' in Item '%s'" % (arg['uom'], arg['item_code']))
+			ret = {'uom' : ''}
+		else:
+			ret = {
+				'conversion_factor'		: flt(uom[0]['conversion_factor']),
+				'transfer_qty'			: flt(arg['qty']) * flt(uom[0]['conversion_factor']),
+			}
+		return str(ret)
+
+		
+	# get stock and incoming rate on posting date
+	# ---------------------------------------------
+	def get_stock_and_rate(self, bom_no = ''):
+		for d in getlist(self.doclist, 'mtn_details'):
+			# assign parent warehouse
+			d.s_warehouse = cstr(d.s_warehouse) or self.doc.purpose != 'Production Order' and self.doc.from_warehouse or ''
+			d.t_warehouse = cstr(d.t_warehouse) or self.doc.purpose != 'Production Order' and self.doc.to_warehouse or ''
+			
+			# get current stock at source warehouse
+			d.actual_qty = d.s_warehouse and self.get_as_on_stock(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time) or 0
+
+			# get incoming rate
+			if not flt(d.incoming_rate):
+				d.incoming_rate = self.get_incoming_rate(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time, d.transfer_qty, d.serial_no, d.fg_item, bom_no)
+			
+	# Get stock qty on any date
+	# ---------------------------
+	def get_as_on_stock(self, item, wh, dt, tm):
+		bin = sql("select name from tabBin where item_code = %s and warehouse = %s", (item, wh))
+		bin_id = bin and bin[0][0] or ''
+		prev_sle = get_obj('Bin', bin_id).get_prev_sle(dt, tm)
+		qty = flt(prev_sle.get('bin_aqat', 0))
+		return qty
+
+	# Get incoming rate
+	# -------------------
+	def get_incoming_rate(self, item, wh, dt, tm, qty = 0, serial_no = '', fg_item = 'No', bom_no = ''):
+		in_rate = 0
+		if fg_item == 'Yes':
+			# re-calculate cost for production item from bom
+			get_obj('BOM Control').calculate_cost(bom_no)
+			in_rate = get_value('Bill Of Materials', bom_no, 'cost_as_per_mar')
+		elif wh:
+			in_rate = get_obj('Valuation Control').get_incoming_rate(dt, tm, item, wh, qty, serial_no)
+		
+		return in_rate
+
+	# makes dict of unique items with it's qty
+	#-----------------------------------------
+	def make_items_dict(self, items_list):
+		# items_list = [[item_name, qty]]
+		for i in items_list:
+			if self.item_dict.has_key(i[0]):
+				self.item_dict[i[0]][0] = flt(self.item_dict[i[0]][0]) + flt(i[1])
+			else:
+				self.item_dict[i[0]] = [flt(i[1]), cstr(i[2]), cstr(i[3])]
+				
+	def get_raw_materials(self,pro_obj):
+		# get all items from flat bom except, child items of sub-contracted and sub assembly items and sub assembly items itself.
+		flat_bom_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom	from `tabFlat BOM Detail` where parent = '%s' and parent_bom = '%s' and is_pro_applicable = 'No' and docstatus < 2 group by item_code" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no)))
+		self.make_items_dict(flat_bom_items)
+		if pro_obj.doc.consider_sa_items == 'Yes':
+			# get all Sub Assembly items only from flat bom
+			fl_bom_sa_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom from `tabFlat BOM Detail` where parent = '%s' and parent_bom != '%s' and is_pro_applicable = 'Yes' and docstatus < 2 group by item_code" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no)))
+			self.make_items_dict(fl_bom_sa_items)
+		
+		if pro_obj.doc.consider_sa_items == 'No':
+			# get all sub assembly childs only from flat bom
+			fl_bom_sa_child_item = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom from `tabFlat BOM Detail` where parent = '%s' and parent_bom in (select distinct parent_bom from `tabFlat BOM Detail` where parent = '%s' and parent_bom != '%s' and is_pro_applicable = 'Yes' and docstatus < 2 ) and is_pro_applicable = 'No' and docstatus < 2 group by item_code" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no)))
+			self.make_items_dict(fl_bom_sa_child_item)
+
+	def add_to_stock_entry_detail(self, pro_obj, item_dict, fg_item = 0):
+		sw, tw = '', ''
+		if self.doc.process == 'Material Transfer':
+			tw = cstr(pro_obj.doc.wip_warehouse)
+		if self.doc.process == 'Backflush':
+			tw = fg_item and cstr(pro_obj.doc.fg_warehouse) or ''
+			if not fg_item: sw = cstr(pro_obj.doc.wip_warehouse)
+		for d in item_dict:
+			se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
+			se_child.s_warehouse = sw
+			se_child.t_warehouse = tw
+			se_child.fg_item	= fg_item
+			se_child.item_code = cstr(d)
+			se_child.description = item_dict[d][1]
+			se_child.uom = item_dict[d][2]
+			se_child.stock_uom = item_dict[d][2]
+			se_child.reqd_qty = flt(item_dict[d][0])
+			se_child.qty = flt(item_dict[d][0])
+			se_child.transfer_qty = flt(item_dict[d][0])
+			se_child.conversion_factor = 1.00
+
+	
+	# get items 
+	#------------------
+	def get_items(self):
+		pro_obj = self.doc.production_order and get_obj('Production Order', self.doc.production_order) or ''
+		
+		self.validate_for_production_order(pro_obj)
+		self.get_raw_materials(pro_obj)
+		
+		self.doc.clear_table(self.doclist, 'mtn_details', 1)
+		
+		self.add_to_stock_entry_detail(pro_obj, self.item_dict)
+		if self.doc.process == 'Backflush':
+			item_dict = {cstr(pro_obj.doc.production_item) : [self.doc.fg_completed_qty, pro_obj.doc.description, pro_obj.doc.stock_uom]}
+			self.add_to_stock_entry_detail(pro_obj, item_dict, fg_item = 1)
+
+	def validate_transfer_qty(self):
+		for d in getlist(self.doclist, 'mtn_details'):
+			if flt(d.transfer_qty) <= 0:
+				msgprint("Transfer Quantity can not be less than or equal to zero at Row No " + cstr(d.idx))
+				raise Exception
+			if d.s_warehouse:
+				if flt(d.transfer_qty) > flt(d.actual_qty):
+					msgprint("Transfer Quantity is more than Available Qty at Row No " + cstr(d.idx))
+					raise Exception
+	
+	def calc_amount(self):
+		total_amount = 0
+		for d in getlist(self.doclist, 'mtn_details'):
+			d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
+			total_amount += flt(d.amount)
+		self.doc.total_amount = flt(total_amount)
+
+	def add_to_values(self, d, wh, qty, is_cancelled):
+		self.values.append({
+				'item_code'			    : d.item_code,
+				'warehouse'			    : wh,
+				'transaction_date'	: self.doc.transfer_date,
+				'posting_date'		  : self.doc.posting_date,
+				'posting_time'		  : self.doc.posting_time,
+				'voucher_type'		  : 'Stock Entry',
+				'voucher_no'		    : self.doc.name, 
+				'voucher_detail_no'	: d.name,
+				'actual_qty'		    : qty,
+				'incoming_rate'		  : flt(d.incoming_rate) or 0,
+				'stock_uom'			    : d.stock_uom,
+				'company'			      : self.doc.company,
+				'fiscal_year'		    : self.doc.fiscal_year,
+				'is_cancelled'		  : (is_cancelled ==1) and 'Yes' or 'No',
+				'batch_no'			    : d.batch_no,
+        'serial_no'         : d.serial_no
+		})
+
+	
+	def update_stock_ledger(self, is_cancelled=0):
+		self.values = []			
+		for d in getlist(self.doclist, 'mtn_details'):
+			if cstr(d.s_warehouse):
+				self.add_to_values(d, cstr(d.s_warehouse), -flt(d.transfer_qty), is_cancelled)
+			if cstr(d.t_warehouse):
+				self.add_to_values(d, cstr(d.t_warehouse), flt(d.transfer_qty), is_cancelled)
+		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
+
+	
+	def validate_for_production_order(self, pro_obj):
+		if self.doc.purpose == 'Production Order' or self.doc.process or self.doc.production_order or flt(self.doc.fg_completed_qty):
+			if self.doc.purpose != 'Production Order':
+				msgprint("Purpose should be 'Production Order'.")
+				raise Exception
+			if not self.doc.process:
+				msgprint("Process Field is mandatory.")
+				raise Exception
+			if self.doc.process == 'Backflush' and not flt(self.doc.fg_completed_qty):
+				msgprint("FG Completed Qty is mandatory as the process selected is 'Backflush'")
+				raise Exception
+			if self.doc.process == 'Material Transfer' and flt(self.doc.fg_completed_qty):
+				msgprint("FG Completed Qty should be zero. As the Process selected is 'Material Transfer'.")
+				raise Exception
+			if not self.doc.production_order:
+				msgprint("Production Order field is mandatory")
+				raise Exception
+			if flt(pro_obj.doc.qty) < flt(pro_obj.doc.produced_qty) + flt(self.doc.fg_completed_qty) :
+				msgprint("error:Already Produced Qty for %s is %s and maximum allowed Qty is %s" % (pro_obj.doc.production_item, cstr(pro_obj.doc.produced_qty) or 0.00 , cstr(pro_obj.doc.qty)))
+				raise Exception
+	
+	# Validate
+	# ------------------
+	def validate(self):
+		sl_obj = get_obj("Stock Ledger", "Stock Ledger")
+		sl_obj.scrub_serial_nos(self)
+		sl_obj.validate_serial_no(self, 'mtn_details')
+		pro_obj = ''
+		if self.doc.production_order:
+			pro_obj = get_obj('Production Order', self.doc.production_order)
+		self.validate_for_production_order(pro_obj)
+		self.validate_incoming_rate()
+		self.validate_warehouse(pro_obj)
+		self.get_stock_and_rate(pro_obj and pro_obj.doc.bom_no or '')
+		self.calc_amount()
+		get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
+				
+	# If target warehouse exists, incoming rate is mandatory
+	# --------------------------------------------------------
+	def validate_incoming_rate(self):
+		for d in getlist(self.doclist, 'mtn_details'):
+			if not flt(d.incoming_rate) and d.t_warehouse:
+				msgprint("Rate is mandatory for Item: %s at row %s" % (d.item_code, d.idx), raise_exception=1)
+
+	# Validate warehouse
+	# -----------------------------------
+	def validate_warehouse(self, pro_obj):
+		fg_qty = 0
+		for d in getlist(self.doclist, 'mtn_details'):
+			if not d.s_warehouse and not d.t_warehouse:
+				d.s_warehouse = self.doc.from_warehouse
+				d.t_warehouse = self.doc.to_warehouse
+
+			if not (d.s_warehouse or d.t_warehouse):
+				msgprint("Atleast one warehouse is mandatory for Stock Entry ")
+				raise Exception
+			if d.s_warehouse and not sql("select name from tabWarehouse where name = '%s'" % d.s_warehouse):
+				msgprint("Invalid Warehouse: %s" % self.doc.s_warehouse)
+				raise Exception
+			if d.t_warehouse and not sql("select name from tabWarehouse where name = '%s'" % d.t_warehouse):
+				msgprint("Invalid Warehouse: %s" % self.doc.t_warehouse)
+				raise Exception
+			if d.s_warehouse == d.t_warehouse:
+				msgprint("Source and Target Warehouse Cannot be Same.")
+				raise Exception
+			if self.doc.purpose == 'Material Issue':
+				if not cstr(d.s_warehouse):
+					msgprint("Source Warehouse is Mandatory for Purpose => 'Material Issue'")
+					raise Exception
+				if cstr(d.t_warehouse):
+					msgprint("Target Warehouse is not Required for Purpose => 'Material Issue'")
+					raise Exception
+			if self.doc.purpose == 'Material Transfer':
+				if not cstr(d.s_warehouse) or not cstr(d.t_warehouse):
+					msgprint("Source Warehouse and Target Warehouse both are Mandatory for Purpose => 'Material Transfer'")
+					raise Exception
+			if self.doc.purpose == 'Material Receipt':
+				if not cstr(d.t_warehouse):
+					msgprint("Target Warehouse is Mandatory for Purpose => 'Material Receipt'")
+					raise Exception
+				if cstr(d.s_warehouse):
+					msgprint("Source Warehouse is not Required for Purpose => 'Material Receipt'")
+					raise Exception
+			if self.doc.process == 'Material Transfer':
+				if cstr(d.t_warehouse) != (pro_obj.doc.wip_warehouse):
+					msgprint(" Target Warehouse should be same as WIP Warehouse %s in Production Order %s at Row No %s" % (cstr(pro_obj.doc.wip_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)) )
+					raise Exception
+				if not cstr(d.s_warehouse):
+					msgprint("Please Enter Source Warehouse at Row No %s is mandatory." % (cstr(d.idx)))
+					raise Exception
+			if self.doc.process == 'Backflush':
+				if flt(d.fg_item):
+					if cstr(pro_obj.doc.production_item) != cstr(d.item_code):
+						msgprint("Item %s in Stock Entry Detail as Row No %s do not match with Item %s in Production Order %s" % (cstr(d.item_code), cstr(d.idx), cstr(pro_obj.doc.production_item), cstr(pro_obj.doc.name)))
+						raise Exception
+					fg_qty = flt(fg_qty) + flt(d.transfer_qty)
+					if cstr(d.t_warehouse) != cstr(pro_obj.doc.fg_warehouse):
+						msgprint("As Item %s is FG Item. Target Warehouse should be same as FG Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.fg_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
+						raise Exception
+					if cstr(d.s_warehouse):
+						msgprint("As Item %s is a FG Item. There should be no Source Warehouse at Row No %s" % (cstr(d.item_code), cstr(d.idx)))
+						raise Exception
+				if not flt(d.fg_item):
+					if cstr(d.t_warehouse):
+						msgprint("As Item %s is not a FG Item. There should no Tareget Warehouse at Row No %s" % (cstr(d.item_code), cstr(d.idx)))
+						raise Exception
+					if cstr(d.s_warehouse) != cstr(pro_obj.doc.wip_warehouse):
+						msgprint("As Item %s is Raw Material. Source Warehouse should be same as WIP Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.wip_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
+						raise Exception
+			d.save()
+		if self.doc.fg_completed_qty and flt(self.doc.fg_completed_qty) != flt(fg_qty):
+			msgprint("The Total of FG Qty %s in Stock Entry Detail do not match with FG Completed Qty %s" % (flt(fg_qty), flt(self.doc.fg_completed_qty)))
+			raise Exception
+
+	def update_production_order(self, is_submit):
+		if self.doc.production_order:
+			pro_obj = get_obj("Production Order", self.doc.production_order)
+			if flt(pro_obj.doc.docstatus) != 1:
+				msgprint("One cannot do any transaction against Production Order : %s, as it's not submitted" % (pro_obj.doc.name))
+				raise Exception
+			if pro_obj.doc.status == 'Stopped':
+				msgprint("One cannot do any transaction against Production Order : %s, as it's status is 'Stopped'" % (pro_obj.doc.name))
+				raise Exception
+			if getdate(pro_obj.doc.posting_date) > getdate(self.doc.posting_date):
+				msgprint("Posting Date of Stock Entry cannot be before Posting Date of Production Order "+ cstr(self.doc.production_order))
+				raise Exception
+			if self.doc.process == 'Backflush':
+				pro_obj.doc.produced_qty = flt(pro_obj.doc.produced_qty) + (is_submit and 1 or -1 ) * flt(self.doc.fg_completed_qty)
+				get_obj('Warehouse',	pro_obj.doc.fg_warehouse).update_bin(0, 0, 0, 0, (is_submit and 1 or -1 ) *	flt(self.doc.fg_completed_qty), pro_obj.doc.production_item, now())
+			pro_obj.doc.status = (flt(pro_obj.doc.qty) == flt(pro_obj.doc.produced_qty)) and	'Completed' or 'In Process'
+			pro_obj.doc.save()
+	
+	# Create / Update Serial No
+	# ----------------------------------
+	def update_serial_no(self, is_submit):
+		sl_obj = get_obj('Stock Ledger')
+		for d in getlist(self.doclist, 'mtn_details'):
+			if d.serial_no:
+				serial_nos = sl_obj.get_sr_no_list(d.serial_no)
+				for x in serial_nos:
+					serial_no = x.strip()
+					if d.s_warehouse:
+						sl_obj.update_serial_delivery_details(self, d, serial_no, is_submit)
+					if d.t_warehouse:
+						sl_obj.update_serial_purchase_details(self, d, serial_no, is_submit, (self.doc.purpose in ['Material Transfer', 'Sales Return']) and 1 or 0)
+					
+					if self.doc.purpose == 'Purchase Return':
+						delete_doc("Serial No", serial_no)
+
+	# On Submit
+	# ------------------
+	def on_submit(self):
+		self.validate_transfer_qty()
+		# Check for Approving Authority
+		get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.total_amount)
+		self.update_serial_no(1)
+		self.update_stock_ledger(0)
+		# update Production Order
+		self.update_production_order(1)
+
+	# On Cancel
+	# -------------------
+	def on_cancel(self):
+		self.update_serial_no(0)
+		self.update_stock_ledger(1)
+		# update Production Order
+		self.update_production_order(0)
+		
+	def get_cust_values(self):
+		tbl = self.doc.delivery_note_no and 'Delivery Note' or 'Receivable Voucher'
+		record_name = self.doc.delivery_note_no or self.doc.sales_invoice_no
+		res = sql("select customer,customer_name, customer_address from `tab%s` where name = '%s'" % (tbl, record_name))
+		ret = {
+			'customer'				 : res and res[0][0] or '',
+			'customer_name'		: res and res[0][1] or '',
+			'customer_address' : res and res[0][2] or ''}
+
+		return str(ret)
+
+
+	def get_cust_addr(self):
+		res = sql("select customer_name,address from `tabCustomer` where name = '%s'"%self.doc.customer)
+		ret = { 
+			'customer_name'		: res and res[0][0] or '',
+			'customer_address' : res and res[0][1] or ''}
+
+		return str(ret)
+
+
+		
+	def get_supp_values(self):
+		res = sql("select supplier,supplier_name,supplier_address from `tabPurchase Receipt` where name = '%s'"%self.doc.purchase_receipt_no)
+		ret = {
+			'supplier' : res and res[0][0] or '',
+			'supplier_name' :res and res[0][1] or '',
+			'supplier_address' : res and res[0][2] or ''}
+		return str(ret)
+		
+
+	def get_supp_addr(self):
+		res = sql("select supplier_name,address from `tabSupplier` where name = '%s'"%self.doc.supplier)
+		ret = {
+			'supplier_name' : res and res[0][0] or '',
+			'supplier_address' : res and res[0][1] or ''}
+		return str(ret)
diff --git a/stock/doctype/stock_entry/stock_entry.py~ b/stock/doctype/stock_entry/stock_entry.py~
new file mode 100644
index 0000000..e90cdce
--- /dev/null
+++ b/stock/doctype/stock_entry/stock_entry.py~
@@ -0,0 +1,429 @@
+# 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, delete_doc
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		self.item_dict = {}
+		self.fname = 'mtn_details' 
+
+	# Autoname
+	# ---------
+	def autoname(self):
+		self.doc.name = make_autoname(self.doc.naming_series+'.#####')
+
+  
+	# get item details
+	# ----------------
+	def get_item_details(self, arg):
+		arg, actual_qty, in_rate = eval(arg), 0, 0
+
+		item = sql("select stock_uom, description, item_name from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00' or end_of_life >	now())", (arg.get('item_code')), as_dict = 1)
+		if not item: 
+			msgprint("Item is not active", raise_exception=1)
+			
+		if arg.get('warehouse'):
+			actual_qty = self.get_as_on_stock(arg.get('item_code'), arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time)
+			in_rate = self.get_incoming_rate(arg.get('item_code'), arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time, arg.get('transfer_qty'), arg.get('serial_no')) or 0
+			
+		ret = {
+			'uom'			      	: item and item[0]['stock_uom'] or '',
+			'stock_uom'			  	: item and item[0]['stock_uom'] or '',
+			'description'		  	: item and item[0]['description'] or '',
+			'item_name' 		  	: item and item[0]['item_name'] or '',
+			'actual_qty'		  	: actual_qty,
+			'qty'					: 0,
+			'transfer_qty'			: 0,
+			'incoming_rate'	  		: in_rate,
+			'conversion_factor'		: 1,
+     		'batch_no'          	: ''
+		}
+		return str(ret)
+
+
+	# Get UOM Details
+	# ----------------
+	def get_uom_details(self, arg = ''):
+		arg, ret = eval(arg), {}
+		uom = sql("select conversion_factor from `tabUOM Conversion Detail` where parent = %s and uom = %s", (arg['item_code'],arg['uom']), as_dict = 1)
+		if not uom:
+			msgprint("There is no Conversion Factor for UOM '%s' in Item '%s'" % (arg['uom'], arg['item_code']))
+			ret = {'uom' : ''}
+		else:
+			ret = {
+				'conversion_factor'		: flt(uom[0]['conversion_factor']),
+				'transfer_qty'			: flt(arg['qty']) * flt(uom[0]['conversion_factor']),
+			}
+		return str(ret)
+
+		
+	# get stock and incoming rate on posting date
+	# ---------------------------------------------
+	def get_stock_and_rate(self, bom_no = ''):
+		for d in getlist(self.doclist, 'mtn_details'):
+			# assign parent warehouse
+			d.s_warehouse = cstr(d.s_warehouse) or self.doc.purpose != 'Production Order' and self.doc.from_warehouse or ''
+			d.t_warehouse = cstr(d.t_warehouse) or self.doc.purpose != 'Production Order' and self.doc.to_warehouse or ''
+			
+			# get current stock at source warehouse
+			d.actual_qty = d.s_warehouse and self.get_as_on_stock(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time) or 0
+
+			# get incoming rate
+			if not flt(d.incoming_rate):
+				msgprint(1)
+				d.incoming_rate = self.get_incoming_rate(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time, d.transfer_qty, d.serial_no, d.fg_item, bom_no)
+			
+	# Get stock qty on any date
+	# ---------------------------
+	def get_as_on_stock(self, item, wh, dt, tm):
+		bin = sql("select name from tabBin where item_code = %s and warehouse = %s", (item, wh))
+		bin_id = bin and bin[0][0] or ''
+		prev_sle = get_obj('Bin', bin_id).get_prev_sle(dt, tm)
+		qty = flt(prev_sle.get('bin_aqat', 0))
+		return qty
+
+	# Get incoming rate
+	# -------------------
+	def get_incoming_rate(self, item, wh, dt, tm, qty = 0, serial_no = '', fg_item = 'No', bom_no = ''):
+		msgprint(wh)
+		in_rate = 0
+		if fg_item == 'Yes':
+			# re-calculate cost for production item from bom
+			get_obj('BOM Control').calculate_cost(bom_no)
+			in_rate = get_value('Bill Of Materials', bom_no, 'cost_as_per_mar')
+		elif wh:
+			msgprint(1)
+			in_rate = get_obj('Valuation Control').get_incoming_rate(dt, tm, item, wh, qty, serial_no)
+		
+		return in_rate
+
+	# makes dict of unique items with it's qty
+	#-----------------------------------------
+	def make_items_dict(self, items_list):
+		# items_list = [[item_name, qty]]
+		for i in items_list:
+			if self.item_dict.has_key(i[0]):
+				self.item_dict[i[0]][0] = flt(self.item_dict[i[0]][0]) + flt(i[1])
+			else:
+				self.item_dict[i[0]] = [flt(i[1]), cstr(i[2]), cstr(i[3])]
+				
+	def get_raw_materials(self,pro_obj):
+		# get all items from flat bom except, child items of sub-contracted and sub assembly items and sub assembly items itself.
+		flat_bom_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom	from `tabFlat BOM Detail` where parent = '%s' and parent_bom = '%s' and is_pro_applicable = 'No' and docstatus < 2 group by item_code" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no)))
+		self.make_items_dict(flat_bom_items)
+		if pro_obj.doc.consider_sa_items == 'Yes':
+			# get all Sub Assembly items only from flat bom
+			fl_bom_sa_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom from `tabFlat BOM Detail` where parent = '%s' and parent_bom != '%s' and is_pro_applicable = 'Yes' and docstatus < 2 group by item_code" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no)))
+			self.make_items_dict(fl_bom_sa_items)
+		
+		if pro_obj.doc.consider_sa_items == 'No':
+			# get all sub assembly childs only from flat bom
+			fl_bom_sa_child_item = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom from `tabFlat BOM Detail` where parent = '%s' and parent_bom in (select distinct parent_bom from `tabFlat BOM Detail` where parent = '%s' and parent_bom != '%s' and is_pro_applicable = 'Yes' and docstatus < 2 ) and is_pro_applicable = 'No' and docstatus < 2 group by item_code" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no), cstr(pro_obj.doc.bom_no)))
+			self.make_items_dict(fl_bom_sa_child_item)
+
+	def add_to_stock_entry_detail(self, pro_obj, item_dict, fg_item = 0):
+		sw, tw = '', ''
+		if self.doc.process == 'Material Transfer':
+			tw = cstr(pro_obj.doc.wip_warehouse)
+		if self.doc.process == 'Backflush':
+			tw = fg_item and cstr(pro_obj.doc.fg_warehouse) or ''
+			if not fg_item: sw = cstr(pro_obj.doc.wip_warehouse)
+		for d in item_dict:
+			se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
+			se_child.s_warehouse = sw
+			se_child.t_warehouse = tw
+			se_child.fg_item	= fg_item
+			se_child.item_code = cstr(d)
+			se_child.description = item_dict[d][1]
+			se_child.uom = item_dict[d][2]
+			se_child.stock_uom = item_dict[d][2]
+			se_child.reqd_qty = flt(item_dict[d][0])
+			se_child.qty = flt(item_dict[d][0])
+			se_child.transfer_qty = flt(item_dict[d][0])
+			se_child.conversion_factor = 1.00
+
+	
+	# get items 
+	#------------------
+	def get_items(self):
+		pro_obj = self.doc.production_order and get_obj('Production Order', self.doc.production_order) or ''
+		
+		self.validate_for_production_order(pro_obj)
+		self.get_raw_materials(pro_obj)
+		
+		self.doc.clear_table(self.doclist, 'mtn_details', 1)
+		
+		self.add_to_stock_entry_detail(pro_obj, self.item_dict)
+		if self.doc.process == 'Backflush':
+			item_dict = {cstr(pro_obj.doc.production_item) : [self.doc.fg_completed_qty, pro_obj.doc.description, pro_obj.doc.stock_uom]}
+			self.add_to_stock_entry_detail(pro_obj, item_dict, fg_item = 1)
+
+	def validate_transfer_qty(self):
+		for d in getlist(self.doclist, 'mtn_details'):
+			if flt(d.transfer_qty) <= 0:
+				msgprint("Transfer Quantity can not be less than or equal to zero at Row No " + cstr(d.idx))
+				raise Exception
+			if d.s_warehouse:
+				if flt(d.transfer_qty) > flt(d.actual_qty):
+					msgprint("Transfer Quantity is more than Available Qty at Row No " + cstr(d.idx))
+					raise Exception
+	
+	def calc_amount(self):
+		total_amount = 0
+		for d in getlist(self.doclist, 'mtn_details'):
+			d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
+			total_amount += flt(d.amount)
+		self.doc.total_amount = flt(total_amount)
+
+	def add_to_values(self, d, wh, qty, is_cancelled):
+		self.values.append({
+				'item_code'			    : d.item_code,
+				'warehouse'			    : wh,
+				'transaction_date'	: self.doc.transfer_date,
+				'posting_date'		  : self.doc.posting_date,
+				'posting_time'		  : self.doc.posting_time,
+				'voucher_type'		  : 'Stock Entry',
+				'voucher_no'		    : self.doc.name, 
+				'voucher_detail_no'	: d.name,
+				'actual_qty'		    : qty,
+				'incoming_rate'		  : flt(d.incoming_rate) or 0,
+				'stock_uom'			    : d.stock_uom,
+				'company'			      : self.doc.company,
+				'fiscal_year'		    : self.doc.fiscal_year,
+				'is_cancelled'		  : (is_cancelled ==1) and 'Yes' or 'No',
+				'batch_no'			    : d.batch_no,
+        'serial_no'         : d.serial_no
+		})
+
+	
+	def update_stock_ledger(self, is_cancelled=0):
+		self.values = []			
+		for d in getlist(self.doclist, 'mtn_details'):
+			if cstr(d.s_warehouse):
+				self.add_to_values(d, cstr(d.s_warehouse), -flt(d.transfer_qty), is_cancelled)
+			if cstr(d.t_warehouse):
+				self.add_to_values(d, cstr(d.t_warehouse), flt(d.transfer_qty), is_cancelled)
+		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
+
+	
+	def validate_for_production_order(self, pro_obj):
+		if self.doc.purpose == 'Production Order' or self.doc.process or self.doc.production_order or flt(self.doc.fg_completed_qty):
+			if self.doc.purpose != 'Production Order':
+				msgprint("Purpose should be 'Production Order'.")
+				raise Exception
+			if not self.doc.process:
+				msgprint("Process Field is mandatory.")
+				raise Exception
+			if self.doc.process == 'Backflush' and not flt(self.doc.fg_completed_qty):
+				msgprint("FG Completed Qty is mandatory as the process selected is 'Backflush'")
+				raise Exception
+			if self.doc.process == 'Material Transfer' and flt(self.doc.fg_completed_qty):
+				msgprint("FG Completed Qty should be zero. As the Process selected is 'Material Transfer'.")
+				raise Exception
+			if not self.doc.production_order:
+				msgprint("Production Order field is mandatory")
+				raise Exception
+			if flt(pro_obj.doc.qty) < flt(pro_obj.doc.produced_qty) + flt(self.doc.fg_completed_qty) :
+				msgprint("error:Already Produced Qty for %s is %s and maximum allowed Qty is %s" % (pro_obj.doc.production_item, cstr(pro_obj.doc.produced_qty) or 0.00 , cstr(pro_obj.doc.qty)))
+				raise Exception
+	
+	# Validate
+	# ------------------
+	def validate(self):
+		sl_obj = get_obj("Stock Ledger", "Stock Ledger")
+		sl_obj.scrub_serial_nos(self)
+		sl_obj.validate_serial_no(self, 'mtn_details')
+		pro_obj = ''
+		if self.doc.production_order:
+			pro_obj = get_obj('Production Order', self.doc.production_order)
+		self.validate_for_production_order(pro_obj)
+		self.validate_incoming_rate()
+		self.validate_warehouse(pro_obj)
+		self.get_stock_and_rate(pro_obj and pro_obj.doc.bom_no or '')
+		self.calc_amount()
+		get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
+				
+	# If target warehouse exists, incoming rate is mandatory
+	# --------------------------------------------------------
+	def validate_incoming_rate(self):
+		for d in getlist(self.doclist, 'mtn_details'):
+			if not flt(d.incoming_rate) and d.t_warehouse:
+				msgprint("Rate is mandatory for Item: %s at row %s" % (d.item_code, d.idx), raise_exception=1)
+
+	# Validate warehouse
+	# -----------------------------------
+	def validate_warehouse(self, pro_obj):
+		fg_qty = 0
+		for d in getlist(self.doclist, 'mtn_details'):
+			if not d.s_warehouse and not d.t_warehouse:
+				d.s_warehouse = self.doc.from_warehouse
+				d.t_warehouse = self.doc.to_warehouse
+
+			if not (d.s_warehouse or d.t_warehouse):
+				msgprint("Atleast one warehouse is mandatory for Stock Entry ")
+				raise Exception
+			if d.s_warehouse and not sql("select name from tabWarehouse where name = '%s'" % d.s_warehouse):
+				msgprint("Invalid Warehouse: %s" % self.doc.s_warehouse)
+				raise Exception
+			if d.t_warehouse and not sql("select name from tabWarehouse where name = '%s'" % d.t_warehouse):
+				msgprint("Invalid Warehouse: %s" % self.doc.t_warehouse)
+				raise Exception
+			if d.s_warehouse == d.t_warehouse:
+				msgprint("Source and Target Warehouse Cannot be Same.")
+				raise Exception
+			if self.doc.purpose == 'Material Issue':
+				if not cstr(d.s_warehouse):
+					msgprint("Source Warehouse is Mandatory for Purpose => 'Material Issue'")
+					raise Exception
+				if cstr(d.t_warehouse):
+					msgprint("Target Warehouse is not Required for Purpose => 'Material Issue'")
+					raise Exception
+			if self.doc.purpose == 'Material Transfer':
+				if not cstr(d.s_warehouse) or not cstr(d.t_warehouse):
+					msgprint("Source Warehouse and Target Warehouse both are Mandatory for Purpose => 'Material Transfer'")
+					raise Exception
+			if self.doc.purpose == 'Material Receipt':
+				if not cstr(d.t_warehouse):
+					msgprint("Target Warehouse is Mandatory for Purpose => 'Material Receipt'")
+					raise Exception
+				if cstr(d.s_warehouse):
+					msgprint("Source Warehouse is not Required for Purpose => 'Material Receipt'")
+					raise Exception
+			if self.doc.process == 'Material Transfer':
+				if cstr(d.t_warehouse) != (pro_obj.doc.wip_warehouse):
+					msgprint(" Target Warehouse should be same as WIP Warehouse %s in Production Order %s at Row No %s" % (cstr(pro_obj.doc.wip_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)) )
+					raise Exception
+				if not cstr(d.s_warehouse):
+					msgprint("Please Enter Source Warehouse at Row No %s is mandatory." % (cstr(d.idx)))
+					raise Exception
+			if self.doc.process == 'Backflush':
+				if flt(d.fg_item):
+					if cstr(pro_obj.doc.production_item) != cstr(d.item_code):
+						msgprint("Item %s in Stock Entry Detail as Row No %s do not match with Item %s in Production Order %s" % (cstr(d.item_code), cstr(d.idx), cstr(pro_obj.doc.production_item), cstr(pro_obj.doc.name)))
+						raise Exception
+					fg_qty = flt(fg_qty) + flt(d.transfer_qty)
+					if cstr(d.t_warehouse) != cstr(pro_obj.doc.fg_warehouse):
+						msgprint("As Item %s is FG Item. Target Warehouse should be same as FG Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.fg_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
+						raise Exception
+					if cstr(d.s_warehouse):
+						msgprint("As Item %s is a FG Item. There should be no Source Warehouse at Row No %s" % (cstr(d.item_code), cstr(d.idx)))
+						raise Exception
+				if not flt(d.fg_item):
+					if cstr(d.t_warehouse):
+						msgprint("As Item %s is not a FG Item. There should no Tareget Warehouse at Row No %s" % (cstr(d.item_code), cstr(d.idx)))
+						raise Exception
+					if cstr(d.s_warehouse) != cstr(pro_obj.doc.wip_warehouse):
+						msgprint("As Item %s is Raw Material. Source Warehouse should be same as WIP Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.wip_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
+						raise Exception
+			d.save()
+		if self.doc.fg_completed_qty and flt(self.doc.fg_completed_qty) != flt(fg_qty):
+			msgprint("The Total of FG Qty %s in Stock Entry Detail do not match with FG Completed Qty %s" % (flt(fg_qty), flt(self.doc.fg_completed_qty)))
+			raise Exception
+
+	def update_production_order(self, is_submit):
+		if self.doc.production_order:
+			pro_obj = get_obj("Production Order", self.doc.production_order)
+			if flt(pro_obj.doc.docstatus) != 1:
+				msgprint("One cannot do any transaction against Production Order : %s, as it's not submitted" % (pro_obj.doc.name))
+				raise Exception
+			if pro_obj.doc.status == 'Stopped':
+				msgprint("One cannot do any transaction against Production Order : %s, as it's status is 'Stopped'" % (pro_obj.doc.name))
+				raise Exception
+			if getdate(pro_obj.doc.posting_date) > getdate(self.doc.posting_date):
+				msgprint("Posting Date of Stock Entry cannot be before Posting Date of Production Order "+ cstr(self.doc.production_order))
+				raise Exception
+			if self.doc.process == 'Backflush':
+				pro_obj.doc.produced_qty = flt(pro_obj.doc.produced_qty) + (is_submit and 1 or -1 ) * flt(self.doc.fg_completed_qty)
+				get_obj('Warehouse',	pro_obj.doc.fg_warehouse).update_bin(0, 0, 0, 0, (is_submit and 1 or -1 ) *	flt(self.doc.fg_completed_qty), pro_obj.doc.production_item, now())
+			pro_obj.doc.status = (flt(pro_obj.doc.qty) == flt(pro_obj.doc.produced_qty)) and	'Completed' or 'In Process'
+			pro_obj.doc.save()
+	
+	# Create / Update Serial No
+	# ----------------------------------
+	def update_serial_no(self, is_submit):
+		sl_obj = get_obj('Stock Ledger')
+		for d in getlist(self.doclist, 'mtn_details'):
+			if d.serial_no:
+				serial_nos = sl_obj.get_sr_no_list(d.serial_no)
+				for x in serial_nos:
+					serial_no = x.strip()
+					if d.s_warehouse:
+						sl_obj.update_serial_delivery_details(self, d, serial_no, is_submit)
+					if d.t_warehouse:
+						sl_obj.update_serial_purchase_details(self, d, serial_no, is_submit, (self.doc.purpose in ['Material Transfer', 'Sales Return']) and 1 or 0)
+					
+					if self.doc.purpose == 'Purchase Return':
+						delete_doc("Serial No", serial_no)
+
+	# On Submit
+	# ------------------
+	def on_submit(self):
+		self.validate_transfer_qty()
+		# Check for Approving Authority
+		get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.total_amount)
+		self.update_serial_no(1)
+		self.update_stock_ledger(0)
+		# update Production Order
+		self.update_production_order(1)
+
+	# On Cancel
+	# -------------------
+	def on_cancel(self):
+		self.update_serial_no(0)
+		self.update_stock_ledger(1)
+		# update Production Order
+		self.update_production_order(0)
+		
+	def get_cust_values(self):
+		tbl = self.doc.delivery_note_no and 'Delivery Note' or 'Receivable Voucher'
+		record_name = self.doc.delivery_note_no or self.doc.sales_invoice_no
+		res = sql("select customer,customer_name, customer_address from `tab%s` where name = '%s'" % (tbl, record_name))
+		ret = {
+			'customer'				 : res and res[0][0] or '',
+			'customer_name'		: res and res[0][1] or '',
+			'customer_address' : res and res[0][2] or ''}
+
+		return str(ret)
+
+
+	def get_cust_addr(self):
+		res = sql("select customer_name,address from `tabCustomer` where name = '%s'"%self.doc.customer)
+		ret = { 
+			'customer_name'		: res and res[0][0] or '',
+			'customer_address' : res and res[0][1] or ''}
+
+		return str(ret)
+
+
+		
+	def get_supp_values(self):
+		res = sql("select supplier,supplier_name,supplier_address from `tabPurchase Receipt` where name = '%s'"%self.doc.purchase_receipt_no)
+		ret = {
+			'supplier' : res and res[0][0] or '',
+			'supplier_name' :res and res[0][1] or '',
+			'supplier_address' : res and res[0][2] or ''}
+		return str(ret)
+		
+
+	def get_supp_addr(self):
+		res = sql("select supplier_name,address from `tabSupplier` where name = '%s'"%self.doc.supplier)
+		ret = {
+			'supplier_name' : res and res[0][0] or '',
+			'supplier_address' : res and res[0][1] or ''}
+		return str(ret)
diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt
new file mode 100644
index 0000000..6959d4d
--- /dev/null
+++ b/stock/doctype/stock_entry/stock_entry.txt
@@ -0,0 +1,779 @@
+# DocType, Stock Entry
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:25',
+		'docstatus': 0,
+		'modified': '2011-06-14 12:50:12',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1308741898',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'module': 'Stock',
+		'name': '__common__',
+		'print_outline': 'No',
+		'search_fields': 'transfer_date, from_warehouse, to_warehouse, purpose, remarks',
+		'section_style': 'Tabbed',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'subject': '%(remarks)s',
+		'tag_fields': 'purpose',
+		'version': 243
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Stock Entry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Stock Entry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Stock Entry
+	{
+		'doctype': 'DocType',
+		'name': 'Stock Entry'
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'Production User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Production User'
+	},
+
+	# DocPerm
+	{
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 2,
+		'role': 'Production User',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 0,
+		'role': 'Production Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 9,
+		'permlevel': 1,
+		'role': 'Production Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 10,
+		'permlevel': 2,
+		'role': 'Production Manager',
+		'write': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 1,
+		'label': 'Warehouse',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 2,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'To manage multiple series please go to Setup > Manage Series',
+		'doctype': 'DocField',
+		'fieldname': 'naming_series',
+		'fieldtype': 'Select',
+		'idx': 3,
+		'label': 'Series',
+		'no_copy': 1,
+		'oldfieldname': 'naming_series',
+		'oldfieldtype': 'Select',
+		'options': 'STE',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry is corrected in the system.',
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'idx': 4,
+		'label': 'Amendment Date',
+		'no_copy': 1,
+		'oldfieldname': 'amendment_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'purpose',
+		'fieldtype': 'Select',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Purpose',
+		'oldfieldname': 'purpose',
+		'oldfieldtype': 'Select',
+		'options': 'Material Issue\nMaterial Receipt\nMaterial Transfer\nSales Return\nPurchase Return\nSubcontracting\nProduction Order',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'delivery_note_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 6,
+		'label': 'Delivery Note No',
+		'oldfieldname': 'delivery_note_no',
+		'oldfieldtype': 'Link',
+		'options': 'Delivery Note',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'purchase_receipt_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 7,
+		'label': 'Purchase Receipt No',
+		'oldfieldname': 'purchase_receipt_no',
+		'oldfieldtype': 'Link',
+		'options': 'Purchase Receipt',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sales_invoice_no',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 8,
+		'label': 'Sales Invoice No',
+		'options': 'Receivable Voucher',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'supplier',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 9,
+		'label': 'Supplier',
+		'oldfieldname': 'supplier',
+		'oldfieldtype': 'Link',
+		'options': 'Supplier',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier_name',
+		'fieldtype': 'Data',
+		'idx': 10,
+		'label': 'Supplier Name',
+		'oldfieldname': 'supplier_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'supplier_address',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'idx': 11,
+		'label': 'Supplier Address',
+		'oldfieldname': 'supplier_address',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'customer',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 12,
+		'label': 'Customer',
+		'oldfieldname': 'customer',
+		'oldfieldtype': 'Link',
+		'options': 'Customer',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_name',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 13,
+		'label': 'Customer Name',
+		'oldfieldname': 'customer_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_address',
+		'fieldtype': 'Small Text',
+		'hidden': 1,
+		'idx': 14,
+		'label': 'Customer Address',
+		'oldfieldname': 'customer_address',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'process',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'idx': 15,
+		'in_filter': 1,
+		'label': 'Process',
+		'oldfieldname': 'process',
+		'oldfieldtype': 'Select',
+		'options': '\nMaterial Transfer\nBackflush',
+		'permlevel': 2,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'production_order',
+		'fieldtype': 'Link',
+		'hidden': 1,
+		'idx': 16,
+		'in_filter': 1,
+		'label': 'Production Order',
+		'oldfieldname': 'production_order',
+		'oldfieldtype': 'Link',
+		'options': 'Production Order',
+		'permlevel': 2,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fg_completed_qty',
+		'fieldtype': 'Currency',
+		'idx': 17,
+		'label': 'FG Completed Qty',
+		'oldfieldname': 'fg_completed_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 2,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 18,
+		'label': 'Warehouse HTML',
+		'no_copy': 0,
+		'oldfieldtype': 'HTML',
+		'options': "<div class='columnHeading'>Warehouse</div>",
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'from_warehouse',
+		'fieldtype': 'Link',
+		'idx': 19,
+		'label': 'Source Warehouse',
+		'oldfieldname': 'from_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': '<b>Notes:</b> Either Source or Target is Mandatory',
+		'doctype': 'DocField',
+		'fieldname': 'to_warehouse',
+		'fieldtype': 'Link',
+		'idx': 20,
+		'in_filter': 0,
+		'label': 'Target Warehouse',
+		'oldfieldname': 'to_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 21,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'default': 'Today',
+		'doctype': 'DocField',
+		'fieldname': 'transfer_date',
+		'fieldtype': 'Date',
+		'idx': 22,
+		'in_filter': 1,
+		'label': 'Transfer Date',
+		'no_copy': 1,
+		'oldfieldname': 'transfer_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry will get or has actually executed.',
+		'doctype': 'DocField',
+		'fieldname': 'posting_date',
+		'fieldtype': 'Date',
+		'idx': 23,
+		'in_filter': 1,
+		'label': 'Posting Date',
+		'no_copy': 1,
+		'oldfieldname': 'posting_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'posting_time',
+		'fieldtype': 'Time',
+		'idx': 24,
+		'in_filter': 0,
+		'label': 'Posting Time',
+		'no_copy': 1,
+		'oldfieldname': 'posting_time',
+		'oldfieldtype': 'Time',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Link',
+		'idx': 25,
+		'label': 'Amended From',
+		'no_copy': 1,
+		'oldfieldname': 'amended_from',
+		'oldfieldtype': 'Link',
+		'options': 'Stock Entry',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'transporter',
+		'fieldtype': 'Data',
+		'idx': 26,
+		'label': 'Transporter',
+		'oldfieldname': 'transporter',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'is_excisable_goods',
+		'fieldtype': 'Select',
+		'idx': 27,
+		'label': 'Is Excisable Goods',
+		'oldfieldname': 'is_excisable_goods',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'excisable_goods',
+		'fieldtype': 'Select',
+		'idx': 28,
+		'label': 'Excisable Goods',
+		'oldfieldname': 'excisable_goods',
+		'oldfieldtype': 'Select',
+		'options': '\nReturnable\nNon-Returnable',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'under_rule',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'idx': 29,
+		'label': 'Under Rule',
+		'oldfieldname': 'under_rule',
+		'oldfieldtype': 'Select',
+		'options': '\nOrdinary\n57 AC (5) a\n57 F (2) Non-Exc.',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'remarks',
+		'fieldtype': 'Text',
+		'idx': 30,
+		'label': 'Remarks',
+		'no_copy': 1,
+		'oldfieldname': 'remarks',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'cancel_reason',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 31,
+		'in_filter': 0,
+		'label': 'Cancel Reason',
+		'no_copy': 1,
+		'oldfieldname': 'cancel_reason',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 32,
+		'label': 'Items',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 33,
+		'label': 'Get Stock and Rate',
+		'oldfieldtype': 'Button',
+		'options': 'get_stock_and_rate',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 34,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'idx': 35,
+		'label': 'Get Items',
+		'oldfieldtype': 'Button',
+		'options': 'get_items',
+		'permlevel': 2,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 36,
+		'oldfieldtype': 'Section Break',
+		'options': 'Simple',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'mtn_details',
+		'fieldtype': 'Table',
+		'idx': 37,
+		'label': 'MTN Details',
+		'oldfieldname': 'mtn_details',
+		'oldfieldtype': 'Table',
+		'options': 'Stock Entry Detail',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'total_amount',
+		'fieldtype': 'Currency',
+		'idx': 38,
+		'label': 'Total Amount',
+		'oldfieldname': 'total_amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 39,
+		'label': 'Other Details',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'idx': 40,
+		'in_filter': 1,
+		'label': 'Company',
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 41,
+		'in_filter': 0,
+		'label': 'Fiscal Year',
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'select_print_heading',
+		'fieldtype': 'Link',
+		'idx': 42,
+		'label': 'Select Print Heading',
+		'oldfieldname': 'select_print_heading',
+		'oldfieldtype': 'Link',
+		'options': 'Print Heading',
+		'permlevel': 0
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/stock_entry_detail/__init__.py b/stock/doctype/stock_entry_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/stock_entry_detail/__init__.py
diff --git a/stock/doctype/stock_entry_detail/stock_entry_detail.txt b/stock/doctype/stock_entry_detail/stock_entry_detail.txt
new file mode 100644
index 0000000..b4fca09
--- /dev/null
+++ b/stock/doctype/stock_entry_detail/stock_entry_detail.txt
@@ -0,0 +1,281 @@
+# DocType, Stock Entry Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:25',
+		'docstatus': 0,
+		'modified': '2011-04-26 11:47:18',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'MTND/.######',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 24
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Stock Entry Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# DocType, Stock Entry Detail
+	{
+		'doctype': 'DocType',
+		'name': 'Stock Entry Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 's_warehouse',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Source Warehouse',
+		'oldfieldname': 's_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 2
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 't_warehouse',
+		'fieldtype': 'Link',
+		'idx': 2,
+		'in_filter': 1,
+		'label': 'Target Warehouse',
+		'oldfieldname': 't_warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 2
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fg_item',
+		'fieldtype': 'Check',
+		'idx': 3,
+		'in_filter': 1,
+		'label': 'FG Item',
+		'oldfieldname': 'fg_item',
+		'oldfieldtype': 'Check',
+		'permlevel': 2,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 0,
+		'reqd': 1,
+		'search_index': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_name',
+		'fieldtype': 'Data',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Item Name',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'description',
+		'fieldtype': 'Text',
+		'idx': 6,
+		'label': 'Description',
+		'oldfieldname': 'description',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'width': '300px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'batch_no',
+		'fieldtype': 'Link',
+		'idx': 7,
+		'label': 'Batch No',
+		'oldfieldname': 'batch_no',
+		'oldfieldtype': 'Link',
+		'options': 'Batch',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'actual_qty',
+		'fieldtype': 'Read Only',
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Actual Qty (at source)',
+		'no_copy': 1,
+		'oldfieldname': 'actual_qty',
+		'oldfieldtype': 'Read Only',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'qty',
+		'fieldtype': 'Currency',
+		'idx': 9,
+		'label': 'Qty',
+		'oldfieldname': 'qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'reqd_qty',
+		'fieldtype': 'Currency',
+		'idx': 10,
+		'in_filter': 0,
+		'label': 'Reqd Qty',
+		'oldfieldname': 'reqd_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 3,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'uom',
+		'fieldtype': 'Link',
+		'idx': 11,
+		'label': 'UOM',
+		'oldfieldname': 'uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'conversion_factor',
+		'fieldtype': 'Currency',
+		'idx': 12,
+		'label': 'Conversion Factor',
+		'oldfieldname': 'conversion_factor',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Link',
+		'idx': 13,
+		'in_filter': 0,
+		'label': 'Stock UOM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM',
+		'permlevel': 1,
+		'reqd': 1,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'transfer_qty',
+		'fieldtype': 'Currency',
+		'idx': 14,
+		'label': 'Stock Qty',
+		'oldfieldname': 'transfer_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Text',
+		'idx': 15,
+		'label': 'Serial No',
+		'no_copy': 1,
+		'oldfieldname': 'serial_no',
+		'oldfieldtype': 'Text',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'incoming_rate',
+		'fieldtype': 'Currency',
+		'idx': 16,
+		'label': 'Incoming Rate',
+		'oldfieldname': 'incoming_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amount',
+		'fieldtype': 'Currency',
+		'idx': 17,
+		'label': 'Amount',
+		'oldfieldname': 'amount',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/stock_ledger/__init__.py b/stock/doctype/stock_ledger/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/stock_ledger/__init__.py
diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py
new file mode 100644
index 0000000..e67afa6
--- /dev/null
+++ b/stock/doctype/stock_ledger/stock_ledger.py
@@ -0,0 +1,244 @@
+# 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
+	
+# -----------------------------------------------------------------------------------------
+
+def get_sr_no_list(sr_nos, qty = 0):
+	serial_nos = cstr(sr_nos).strip().replace(',', '\n').split('\n')
+	valid_serial_nos = []
+	for val in serial_nos:
+		if val:
+			if val in valid_serial_nos:
+				msgprint("You have entered duplicate serial no: %s" % val, raise_exception=1)
+			else:
+				valid_serial_nos.append(val.strip())
+
+	if qty > 0 and cstr(sr_nos).strip() and len(valid_serial_nos) != flt(qty):
+		msgprint("Please enter serial nos for all "+ cstr(qty) + " quantity", raise_exception = 1)
+	return valid_serial_nos
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+
+
+	# -----------------
+	# scrub serial nos
+	# -----------------
+	def scrub_serial_nos(self, obj):
+		for d in getlist(obj.doclist, obj.fname):
+			if d.serial_no:
+				d.serial_no = d.serial_no.replace(',', '\n')
+				d.save()
+
+
+	# -----------------------------
+	# validate serial no warehouse
+	# -----------------------------
+	def validate_serial_no_warehouse(self, obj, fname):
+		for d in getlist(obj.doclist, fname):
+			if d.serial_no:
+				serial_nos = self.get_sr_no_list(d.serial_no)
+				for s in serial_nos:
+					s = s.strip()
+					sr_war =	sql("select warehouse from `tabSerial No` where name = '%s'" % (s))
+					if not sr_war:
+						msgprint("Please set a warehouse in the Serial No <b>%s</b>" % s, raise_exception = 1)
+					if sr_war[0][0] != d.warehouse:
+						msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, d.warehouse), raise_exception = 1)
+					
+
+	# ------------------------------------
+	# check whether serial no is required	
+	# ------------------------------------
+	def validate_serial_no(self, obj, fname):
+		for d in getlist(obj.doclist, fname):
+			is_stock_item = get_value('Item', d.item_code, 'is_stock_item')
+			ar_required = get_value('Item', d.item_code, 'has_serial_no')
+			if cstr(d.serial_no).strip():
+				if is_stock_item != 'Yes':
+					msgprint("Serial No is not required for non-stock item: %s" % d.item_code, raise_exception=1)
+				elif ar_required != 'Yes':
+					msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" + d.item_code + ', otherwise please remove serial no', raise_exception=1)
+			elif ar_required == 'Yes' and not d.serial_no:
+				msgprint("Serial no is mandatory for item: "+ d.item_code, raise_exception = 1)
+			
+
+	
+	# -------------------
+	# get serial no list
+	# -------------------
+	def get_sr_no_list(self, sr_nos, qty = 0):
+		return get_sr_no_list(sr_nos, qty)
+
+	# ---------------------
+	# set serial no values
+	# ---------------------
+	def set_pur_serial_no_values(self, obj, serial_no, d, s, new_rec):
+		item_details = sql("select item_group, warranty_period from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) " %(d.item_code), as_dict=1)
+		s.purchase_document_type =	 obj.doc.doctype
+		s.purchase_document_no	 =	 obj.doc.name
+		s.purchase_date					=	 obj.doc.posting_date
+		s.purchase_time					=	 obj.doc.posting_time
+		s.purchase_rate					=	 d.purchase_rate or d.incoming_rate
+		s.item_code						=	 d.item_code
+		s.brand							=	 d.brand
+		s.description					=	 d.description
+		s.item_group					=	 item_details and item_details[0]['item_group'] or ''
+		s.warranty_period				=	 item_details and item_details[0]['warranty_period'] or 0
+		s.supplier						=	 obj.doc.supplier
+		s.supplier_name					=	 obj.doc.supplier_name
+		s.supplier_address			 	=	 obj.doc.supplier_address
+		s.warehouse						=	 d.warehouse or d.t_warehouse
+		s.docstatus						=	 0
+		s.status						=	 'In Store'
+		s.modified						=	 nowdate()
+		s.modified_by					=	 session['user']
+		s.serial_no						=	 serial_no
+		s.fiscal_year					=	 obj.doc.fiscal_year
+		s.company						=	 obj.doc.company
+		s.save(new_rec)
+
+
+	# ----------------------------------
+	# update serial no purchase details
+	# ----------------------------------
+	def update_serial_purchase_details(self, obj, d, serial_no, is_submit, is_transfer = 0):
+		exists = sql("select name, status, docstatus from `tabSerial No` where name = '%s'" % (serial_no))
+		if is_submit:
+			if exists and exists[0][2] != 2 and not is_transfer:
+				msgprint("Serial No: %s already %s" % (serial_no, exists and exists[0][1]), raise_exception = 1)
+			elif exists:
+				s = Document('Serial No', exists and exists[0][0])
+				self.set_pur_serial_no_values(obj, serial_no, d, s, new_rec = 0)
+			else:
+				s = Document('Serial No')
+				self.set_pur_serial_no_values(obj, serial_no, d, s, new_rec = 1)
+		else:
+			if exists and exists[0][1] == 'Delivered' and exists[0][2] != 2:
+				msgprint("Serial No: %s is already delivered, you can not cancel the document." % serial_no, raise_exception=1)
+			else:
+				sql("update `tabSerial No` set docstatus = '%s', status = '%s', purchase_document_type = '', purchase_document_no = '', purchase_date = '', purchase_rate = '', supplier = null, supplier_name = '', supplier_address = '', warehouse = null where name = '%s'" % (not is_transfer and 2 or 0, is_transfer and 'In Store' or 'Not in Use', serial_no))
+
+
+	# -------------------------------
+	# check whether serial no exists
+	# -------------------------------
+	def check_serial_no_exists(self, serial_no, item_code):
+		chk = sql("select name, status, docstatus, item_code from `tabSerial No` where name = %s", (serial_no), as_dict=1)
+		if not chk:
+			msgprint("Serial No: %s does not exists in the system" % serial_no, raise_exception=1)
+		elif chk and chk[0]['item_code'] != item_code:
+			msgprint("Serial No: %s not belong to item: %s" % (serial_no, item_code), raise_exception=1)
+		elif chk and chk[0]['docstatus'] == 2:
+			msgprint("Serial No: %s of Item : %s is trashed in the system" % (serial_no, item_code), raise_exception = 1)
+		elif chk and chk[0]['status'] == 'Delivered':
+			msgprint("Serial No: %s of Item : %s is already delivered." % (serial_no, item_code), raise_exception = 1)
+
+	# ---------------------
+	# set serial no values
+	# ---------------------
+	def set_delivery_serial_no_values(self, obj, serial_no):
+		s = Document('Serial No', serial_no)
+		s.delivery_document_type =	 obj.doc.doctype
+		s.delivery_document_no	 =	 obj.doc.name
+		s.delivery_date					=	 obj.doc.posting_date
+		s.delivery_time					=	 obj.doc.posting_time
+		s.customer						=	 obj.doc.customer
+		s.customer_name					=	 obj.doc.customer_name
+		s.delivery_address			 	=	 obj.doc.delivery_address
+		s.territory						=	 obj.doc.territory
+		s.warranty_expiry_date	 		=	 s.warranty_period and add_days(cstr(obj.doc.posting_date), s.warranty_period) or ''
+		s.docstatus						=	 1
+		s.status						=	 'Delivered'
+		s.modified						=	 nowdate()
+		s.modified_by					=	 session['user']
+		s.save()
+
+
+	# ----------------------------------
+	# update serial no delivery details
+	# ----------------------------------
+	def update_serial_delivery_details(self, obj, d, serial_no, is_submit):
+		if is_submit:
+			self.check_serial_no_exists(serial_no, d.item_code)
+			self.set_delivery_serial_no_values(obj, serial_no)
+		else:
+			sql("update `tabSerial No` set docstatus = 0, status = 'In Store', delivery_document_type = '', delivery_document_no = '', delivery_date = '', customer = null, customer_name = '', delivery_address = '', territory = null where name = '%s'" % (serial_no))
+
+
+	# ---------------------
+	# update serial record
+	# ---------------------
+	def update_serial_record(self, obj, fname, is_submit = 1, is_incoming = 0):
+		import datetime
+		for d in getlist(obj.doclist, fname):
+			if d.serial_no:
+				serial_nos = self.get_sr_no_list(d.serial_no, d.qty)
+				for a in serial_nos:
+					serial_no = a.strip()
+					if is_incoming:
+						self.update_serial_purchase_details(obj, d, serial_no, is_submit)
+					else:
+						self.update_serial_delivery_details(obj, d, serial_no, is_submit)
+
+
+	# -------------
+	# update stock
+	# -------------
+	def update_stock(self, values):
+		for v in values:
+			sle_id, serial_nos = '', ''
+
+			# get serial nos
+			if v["serial_no"]:
+				serial_nos = self.get_sr_no_list(v["serial_no"], v['actual_qty'])
+
+			# reverse quantities for cancel
+			if v['is_cancelled'] == 'Yes':
+				v['actual_qty'] = -flt(v['actual_qty'])
+				# cancel matching entry
+				sql("update `tabStock Ledger Entry` set is_cancelled='Yes' where voucher_no=%s and voucher_type=%s", (v['voucher_no'], v['voucher_type']))
+
+			if v["actual_qty"]:
+				sle_id = self.make_entry(v)
+
+			get_obj('Warehouse', v["warehouse"]).update_bin(flt(v["actual_qty"]), 0, 0, 0, 0, v["item_code"], v["posting_date"], sle_id, v["posting_time"], '', v["is_cancelled"])
+
+
+	# -----------
+	# make entry
+	# -----------
+	def make_entry(self, args):
+		sle = Document(doctype = 'Stock Ledger Entry')
+		for k in args.keys():
+			# adds warehouse_type
+			if k == 'warehouse': 
+				sle.fields['warehouse_type'] = get_value('Warehouse' , args[k], 'warehouse_type')
+			sle.fields[k] = args[k]
+		sle_obj = get_obj(doc=sle)
+		# validate
+		sle_obj.validate()
+		sle.save(new = 1)
+		return sle.name
+		
+	def repost(self):
+		"""
+		Repost everything!
+		"""
+		for wh in sql("select name from tabWarehouse"):
+			get_obj('Warehouse', wh[0]).repost_stock()
diff --git a/stock/doctype/stock_ledger/stock_ledger.txt b/stock/doctype/stock_ledger/stock_ledger.txt
new file mode 100644
index 0000000..2bbfbb9
--- /dev/null
+++ b/stock/doctype/stock_ledger/stock_ledger.txt
@@ -0,0 +1,59 @@
+# DocType, Stock Ledger
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:25',
+		'docstatus': 0,
+		'modified': '2010-12-16 23:57:05',
+		'modified_by': 'nabin@webnotestech.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'hide_toolbar': 1,
+		'in_create': 1,
+		'issingle': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'read_only': 1,
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 10
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Stock Ledger',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 1,
+		'read': 1
+	},
+
+	# DocType, Stock Ledger
+	{
+		'doctype': 'DocType',
+		'name': 'Stock Ledger'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'role': 'Material User'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/stock_ledger_entry/__init__.py b/stock/doctype/stock_ledger_entry/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/stock_ledger_entry/__init__.py
diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
new file mode 100644
index 0000000..3833e45
--- /dev/null
+++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -0,0 +1,81 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import cstr, cint, flt, cstr, getdate
+
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+msgprint = webnotes.msgprint
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+	
+	#check for item quantity available in stock
+	def actual_amt_check(self):
+		if self.doc.batch_no:
+			batch_bal = flt(sql("select sum(actual_qty) from `tabStock Ledger Entry` where warehouse = '%s' and item_code = '%s' and batch_no = '%s'"%(self.doc.warehouse,self.doc.item_code,self.doc.batch_no))[0][0])
+	
+			if (batch_bal + self.doc.actual_qty) < 0:
+				msgprint("""Not enough quantity (requested: %(actual_qty)s, current: %(batch_bal)s in Batch 
+		<b>%(batch_no)s</b> for Item <b>%(item_code)s</b> at Warehouse<b>%(warehouse)s</b> 
+		as on %(posting_date)s %(posting_time)s""" % self.doc.fields.update({'batch_bal': batch_bal}), raise_exception = 1)
+			 
+
+	# mandatory
+	# ---------
+	
+	def validate_mandatory(self):		
+		mandatory = ['warehouse','transaction_date','posting_date','voucher_type','voucher_no','actual_qty','company','fiscal_year']
+		for k in mandatory:
+			if self.doc.fields.get(k)==None:
+				msgprint("Stock Ledger Entry: '%s' is mandatory" % k, raise_exception = 1)
+			elif k == 'warehouse':
+				if not sql("select name from tabWarehouse where name = '%s'" % self.doc.fields.get(k)):
+					msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
+
+	# validate for item
+	# -----------------
+	
+	def validate_item(self):
+		item_det = sql("select name, has_batch_no, docstatus from tabItem where name = '%s'" % self.doc.item_code)
+
+		# check item exists
+		if item_det:
+			item_det = item_det and item_det[0]
+		else:
+			msgprint("Item: '%s' does not exist in the system. Please check." % self.doc.item_code, raise_exception = 1)
+			
+		# check if item is trashed
+		if cint(item_det[2])==2:
+			msgprint("Item: '%s' is trashed, cannot make a stock transaction against a trashed item" % self.doc.item_code, raise_exception = 1)
+			
+		# check if batch number is required
+		if item_det[1]=='Yes' and self.doc.voucher_type != 'Stock Reconciliation':
+			if not self.doc.batch_no:
+				msgprint("Batch number is mandatory for Item '%s'" % self.doc.item_code, raise_exception = 1)
+				raise Exception
+		
+			# check if batch belongs to item
+			if not sql("select name from `tabBatch` where item='%s' and name ='%s' and docstatus != 2" % (self.doc.item_code, self.doc.batch_no)):
+				msgprint("'%s' is not a valid Batch Number for Item '%s'" % (self.doc.batch_no, self.doc.item_code), raise_exception = 1)
+	
+	# Nobody can do SL Entries where posting date is before freezing date except authorized person
+	#----------------------------------------------------------------------------------------------
+	def check_stock_frozen_date(self):
+		stock_frozen_upto = get_value('Manage Account', None, 'stock_frozen_upto') or ''
+		if stock_frozen_upto:
+			stock_auth_role = get_value('Manage Account', None,'stock_auth_role')
+			if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in webnotes.user.get_roles():
+				msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1)
+
+
+	def validate(self):
+		self.validate_mandatory()
+		self.validate_item()
+		self.actual_amt_check()
+		self.check_stock_frozen_date()
diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt
new file mode 100644
index 0000000..603f095
--- /dev/null
+++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt
@@ -0,0 +1,447 @@
+# DocType, Stock Ledger Entry
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:25',
+		'docstatus': 0,
+		'modified': '2011-06-02 15:42:37',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1307707462',
+		'autoname': 'SLE/.########',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'hide_toolbar': 1,
+		'in_create': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 53
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Stock Ledger Entry',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Stock Ledger Entry',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Stock Ledger Entry
+	{
+		'doctype': 'DocType',
+		'name': 'Stock Ledger Entry'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 2,
+		'role': 'System Manager'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'in_filter': 1,
+		'label': 'Item Code',
+		'oldfieldname': 'item_code',
+		'oldfieldtype': 'Link',
+		'options': 'Item',
+		'permlevel': 1,
+		'reqd': 0,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'serial_no',
+		'fieldtype': 'Text',
+		'idx': 2,
+		'in_filter': 0,
+		'label': 'Serial No',
+		'permlevel': 0,
+		'search_index': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'batch_no',
+		'fieldtype': 'Data',
+		'idx': 3,
+		'label': 'Batch No',
+		'oldfieldname': 'batch_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse',
+		'fieldtype': 'Link',
+		'idx': 4,
+		'in_filter': 1,
+		'label': 'Warehouse',
+		'oldfieldname': 'warehouse',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse_type',
+		'fieldtype': 'Select',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Warehouse Type',
+		'oldfieldname': 'warehouse_type',
+		'oldfieldtype': 'Select',
+		'options': 'link:Warehouse Type',
+		'permlevel': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry will get or has actually executed.',
+		'doctype': 'DocField',
+		'fieldname': 'posting_date',
+		'fieldtype': 'Date',
+		'idx': 6,
+		'in_filter': 1,
+		'label': 'Posting Date',
+		'oldfieldname': 'posting_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'reqd': 0,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'posting_time',
+		'fieldtype': 'Time',
+		'idx': 7,
+		'in_filter': 0,
+		'label': 'Posting Time',
+		'oldfieldname': 'posting_time',
+		'oldfieldtype': 'Time',
+		'permlevel': 1,
+		'search_index': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'description': 'The date at which current entry is made in system.',
+		'doctype': 'DocField',
+		'fieldname': 'transaction_date',
+		'fieldtype': 'Date',
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Transaction Date',
+		'oldfieldname': 'transaction_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'voucher_type',
+		'fieldtype': 'Data',
+		'idx': 9,
+		'in_filter': 1,
+		'label': 'Voucher Type',
+		'oldfieldname': 'voucher_type',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'voucher_no',
+		'fieldtype': 'Data',
+		'idx': 10,
+		'in_filter': 1,
+		'label': 'Voucher No',
+		'oldfieldname': 'voucher_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'voucher_detail_no',
+		'fieldtype': 'Data',
+		'idx': 11,
+		'label': 'Voucher Detail No',
+		'oldfieldname': 'voucher_detail_no',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'actual_qty',
+		'fieldtype': 'Currency',
+		'idx': 12,
+		'in_filter': 1,
+		'label': 'Actual Quantity',
+		'oldfieldname': 'actual_qty',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'incoming_rate',
+		'fieldtype': 'Currency',
+		'idx': 13,
+		'label': 'Incoming Rate',
+		'oldfieldname': 'incoming_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_uom',
+		'fieldtype': 'Data',
+		'idx': 14,
+		'label': 'Stock UOM',
+		'oldfieldname': 'stock_uom',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'bin_aqat',
+		'fieldtype': 'Currency',
+		'idx': 15,
+		'in_filter': 1,
+		'label': 'Bin Actual Qty After Transaction',
+		'oldfieldname': 'bin_aqat',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'ma_rate',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 16,
+		'label': 'Moving Average Rate',
+		'oldfieldname': 'ma_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fcfs_rate',
+		'fieldtype': 'Currency',
+		'hidden': 1,
+		'idx': 17,
+		'label': 'FIFO Rate',
+		'oldfieldname': 'fcfs_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'valuation_rate',
+		'fieldtype': 'Currency',
+		'idx': 18,
+		'label': 'Valuation Rate',
+		'oldfieldname': 'valuation_rate',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'stock_value',
+		'fieldtype': 'Currency',
+		'idx': 19,
+		'label': 'Stock Value',
+		'oldfieldname': 'stock_value',
+		'oldfieldtype': 'Currency',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fcfs_stack',
+		'fieldtype': 'Text',
+		'hidden': 0,
+		'idx': 20,
+		'in_filter': 0,
+		'label': 'FIFO Stack',
+		'oldfieldname': 'fcfs_stack',
+		'oldfieldtype': 'Text',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 0,
+		'search_index': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Data',
+		'idx': 21,
+		'in_filter': 1,
+		'label': 'Company',
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Data',
+		'idx': 22,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Data',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'is_cancelled',
+		'fieldtype': 'Select',
+		'idx': 23,
+		'in_filter': 1,
+		'label': 'Is Cancelled',
+		'oldfieldname': 'is_cancelled',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'is_stock_entry',
+		'fieldtype': 'Select',
+		'idx': 24,
+		'in_filter': 1,
+		'label': 'Is Stock Entry',
+		'oldfieldname': 'is_stock_entry',
+		'oldfieldtype': 'Select',
+		'options': '\nYes\nNo',
+		'permlevel': 1,
+		'search_index': 1,
+		'width': '100px'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/stock_reconciliation/__init__.py b/stock/doctype/stock_reconciliation/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/stock_reconciliation/__init__.py
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js
new file mode 100644
index 0000000..de89d80
--- /dev/null
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -0,0 +1,37 @@
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+  cfn_set_fields(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+  cfn_set_fields(doc, cdt, cdn);
+}
+
+var cfn_set_fields = function(doc, cdt, cdn) {
+  refresh_field('remark');
+  refresh_field('next_step');
+  if (doc.docstatus == 0 && doc.next_step == 'Upload File and Save Document') 
+    doc.next_step = 'Validate Data';
+  
+  if (! doc.file_list)
+    doc.next_step = 'Upload File and Save Document'
+  
+  if (doc.next_step == 'Upload File and Save Document') {
+    //alert("Upload File and Save Document");
+    cur_frm.clear_tip();
+    cur_frm.set_tip("Please Enter Reconciliation Date and Attach CSV File with Columns in Following Sequence:-");
+    cur_frm.append_tip("Item Code , Warehouse , Qty , MAR");
+    hide_field("Validate Data");
+  }
+  if (doc.next_step == 'Validate Data') {
+    //alert("Validate Data");
+    cur_frm.clear_tip();
+    cur_frm.set_tip("Please Check Remarks");
+    unhide_field("Validate Data");
+  }
+  if (doc.next_step == 'Submit Document') {
+    //alert('Submit Document');
+    cur_frm.clear_tip();
+    cur_frm.set_tip("Please Submit the document.");
+    hide_field("Validate Data");
+  }
+}
\ No newline at end of file
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py
new file mode 100644
index 0000000..28410c8
--- /dev/null
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -0,0 +1,310 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		self.label = { 'item_code': 0 , 'warehouse': 1 , 'qty': 2, 'mar': 3,'stock_uom':4, 'actual_qty':5, 'diff': 6} # with mar
+
+	# autoname
+	#-----------------
+	def autoname(self):
+		 self.doc.name = make_autoname('SR/' + self.doc.fiscal_year + '/.######')
+
+	# -----------------
+	# update next step
+	# -----------------
+	def update_next_step(self,next_step):
+		sql("update `tabStock Reconciliation` set next_step = '%s' where name = '%s'" % (next_step,self.doc.name))
+	
+
+	# -----------
+	# add remark
+	# -----------
+	def add_remark(self, text, next_step, first_time = 0):
+		if first_time:
+			sql("update `tabStock Reconciliation` set remark = '' where name = '%s'" % self.doc.name)
+		else:
+			sql("update `tabStock Reconciliation` set remark = concat(remark, '%s'), modified = '%s' where name = '%s'" % (text + "<br>", nowdate(), self.doc.name))
+		self.update_next_step(next_step)
+
+
+	# --------------
+	# validate item
+	# --------------
+	def validate_item(self, item, count, check_item = 1):
+		det = sql("select item_code, has_serial_no from `tabItem` where name = '%s'"% cstr(item), as_dict = 1)
+		if not det:
+			text = "Item: " + cstr(item) + " mentioned at Row No. " + cstr(count) + "does not exist in the system"
+			msgprint(text)
+			self.add_remark(text, 'Validate Data', 0)
+			check_item = 0
+		elif det and det[0]['has_serial_no'] == 'Yes':
+			text = "You cannot make Stock Reconciliation of items having serial no. You can directly upload serial no to update their inventory. Please remove Item Code : %s at Row No. %s" %(cstr(item), cstr(count))
+			msgprint(text)
+			self.add_remark(text, 'Validate Data', 0)
+			check_item = 0
+		return check_item
+
+
+	# -------------------
+	# validate warehouse
+	# -------------------
+	def validate_warehouse(self,wh,count, check_warehouse = 1):
+		if not sql("select name from `tabWarehouse` where name = '%s'" % cstr(wh)):
+			text = "Warehouse: " + cstr(wh) + " mentioned at Row No. " + cstr(count) + "does not exist in the system"
+			self.add_remark(text,'Validate Data',0)
+			check_warehouse = 0
+		return check_warehouse
+
+
+	# ---------------------------
+	# validate data of .csv file
+	# ---------------------------
+	def validate_data(self,stock):
+		self.add_remark('','Validate Data',1)
+
+		# check whether file uploaded
+		if not self.doc.file_list:
+			set(self.doc,'next_step','Upload File and Save Document')
+			msgprint("Please Attach File", raise_exception=1)
+
+		# validate item and warehouse
+		check_item,check_warehouse,count = 1, 1, 1
+		for s in stock:
+			count +=1
+			check_item = self.validate_item(s[self.label['item_code']],count) or 0
+			check_warehouse = self.validate_warehouse(s[self.label['warehouse']],count) or 0
+
+		if check_item and check_warehouse:
+			text = "Validation Completed Successfully..."
+			self.add_remark(text,'Submit Document',0)
+		return check_item and check_warehouse
+
+
+	# ------------------------------
+	# convert lines in .csv to list
+	# ------------------------------
+	def convert_into_list(self, stock, submit):
+		count, st_list = 1, []
+		for s in stock:
+			if submit and len(s) != 4:
+				msgprint("Data entered at Row No " + cstr(count) + " in Attachment File is not in correct format.", raise_exception=1)
+
+			l = [s[0].encode("ascii"), s[1].encode("ascii"), s[2].encode("ascii"), s[3].encode("ascii")]
+			st_list.append(l)
+			count += 1
+		return st_list
+
+	# ------------------
+	# get current stock
+	# ------------------
+	def get_current_stock(self, item_code, warehouse):
+		bin = sql("select name from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item_code, warehouse))
+		prev_sle = bin and get_obj('Bin', bin[0][0]).get_prev_sle(self.doc.reconciliation_date,self.doc.reconciliation_time) or 0
+		stock_uom = sql("select stock_uom from `tabItem` where name = %s",item_code)
+		return {'actual_qty': prev_sle.get('bin_aqat', 0), 'stock_uom': stock_uom[0][0]}
+
+
+	# -----------
+	# update mar
+	# -----------
+	def update_mar(self, d, qty_diff):
+		if not d[self.label['qty']] and not d[self.label['actual_qty']]:
+			 # seems like a special condition when there is no actual quanitity but there is a rate, may be only for setting a rate!
+			 self.make_sl_entry(1,d,1)
+			 self.make_sl_entry(-1,d,1)
+		else:
+			self.update_item_valuation_pre_date(d)
+
+			if not qty_diff:
+				self.update_item_valuation_post_date(d)
+				
+	# update valuation rate as csv file in all sle before reconciliation date
+	# ------------------------------------------------------------------------
+	def update_item_valuation_pre_date(self, d):
+		mar = flt(d[self.label['mar']])		
+
+		# previous sle
+		prev_sle = sql("""
+			select name, fcfs_stack
+			from `tabStock Ledger Entry`
+			where item_code = %s
+			and warehouse = %s
+			and ifnull(is_cancelled, 'No') = 'No'
+			and timestamp(posting_date, posting_time) <= timestamp(%s, %s)
+			""", (d[self.label['item_code']], d[self.label['warehouse']], self.doc.reconciliation_date, self.doc.reconciliation_time))
+
+		for each in prev_sle:
+			# updated fifo stack
+			fstack = each[1] and [[i[0], mar] for i in eval(each[1])] or ''
+
+			# update incoming rate, valuation rate, stock value and fifo stack
+			sql("""update `tabStock Ledger Entry` 
+			set incoming_rate = %s, valuation_rate = %s, stock_value = bin_aqat*%s, fcfs_stack = %s 
+			where name = %s
+			""", (mar, mar, mar, cstr(fstack), each[0]))
+			
+				
+	# Update item valuation in all sle after the reconcliation date
+	# ---------------------------------------------------------
+	def update_item_valuation_post_date(self, d):
+		bin = sql("select name from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d[self.label['item_code']], d[self.label['warehouse']]))
+		bin_obj = get_obj('Bin', bin[0][0])
+
+		# prev sle
+		prev_sle = bin_obj.get_prev_sle(self.doc.reconciliation_date,self.doc.reconciliation_time)
+
+		# update valuation in sle posted after reconciliation datetime
+		bin_obj.update_item_valuation(posting_date = self.doc.reconciliation_date, posting_time = self.doc.reconciliation_time, prev_sle = prev_sle)
+
+	# --------------
+	# make sl entry
+	# --------------
+	def make_sl_entry(self, update_stock, stock, diff):
+		values = []
+		values.append({
+				'item_code'					: stock[self.label['item_code']],
+				'warehouse'					: stock[self.label['warehouse']],
+				'transaction_date'	 		: now(),
+				'posting_date'				: self.doc.reconciliation_date,
+				'posting_time'			 	: self.doc.reconciliation_time,
+				'voucher_type'			 	: self.doc.doctype,
+				'voucher_no'				: self.doc.name,
+				'voucher_detail_no'			: self.doc.name,
+				'actual_qty'				: flt(update_stock) * flt(diff),
+				'stock_uom'					: stock[self.label['stock_uom']],
+				'incoming_rate'				: stock[self.label['mar']] or 0,
+				'company'					: self.doc.company,
+				'fiscal_year'				: self.doc.fiscal_year,
+				'is_cancelled'			 	: (update_stock==1) and 'No' or 'Yes',
+				'batch_no'					: '',
+				'serial_no'					: ''
+		 })
+				
+		get_obj('Stock Ledger', 'Stock Ledger').update_stock(values)
+
+
+	# -----------------------
+	# get stock reco details
+	# -----------------------
+	def get_reconciliation_stock_details(self,submit = 0):
+		import csv 
+		stock = csv.reader(self.get_csv_file_data().splitlines())
+		stock = self.convert_into_list(stock, submit)
+		if stock[0][0] and stock[0][0].strip()=='Item Code':
+			stock.pop(0)		# remove the labels
+		check = self.validate_data(stock)
+		if not check:
+			return 0
+		return stock
+
+	# validate date and time
+	# ------------------------
+	def validate_datetime(self):
+		if not self.doc.reconciliation_date:
+			msgprint("Please Enter Reconciliation Date.", raise_exception=1)
+		if not self.doc.reconciliation_time:
+			msgprint("Please Enter Reconciliation Time.", raise_exception=1)
+
+
+
+	# ----------------------
+	# stock reconciliations
+	# ----------------------
+	def stock_reconciliations(self, submit = 0):
+		self.validate_datetime()
+
+		# get reco data
+		rec_stock_detail = self.get_reconciliation_stock_details(submit) or []
+		if not rec_stock_detail:
+			msgprint("Please Check Remarks", raise_exception=1)
+
+		count = 1
+		for stock in rec_stock_detail:
+			count += 1
+
+			# Get qty as per system
+			cur_stock_detail = self.get_current_stock(stock[self.label['item_code']],stock[self.label['warehouse']])
+			stock.append(cur_stock_detail['stock_uom'])
+			stock.append(cur_stock_detail['actual_qty'])
+
+			# Qty Diff between file and system
+			diff = flt(stock[self.label['qty']]) - flt(cur_stock_detail['actual_qty'])
+
+			# Update MAR
+			if not stock[self.label['mar']] == '~':
+				self.update_mar(stock, diff)
+			
+			# Make sl entry if qty differ
+			if diff:
+				self.make_sl_entry(submit, stock, diff)
+
+		if rec_stock_detail:
+			text = "Stock Reconciliation Completed Successfully..."
+			self.add_data_in_CSV(rec_stock_detail)
+			self.add_remark(text,'Completed', 0)
+
+	# Get csv data
+	#--------------------------
+	def get_csv_file_data(self):
+		filename = self.doc.file_list.split(',')
+		if not filename:
+			msgprint("Please Attach File. ", raise_exception=1)
+			
+		from webnotes.utils import file_manager
+		fn, content = file_manager.get_file(filename[1])
+		
+		if not type(content) == str:
+			content = content.tostring()
+		return content
+
+
+	def getCSVelement(self,v):
+		v = cstr(v)
+		if not v: return ''
+		if (',' in v) or ('' in v) or ('"' in	v):
+			if '"' in v: v = v.replace('"', '""')
+			return '"'+v+'"'
+		else: return v or ''
+
+	# Add qty diff column in attached file
+	#----------------------------------------
+	def add_data_in_CSV(self,data):
+		filename = self.doc.file_list.split(',')
+		head = []
+		for h in ['Item Code','Warehouse','Qty','Actual','Difference','MAR']:
+			head.append(self.getCSVelement(h))
+		dset = (','.join(head) + "\n")
+		for d in data:
+			l = [d[self.label['item_code']],d[self.label['warehouse']],d[self.label['qty']],d[self.label['actual_qty']],flt(d[self.label['qty']])-flt(d[self.label['actual_qty']]),d[self.label['mar']]]
+			s =[]
+			for i in l:
+				s.append(self.getCSVelement(i))
+			dset +=(','.join(s)+"\n")
+		
+		from webnotes.utils import file_manager
+		file_manager.write_file(filename[1], dset)
+
+	# ----------
+	# on submit
+	# ----------
+	def on_submit(self):
+		self.stock_reconciliations(submit = 1)
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
new file mode 100644
index 0000000..1080a27
--- /dev/null
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
@@ -0,0 +1,260 @@
+# DocType, Stock Reconciliation
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:26',
+		'docstatus': 0,
+		'modified': '2011-04-25 11:46:21',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1307707462',
+		'allow_attach': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'max_attachments': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'search_fields': 'reconciliation_date',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 85
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Stock Reconciliation',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Stock Reconciliation',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Stock Reconciliation
+	{
+		'doctype': 'DocType',
+		'name': 'Stock Reconciliation'
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 1,
+		'role': 'System Manager'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 1,
+		'idx': 1,
+		'label': 'Validate Data',
+		'oldfieldtype': 'Button',
+		'options': 'get_reconciliation_stock_details',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 2,
+		'label': 'Summary',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'reconciliation_date',
+		'fieldtype': 'Date',
+		'idx': 3,
+		'in_filter': 0,
+		'label': 'Reconciliation Date',
+		'oldfieldname': 'reconciliation_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'reconciliation_time',
+		'fieldtype': 'Time',
+		'idx': 4,
+		'in_filter': 0,
+		'label': 'Reconciliation Time',
+		'oldfieldname': 'reconciliation_time',
+		'oldfieldtype': 'Time',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'next_step',
+		'fieldtype': 'Select',
+		'idx': 5,
+		'label': 'Next Steps',
+		'oldfieldname': 'next_step',
+		'oldfieldtype': 'Select',
+		'options': 'Upload File and Save Document\nValidate Data\nSubmit Document\nCompleted',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'remark',
+		'fieldtype': 'Text',
+		'idx': 6,
+		'label': 'Remark',
+		'oldfieldname': 'remark',
+		'oldfieldtype': 'Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'idx': 7,
+		'in_filter': 1,
+		'label': 'Company',
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 8,
+		'in_filter': 1,
+		'label': 'Fiscal Year',
+		'oldfieldname': 'fiscal_year',
+		'oldfieldtype': 'Select',
+		'options': 'link:Fiscal Year',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amended_from',
+		'fieldtype': 'Data',
+		'idx': 9,
+		'label': 'Amended From',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'amendment_date',
+		'fieldtype': 'Date',
+		'idx': 10,
+		'label': 'Amendment Date',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 11,
+		'label': 'Attachment',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 12,
+		'label': 'Attachment HTML',
+		'oldfieldtype': 'HTML',
+		'options': 'The attachment must be a CSV(Comma Seperated Value) file',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'file_list',
+		'fieldtype': 'Text',
+		'hidden': 1,
+		'idx': 13,
+		'label': 'File List',
+		'oldfieldname': 'file_list',
+		'oldfieldtype': 'Text',
+		'permlevel': 1,
+		'print_hide': 1
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/stock_uom_replace_utility/__init__.py b/stock/doctype/stock_uom_replace_utility/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/stock_uom_replace_utility/__init__.py
diff --git a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.js b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.js
new file mode 100644
index 0000000..8352506
--- /dev/null
+++ b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.js
@@ -0,0 +1,10 @@
+cur_frm.fields_dict['item_code'].get_query = function(doc) {
+  return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.`%(key)s` like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
+}
+
+//==================== Get Items Stock UOM =====================================================
+cur_frm.cscript.item_code = function(doc,cdt,cdn) {
+ if (doc.item_code) {
+    get_server_fields('get_stock_uom', doc.item_code, '', doc, cdt, cdn, 1);
+  }
+}
\ No newline at end of file
diff --git a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
new file mode 100644
index 0000000..e603d1f
--- /dev/null
+++ b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
@@ -0,0 +1,105 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, d, dl=[]):
+    self.doc, self.doclist = d,dl
+
+  def get_stock_uom(self, item_code):
+    return cstr({'current_stock_uom': cstr(get_value('Item', item_code, 'stock_uom'))})
+  
+  def validate_mandatory(self):
+    if not cstr(self.doc.item_code):
+      msgprint("Please Enter an Item.")
+      raise Exception
+
+    if not cstr(self.doc.current_stock_uom):
+      msgprint("There is no Current Stock UOM for Item Code" + cstr(self.doc.item_code))
+      raise Exception
+    
+    if not cstr(self.doc.new_stock_uom):
+      msgprint("Please Enter New Stock UOM.")
+      raise Exception
+
+    if cstr(self.doc.current_stock_uom) == cstr(self.doc.new_stock_uom):
+      msgprint("Current Stock UOM and Stock UOM are same.")
+      raise Exception 
+  
+    # check conversion factor
+    if not flt(self.doc.conversion_factor):
+      msgprint("Please Enter Conversion Factor.")
+      raise Exception
+    
+    stock_uom = sql("select stock_uom from `tabItem` where name = '%s'" % self.doc.item_code)
+    stock_uom = stock_uom and stock_uom[0][0]
+    if cstr(self.doc.new_stock_uom) == cstr(stock_uom):
+      msgprint("Item Master is already updated with New Stock UOM " + cstr(self.doc.new_stock_uom))
+      raise Exception
+      
+  def update_item_master(self):
+    # update stock uom in item master
+    sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
+    
+    # acknowledge user
+    msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code))
+    
+  def update_bin(self):
+    # update bin
+    if flt(self.doc.conversion_factor) != flt(1):
+      sql("update `tabBin` set stock_uom = '%s' , indented_qty = ifnull(indented_qty,0) * %s, ordered_qty = ifnull(ordered_qty,0) * %s, reserved_qty = ifnull(reserved_qty,0) * %s, planned_qty = ifnull(planned_qty,0) * %s, projected_qty = actual_qty + ordered_qty + indented_qty + planned_qty - reserved_qty  where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.item_code) )
+    else:
+      sql("update `tabBin` set stock_uom = '%s' where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.item_code) )
+
+    # acknowledge user
+    msgprint(" All Bin's Updated Successfully.")
+      
+  def update_stock_ledger_entry(self):
+    # update stock ledger entry
+    if flt(self.doc.conversion_factor) != flt(1):
+      sql("update `tabStock Ledger Entry` set stock_uom = '%s', actual_qty = ifnull(actual_qty,0) * '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.item_code))
+    else:
+      sql("update `tabStock Ledger Entry` set stock_uom = '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
+    
+    # acknowledge user
+    msgprint("Stock Ledger Entries Updated Successfully.")
+    
+    # update item valuation
+    if flt(self.doc.conversion_factor) != flt(1):
+      wh = sql("select name from `tabWarehouse`")
+      for w in wh:
+        bin = sql("select name from `tabBin` where item_code = '%s' and warehouse = '%s'" % (self.doc.item_code, w[0])) 
+        if bin and bin[0][0]:
+          get_obj("Bin", bin[0][0]).update_item_valuation(sle_id = '', posting_date = '', posting_time = '')
+
+    # acknowledge user
+    msgprint("Item Valuation Updated Successfully.")
+
+  # Update Stock UOM              
+  def update_stock_uom(self):
+    # validate mandatory
+    self.validate_mandatory()
+    
+    # update item master
+    self.update_item_master()
+    
+    # update stock ledger entry
+    self.update_stock_ledger_entry()
+    
+    # update bin
+    self.update_bin()
\ No newline at end of file
diff --git a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt
new file mode 100644
index 0000000..7818530
--- /dev/null
+++ b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt
@@ -0,0 +1,161 @@
+# DocType, Stock UOM Replace Utility
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:26',
+		'docstatus': 0,
+		'modified': '2010-12-23 14:40:02',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'in_create': 0,
+		'issingle': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'read_only': 0,
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'version': 25
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Stock UOM Replace Utility',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Stock UOM Replace Utility',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Stock UOM Replace Utility
+	{
+		'doctype': 'DocType',
+		'name': 'Stock UOM Replace Utility'
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1,
+		'role': 'System Manager',
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 0,
+		'role': 'Material Master Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 1,
+		'role': 'Material Master Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Material Manager'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'item_code',
+		'fieldtype': 'Link',
+		'idx': 1,
+		'label': 'Item',
+		'options': 'Item',
+		'permlevel': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'current_stock_uom',
+		'fieldtype': 'Link',
+		'idx': 2,
+		'label': 'Current Stock UOM',
+		'options': 'UOM',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'new_stock_uom',
+		'fieldtype': 'Link',
+		'idx': 3,
+		'label': 'New Stock UOM',
+		'options': 'UOM',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 5,
+		'label': 'Update',
+		'options': 'update_stock_uom',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'conversion_factor',
+		'fieldtype': 'Currency',
+		'idx': 11,
+		'label': 'Conversion Factor',
+		'permlevel': 0
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/uom_conversion_detail/__init__.py b/stock/doctype/uom_conversion_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/uom_conversion_detail/__init__.py
diff --git a/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt b/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt
new file mode 100644
index 0000000..14608be
--- /dev/null
+++ b/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt
@@ -0,0 +1,65 @@
+# DocType, UOM Conversion Detail
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:29',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'autoname': 'UCDD/.#####',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'istable': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Tray',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 1
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'UOM Conversion Detail',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# DocType, UOM Conversion Detail
+	{
+		'doctype': 'DocType',
+		'name': 'UOM Conversion Detail'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'uom',
+		'fieldtype': 'Link',
+		'idx': 10,
+		'label': 'UOM',
+		'oldfieldname': 'uom',
+		'oldfieldtype': 'Link',
+		'options': 'UOM'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'conversion_factor',
+		'fieldtype': 'Float',
+		'idx': 11,
+		'label': 'Conversion Factor',
+		'oldfieldname': 'conversion_factor',
+		'oldfieldtype': 'Float'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/valuation_control/__init__.py b/stock/doctype/valuation_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/valuation_control/__init__.py
diff --git a/stock/doctype/valuation_control/valuation_control.py b/stock/doctype/valuation_control/valuation_control.py
new file mode 100644
index 0000000..131c71b
--- /dev/null
+++ b/stock/doctype/valuation_control/valuation_control.py
@@ -0,0 +1,83 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+
+	# Get FIFO Rate from Stack
+	# -------------------------
+	def get_fifo_rate(self, fcfs_stack, qty):
+		fcfs_val = 0
+		withdraw = flt(qty)
+		while withdraw:
+			batch = fcfs_stack[0]				
+			if batch[0] <= withdraw:
+				# not enough or exactly same qty in current batch, clear batch
+				withdraw -= batch[0]
+				fcfs_val += (flt(batch[0]) * flt(batch[1]))
+				fcfs_stack.pop(0)
+			else:
+				# all from current batch
+				fcfs_val += (flt(withdraw) * flt(batch[1]))
+				batch[0] -= withdraw
+				withdraw = 0
+		fcfs_rate = flt(fcfs_val) / flt(qty)
+		return fcfs_rate
+
+	# --------------------------------
+	# get serializable inventory rate
+	# --------------------------------
+	def get_serializable_inventory_rate(self, serial_no):
+		sr_nos = get_obj("Stock Ledger").get_sr_no_list(serial_no)
+		tot = 0
+		for s in sr_nos:
+			serial_no = s.strip()
+			tot += flt(get_value('Serial No', serial_no, 'purchase_rate'))
+		return tot / len(sr_nos)
+
+
+	# ---------------------
+	# get valuation method
+	# ---------------------
+	def get_valuation_method(self, item_code):
+		val_method = webnotes.conn.get_value('Item', item_code, 'valuation_method')
+		if not val_method:
+			val_method = get_defaults().get('valuation_method', 'FIFO')
+		return val_method
+		
+
+	# Get Incoming Rate based on valuation method
+	# --------------------------------------------
+	def get_incoming_rate(self, posting_date, posting_time, item, warehouse, qty = 0, serial_no = ''):
+		in_rate = 0
+		val_method = self.get_valuation_method(item)
+		bin_obj = get_obj('Warehouse',warehouse).get_bin(item)
+		if serial_no:
+			in_rate = self.get_serializable_inventory_rate(serial_no)
+		elif val_method == 'FIFO':
+			in_rate = 0
+			if qty:
+				prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
+				fcfs_stack = eval(prev_sle.get('fcfs_stack', '[]') or '[]')
+				in_rate = fcfs_stack and self.get_fifo_rate(fcfs_stack, qty) or 0
+		elif val_method == 'Moving Average':
+			prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
+			in_rate = prev_sle and prev_sle.get('valuation_rate', 0) or 0
+		return in_rate
diff --git a/stock/doctype/valuation_control/valuation_control.py~ b/stock/doctype/valuation_control/valuation_control.py~
new file mode 100644
index 0000000..82e7fb9
--- /dev/null
+++ b/stock/doctype/valuation_control/valuation_control.py~
@@ -0,0 +1,87 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+
+	# Get FIFO Rate from Stack
+	# -------------------------
+	def get_fifo_rate(self, fcfs_stack, qty):
+		fcfs_val = 0
+		withdraw = flt(qty)
+		while withdraw:
+			batch = fcfs_stack[0]				
+			if batch[0] <= withdraw:
+				# not enough or exactly same qty in current batch, clear batch
+				withdraw -= batch[0]
+				fcfs_val += (flt(batch[0]) * flt(batch[1]))
+				fcfs_stack.pop(0)
+			else:
+				# all from current batch
+				fcfs_val += (flt(withdraw) * flt(batch[1]))
+				batch[0] -= withdraw
+				withdraw = 0
+		fcfs_rate = flt(fcfs_val) / flt(qty)
+		return fcfs_rate
+
+	# --------------------------------
+	# get serializable inventory rate
+	# --------------------------------
+	def get_serializable_inventory_rate(self, serial_no):
+		sr_nos = get_obj("Stock Ledger").get_sr_no_list(serial_no)
+		tot = 0
+		for s in sr_nos:
+			serial_no = s.strip()
+			tot += flt(get_value('Serial No', serial_no, 'purchase_rate'))
+		return tot / len(sr_nos)
+
+
+	# ---------------------
+	# get valuation method
+	# ---------------------
+	def get_valuation_method(self, item_code):
+		val_method = webnotes.conn.get_value('Item', item_code, 'valuation_method')
+		if not val_method:
+			val_method = get_defaults().get('valuation_method', 'FIFO')
+		return val_method
+		
+
+	# Get Incoming Rate based on valuation method
+	# --------------------------------------------
+	def get_incoming_rate(self, posting_date, posting_time, item, warehouse, qty = 0, serial_no = ''):
+		msgprint(1)
+		in_rate = 0
+		val_method = self.get_valuation_method(item)
+		bin_obj = get_obj('Warehouse',warehouse).get_bin(item)
+		if serial_no:
+			in_rate = self.get_serializable_inventory_rate(serial_no)
+		elif val_method == 'FIFO':
+			in_rate = 0
+			if qty:
+				prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
+				msgprint(prev_sle)
+				fcfs_stack = eval(prev_sle.get('fcfs_stack', '[]') or '[]')
+				msgprint(fcfs_stack)
+				in_rate = fcfs_stack and self.get_fifo_rate(fcfs_stack, qty) or 0
+				msgprint(in_rate)
+		elif val_method == 'Moving Average':
+			prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
+			in_rate = prev_sle and prev_sle.get('valuation_rate', 0) or 0
+		return in_rate
diff --git a/stock/doctype/valuation_control/valuation_control.txt b/stock/doctype/valuation_control/valuation_control.txt
new file mode 100644
index 0000000..c2a2935
--- /dev/null
+++ b/stock/doctype/valuation_control/valuation_control.txt
@@ -0,0 +1,31 @@
+# DocType, Valuation Control
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:30',
+		'docstatus': 0,
+		'modified': '2010-12-23 11:18:22',
+		'modified_by': 'umair@iwebnotes.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'in_create': 1,
+		'issingle': 1,
+		'module': 'Stock',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'version': 4
+	},
+
+	# DocType, Valuation Control
+	{
+		'doctype': 'DocType',
+		'name': 'Valuation Control'
+	}
+]
\ No newline at end of file
diff --git a/stock/doctype/warehouse/__init__.py b/stock/doctype/warehouse/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/doctype/warehouse/__init__.py
diff --git a/stock/doctype/warehouse/warehouse.js b/stock/doctype/warehouse/warehouse.js
new file mode 100644
index 0000000..a418027
--- /dev/null
+++ b/stock/doctype/warehouse/warehouse.js
@@ -0,0 +1,13 @@
+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');
+      }
+    }  
+  );
+}
diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py
new file mode 100644
index 0000000..51c615c
--- /dev/null
+++ b/stock/doctype/warehouse/warehouse.py
@@ -0,0 +1,90 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+  def __init__(self, doc, doclist=[]):
+    self.doc = doc
+    self.doclist = doclist
+    
+  def get_bin(self, item_code):
+    bin = sql("select name from tabBin where item_code = '%s' and warehouse = '%s'" % (item_code, self.doc.name))
+    bin = bin and bin[0][0] or ''
+    if not bin:
+      if not self.doc.warehouse_type :
+        msgprint("[Warehouse Type is Mandatory] Please Enter warehouse type in Warehouse " + self.doc.name)
+        raise Exception
+      bin = Document('Bin')
+      bin.item_code = item_code
+      bin.stock_uom = get_value('Item', item_code, 'stock_uom')
+      bin.warehouse = self.doc.name
+      bin.warehouse_type = self.doc.warehouse_type
+      bin_obj = get_obj(doc=bin)
+      bin_obj.validate()
+      bin.save(1)
+      bin = bin.name
+    else:
+      bin_obj = get_obj('Bin',bin)
+
+    return bin_obj
+  
+
+  def validate_asset(self, item_code):
+    if sql("select is_asset_item from tabItem where name=%s", item_code)[0][0] == 'Yes' and self.doc.warehouse_type != 'Fixed Asset':
+      msgprint("Fixed Asset Item %s can only be transacted in a Fixed Asset type Warehouse" % item_code)
+      raise Exception
+
+
+  # update bin
+  # ----------
+  def update_bin(self, actual_qty, reserved_qty, ordered_qty, indented_qty, planned_qty, item_code, dt, sle_id = '',posting_time = '', serial_no = '', is_cancelled = 'No'):
+    self.validate_asset(item_code)
+    it_det = get_value('Item', item_code, 'is_stock_item')
+    if it_det and it_det == 'Yes':
+      bin = self.get_bin(item_code)
+      bin.update_stock(actual_qty, reserved_qty, ordered_qty, indented_qty, planned_qty, dt, sle_id, posting_time, serial_no, is_cancelled)
+      return bin
+    else:
+      msgprint("[Stock Update] Ignored %s since it is not a stock item" % item_code)
+
+  # repost stock
+  # ------------
+  def repost_stock(self):
+    bl = sql("select name from tabBin where warehouse=%s", self.doc.name)
+    for b in bl:
+      bobj = get_obj('Bin',b[0])
+      bobj.update_item_valuation()
+
+      sql("COMMIT")
+      sql("START TRANSACTION")
+
+  def check_state(self):
+    return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
+
+  def validate(self):
+    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.warehouse_type:
+      msgprint("[Warehouse Type is Mandatory] Please Enter  Please Entry warehouse type in Warehouse " + self.doc.name)
+      raise Exception
+    wt = sql("select warehouse_type from `tabWarehouse` where name ='%s'" % self.doc.name)
+    if cstr(self.doc.warehouse_type) != cstr(wt and wt[0][0] or ''):
+      sql("update `tabStock Ledger Entry` set warehouse_type = '%s' where warehouse = '%s'" % (self.doc.warehouse_type, self.doc.name))
+      msgprint("All Stock Ledger Entries Updated.")
diff --git a/stock/doctype/warehouse/warehouse.txt b/stock/doctype/warehouse/warehouse.txt
new file mode 100644
index 0000000..3d69b07
--- /dev/null
+++ b/stock/doctype/warehouse/warehouse.txt
@@ -0,0 +1,460 @@
+# DocType, Warehouse
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:09:30',
+		'docstatus': 0,
+		'modified': '2010-12-16 23:57:04',
+		'modified_by': 'nabin@webnotestech.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1300788639',
+		'allow_trash': 1,
+		'autoname': 'field:warehouse_name',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Master',
+		'module': 'Stock',
+		'name': '__common__',
+		'search_fields': 'warehouse_type',
+		'section_style': 'Tabbed',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 55
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Warehouse',
+		'parentfield': 'fields',
+		'parenttype': 'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Warehouse',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1
+	},
+
+	# DocType, Warehouse
+	{
+		'doctype': 'DocType',
+		'name': 'Warehouse'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 2,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 0,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'permlevel': 1,
+		'role': 'Material User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 4,
+		'permlevel': 2,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 5,
+		'permlevel': 0,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 6,
+		'permlevel': 1,
+		'role': 'Material Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 7,
+		'permlevel': 1,
+		'role': 'All'
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 8,
+		'permlevel': 0,
+		'role': 'Material Master Manager',
+		'submit': 0,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 9,
+		'permlevel': 1,
+		'role': 'Material Master Manager'
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 10,
+		'permlevel': 0,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 11,
+		'permlevel': 2,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'trash_reason',
+		'fieldtype': 'Small Text',
+		'idx': 1,
+		'label': 'Trash Reason',
+		'oldfieldname': 'trash_reason',
+		'oldfieldtype': 'Small Text',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 2,
+		'label': 'Warehouse Detail',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'warehouse_name',
+		'fieldtype': 'Data',
+		'idx': 3,
+		'label': 'Warehouse Name',
+		'oldfieldname': 'warehouse_name',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'warehouse_type',
+		'fieldtype': 'Link',
+		'idx': 4,
+		'label': 'Warehouse Type',
+		'oldfieldname': 'warehouse_type',
+		'oldfieldtype': 'Link',
+		'options': 'Warehouse Type',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'The valuation of items in this warehouse will be considered for the company that is specified',
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Link',
+		'idx': 5,
+		'in_filter': 1,
+		'label': 'Company',
+		'oldfieldname': 'company',
+		'oldfieldtype': 'Link',
+		'options': 'Company',
+		'permlevel': 0,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'email_id',
+		'fieldtype': 'Data',
+		'hidden': 1,
+		'idx': 6,
+		'label': 'Email Id',
+		'oldfieldname': 'email_id',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'auto_indent_mail',
+		'fieldtype': 'Select',
+		'hidden': 1,
+		'idx': 7,
+		'label': 'Send Reorder Alert Mail ',
+		'no_copy': 1,
+		'oldfieldname': 'auto_indent_mail',
+		'oldfieldtype': 'Select',
+		'options': 'No\nYes',
+		'permlevel': 0,
+		'print_hide': 1,
+		'report_hide': 1,
+		'reqd': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'phone_no',
+		'fieldtype': 'Int',
+		'idx': 8,
+		'label': 'Phone No',
+		'oldfieldname': 'phone_no',
+		'oldfieldtype': 'Int',
+		'options': 'Phone',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'mobile_no',
+		'fieldtype': 'Int',
+		'idx': 9,
+		'label': 'Mobile No',
+		'oldfieldname': 'mobile_no',
+		'oldfieldtype': 'Int',
+		'options': 'Phone',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 10,
+		'oldfieldtype': 'Column Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'address_line_1',
+		'fieldtype': 'Data',
+		'idx': 11,
+		'label': 'Address Line 1',
+		'oldfieldname': 'address_line_1',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'address_line_2',
+		'fieldtype': 'Data',
+		'idx': 12,
+		'label': 'Address Line 2',
+		'oldfieldname': 'address_line_2',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'allow_on_submit': 0,
+		'doctype': 'DocField',
+		'fieldname': 'country',
+		'fieldtype': 'Link',
+		'hidden': 0,
+		'idx': 13,
+		'in_filter': 0,
+		'label': 'Country',
+		'no_copy': 0,
+		'oldfieldname': 'country',
+		'oldfieldtype': 'Link',
+		'options': 'Country',
+		'permlevel': 0,
+		'print_hide': 0,
+		'report_hide': 0,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'state',
+		'fieldtype': 'Select',
+		'idx': 14,
+		'label': 'State',
+		'oldfieldname': 'state',
+		'oldfieldtype': 'Select',
+		'options': '\nSelect country first',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'city',
+		'fieldtype': 'Data',
+		'idx': 15,
+		'label': 'City',
+		'oldfieldname': 'city',
+		'oldfieldtype': 'Data',
+		'permlevel': 0,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'pin',
+		'fieldtype': 'Int',
+		'idx': 16,
+		'label': 'PIN',
+		'oldfieldname': 'pin',
+		'oldfieldtype': 'Int',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 17,
+		'label': 'Repost Stock',
+		'oldfieldtype': 'Section Break',
+		'permlevel': 2
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'idx': 18,
+		'label': 'Repost Stock Ledger',
+		'oldfieldtype': 'Button',
+		'options': 'repost_stock',
+		'permlevel': 2
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'test_field2',
+		'fieldtype': 'Data',
+		'idx': 19,
+		'label': 'Test Field2',
+		'oldfieldname': 'test_field2',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'test_field1',
+		'fieldtype': 'Data',
+		'idx': 20,
+		'label': 'Test Field1',
+		'oldfieldname': 'test_field1',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'test_field',
+		'fieldtype': 'Data',
+		'idx': 21,
+		'label': 'Test Field',
+		'oldfieldname': 'test_field',
+		'oldfieldtype': 'Data',
+		'permlevel': 0
+	}
+]
\ No newline at end of file
diff --git a/stock/page/__init__.py b/stock/page/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/page/__init__.py
diff --git a/stock/search_criteria/__init__.py b/stock/search_criteria/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/__init__.py
diff --git a/stock/search_criteria/itemwise_price_list/__init__.py b/stock/search_criteria/itemwise_price_list/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/itemwise_price_list/__init__.py
diff --git a/stock/search_criteria/itemwise_price_list/itemwise_price_list.js b/stock/search_criteria/itemwise_price_list/itemwise_price_list.js
new file mode 100644
index 0000000..83be08c
--- /dev/null
+++ b/stock/search_criteria/itemwise_price_list/itemwise_price_list.js
@@ -0,0 +1,3 @@
+report.customize_filters = function() {
+  this.filter_fields_dict['Item'+FILTER_SEP +'ID'].df.in_first_page = 1;
+}
\ No newline at end of file
diff --git a/stock/search_criteria/itemwise_price_list/itemwise_price_list.txt b/stock/search_criteria/itemwise_price_list/itemwise_price_list.txt
new file mode 100644
index 0000000..6c6a2e7
--- /dev/null
+++ b/stock/search_criteria/itemwise_price_list/itemwise_price_list.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Item\x01Item Name,Item\x01Item Group,Ref Rate Detail\x01Price List Name,Ref Rate Detail\x01Ref Rate,Ref Rate Detail\x01Currency',
+		'creation': '2010-08-20 12:20:55',
+		'criteria_name': 'Itemwise Price List',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Ref Rate Detail',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Item\x01Saved':1,'Ref Rate Detail\x01Price List Name':'','Ref Rate Detail\x01Currency':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-08-20 12:15:17',
+		'modified_by': 'Administrator',
+		'module': 'Material Management',
+		'name': 'itemwise_price_list',
+		'owner': 'harshada@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': 'Item',
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabItem`.`item_name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/stock/search_criteria/shortage_to_indent/__init__.py b/stock/search_criteria/shortage_to_indent/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/shortage_to_indent/__init__.py
diff --git a/stock/search_criteria/shortage_to_indent/shortage_to_indent.js b/stock/search_criteria/shortage_to_indent/shortage_to_indent.js
new file mode 100644
index 0000000..3c0f8bf
--- /dev/null
+++ b/stock/search_criteria/shortage_to_indent/shortage_to_indent.js
@@ -0,0 +1,11 @@
+report.customize_filters = function() {
+
+  this.add_filter({fieldname:'posting_date', label:'Posting Date', fieldtype:'Date', ignore : 1, parent:'Item'});
+  //this.add_filter({fieldname:'weekly_working_days', label:'Weekly Working Days', fieldtype:'Select', options:NEWLINE+1+NEWLINE+2+NEWLINE+3+NEWLINE+4+NEWLINE+5+NEWLINE+6+NEWLINE+7, ignore : 1, parent:'Item'});
+
+  this.filter_fields_dict['Item'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
+  this.filter_fields_dict['Item'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
+  //this.filter_fields_dict['Item'+FILTER_SEP +'Weekly Working Days'].df.in_first_page = 1;
+
+
+}
\ No newline at end of file
diff --git a/stock/search_criteria/shortage_to_indent/shortage_to_indent.py b/stock/search_criteria/shortage_to_indent/shortage_to_indent.py
new file mode 100644
index 0000000..75b3f3f
--- /dev/null
+++ b/stock/search_criteria/shortage_to_indent/shortage_to_indent.py
@@ -0,0 +1,132 @@
+mon_list = []
+data = {'start_date':0, 'end_date':1, 'working_days': 2}
+
+def make_month_list(start_date, end_date, mon_list, colnames, coltypes, colwidths, coloptions, col_idx):
+
+  # get period between from date and to date
+
+  period_diff = sql("select PERIOD_DIFF('%s','%s')"% (('').join( end_date.split('-')[i] for i in range(len(end_date.split('-')) - 1)),('').join(start_date.split('-')[i] for i in range(len(start_date.split('-')) - 1))))
+  period_diff = period_diff and int(period_diff[0][0])
+
+  for pd in range(int(period_diff) + 1):
+    # get last date
+    last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
+      
+    # get no of days in the month            
+    if not int(sql("select DATEDIFF('%s','%s')" % (end_date, last_date))[0][0]) >0:
+      last_date = end_date
+    diff = int(sql("select DATEDIFF('%s','%s')" % (last_date, start_date))[0][0]) + 1
+      
+    # make mon_list
+    mon_list.append([start_date, last_date, (diff > 26) and 26 or diff])
+           
+    # add months as Column names
+    month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
+  
+    colnames.append(str(str(month_name)[:3])+ '-'+ str(start_date[:4]))
+    coltypes.append('Currency')
+    colwidths.append('150px')
+    coloptions.append('')
+    col_idx[str(str(month_name)[:3])+ '-'+ str(start_date[:4])] = len(colnames) - 1
+
+    # get start date
+    start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
+
+# Validation for 'ID' and 'Lead Time Days' Column Name
+if 'ID' not in colnames or 'Lead Time Days' not in colnames:
+  msgprint("Please select Id and Lead Time Days in 'Select Columns' tab Else Report will not be generated")
+  raise Exception
+
+# Validation for Posting Date Filters
+if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
+  msgprint("Please select From Posting Date and To Posting Date")
+  raise Exception
+else:
+  from_date = str(filter_values.get('posting_date'))
+  to_date = str(filter_values.get('posting_date1'))
+
+
+# Call Make Month List Function
+make_month_list(from_date, to_date, mon_list, colnames, coltypes, colwidths, coloptions, col_idx)
+
+
+# Add Column names 
+col = [['Total Daily Consumption','Currency','150px','']
+      ,['MIL(Min Inv. Level)','Currency','150px','']
+      ,['ROL(Re-Order Level)','Currency','150px','']
+      ,['Actual Quantity','Currency','150px','']
+      ,['Indented Quantity','Currency','150px','']
+      ,['Ordered Quantity','Currency','150px','']
+      ,['Shortage To Indent','Currency','150px','']
+      ,['MAR','Currency','100px','']
+      ,['LPR','Currency','100px','']]
+
+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
+
+for r in res:
+
+  # calculate Total Daily Consumption Monthly
+  count, tot_consumption, tot_days = 0, 0, 1
+  #for idx in range(col_idx['Stock Unit of Measurement'] + 1 , col_idx['Total Daily Consumption'] ):
+  for idx in range(col_idx['Lead Time Days'] + 1 , col_idx['Total Daily Consumption'] ):
+  
+    # As Consumption Means:= Adding Qty Transfered to WIP Warehouse ++ Qty Issued directly warehouse whose waraehouse_type != WIP Warehouse and Subtracting Qty Issued from WIP Warehouse
+    #Capture item qty coming to WIP Warehouse for production purpose which means consuming that items
+    add_con = sql("select ifnull(sum(t1.actual_qty),0)  from `tabStock Ledger Entry` t1 where t1.item_code = '%s' and t1.is_cancelled = 'No'  and t1.posting_date >= '%s' and t1.posting_date <= '%s' and t1.warehouse_type = 'WIP Warehouse' and t1.actual_qty > 0 " % (r[col_idx['ID']],mon_list[count][data['start_date']],mon_list[count][data['end_date']]))
+    
+    # This is Stock Entry which is of Type Material Issue also to mention that Source Warehouse should not be WIP WArehouse
+    #Transfering items to Internal Other Warehouse but not to WIP Warehouse
+    dir_con = sql("select ifnull(sum(t1.actual_qty),0) from `tabStock Ledger Entry` t1, `tabStock Entry Detail` t2 where t1.item_code = '%s' and t1.is_cancelled = 'No' and t1.posting_date >= '%s' and t1.posting_date <= '%s' and t1.warehouse_type != 'WIP Warehouse' and t1.actual_qty < 0 and t1.voucher_type = 'Stock Entry' and t1.voucher_detail_no = t2.name and ifnull(t2.t_warehouse, '') = ''"%(r[col_idx['ID']],mon_list[count][data['start_date']],mon_list[count][data['end_date']]))
+    
+    # This is Stock Entry which is of Type MAterial TRansfer also to mention that Source Warehouse should be WIP WArhouse
+    #like, transfering items from internal warehouse to customer
+    red_con = sql("select ifnull(sum(t1.actual_qty),0) from `tabStock Ledger Entry` t1, `tabStock Entry Detail` t2 where t1.item_code = '%s' and t1.is_cancelled = 'No'  and t1.posting_date >= '%s' and t1.posting_date <= '%s' and t1.warehouse_type = 'WIP Warehouse' and t1.actual_qty < 0 and t1.voucher_type = 'Stock Entry' and t1.voucher_detail_no = t2.name and ifnull(t2.t_warehouse, '') != ''"%(r[col_idx['ID']],mon_list[count][data['start_date']],mon_list[count][data['end_date']]))
+    #msgprint(str(add_con[0][0]) + "~~~" + str(dir_con[0][0]) + "~~~" + str(red_con[0][0]))
+
+    add_con = add_con and add_con[0][0] or 0.00
+    dir_con = dir_con and ((-1) * dir_con[0][0]) or 0.00
+    red_con = red_con and red_con[0][0] or 0.00
+    tot_con = flt(add_con) + flt(dir_con) + flt(red_con)
+    #tot_con = add_con and add_con[0][0] or 0 + dir_con and (-1) * dir_con[0][0] or 0 +  red_con and red_con[0][0] or 0
+    tot_con = flt(r[col_idx['Lead Time Days']] and tot_con  or 0)
+
+
+    # monthly avg consumption
+    r.append(flt(tot_con / mon_list[count][data['working_days']]))
+
+    # calculate tot_consumption and tot_days   
+    tot_consumption = flt(tot_consumption) + flt(tot_con)
+    tot_days = (tot_days == 1) and flt(mon_list[count][data['working_days']]) or (flt(tot_days) + flt(mon_list[count][data['working_days']]))
+    count = count + 1  
+
+  # Calculate Daily Consumption
+  r.append(tot_consumption and flt(tot_consumption /tot_days) or 0)
+
+  # Calculate Minimum Inventory Level
+  r.append(flt(r[col_idx['Total Daily Consumption']]) * flt(r[col_idx['Lead Time Days']]))
+ 
+  # Calculate Re-Order Level
+  r.append(flt(r[col_idx['MIL(Min Inv. Level)']] * 2))
+
+  # get stock level
+  stock_level = sql("select sum(t1.actual_qty), sum(t1.indented_qty), sum(t1.ordered_qty) from `tabBin` t1, `tabWarehouse` t2 where t1.warehouse = t2.name and t2.warehouse_type != 'WIP Warehouse' and t1.item_code = '%s'"%(r[col_idx['ID']]))
+ 
+  r.append(stock_level and flt(stock_level[0][0]) or 0) # Actual Qty
+  r.append(stock_level and flt(stock_level[0][1]) or 0) # Indented Qty
+  r.append(stock_level and flt(stock_level[0][2]) or 0) # Ordered Qty
+  
+  # calculate shortage
+  r.append((r[col_idx['ROL(Re-Order Level)']] > 0) and flt(flt(r[col_idx['ROL(Re-Order Level)']]) - flt(r[col_idx['Actual Quantity']]) - flt(r[col_idx['Indented Quantity']]) - flt(r[col_idx['Ordered Quantity']])) or 0)
+
+  # get moving average rate
+  m_a_r = sql("select ifnull(sum(t1.ma_rate), 0)/ ifnull(count(t1.name),1) from `tabBin` t1, `tabWarehouse` t2 where t1.item_code = '%s' and ifnull(t1.ma_rate, 0) > 0 and t1.warehouse = t2.name and t2.warehouse_type != 'WIP Warehouse'" % r[col_idx['ID']])
+  r.append(m_a_r and flt(m_a_r[0][0]) or 0)
+    
+  # get recent last purchase rate 
+  lpr_rate = flt(sql("select last_purchase_rate from `tabItem` where name = '%s'" %r[col_idx['ID']])[0][0]) or 0.00
+  r.append(lpr_rate)
diff --git a/stock/search_criteria/shortage_to_indent/shortage_to_indent.txt b/stock/search_criteria/shortage_to_indent/shortage_to_indent.txt
new file mode 100644
index 0000000..2ac52a1
--- /dev/null
+++ b/stock/search_criteria/shortage_to_indent/shortage_to_indent.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Item\x01ID,Item\x01Item Name,Item\x01Description,Item\x01Lead Time Days',
+		'creation': '2011-05-25 12:44:22',
+		'criteria_name': 'Shortage To Indent',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Item',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Item\x01Saved':1}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2011-05-18 11:52:59',
+		'modified_by': 'Guest',
+		'module': 'Material Management',
+		'name': 'shortage_to_indent',
+		'owner': 'wasim@webnotestech.com',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabItem`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_aging_report/__init__.py b/stock/search_criteria/stock_aging_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/stock_aging_report/__init__.py
diff --git a/stock/search_criteria/stock_aging_report/stock_aging_report.js b/stock/search_criteria/stock_aging_report/stock_aging_report.js
new file mode 100644
index 0000000..194990a
--- /dev/null
+++ b/stock/search_criteria/stock_aging_report/stock_aging_report.js
@@ -0,0 +1,12 @@
+report.customize_filters = function() {
+  //this.hide_all_filters();
+
+  this.filter_fields_dict['Serial No'+FILTER_SEP +'Status'].df.filter_hide = 1;
+
+  this.filter_fields_dict['Serial No'+FILTER_SEP +'ID'].df.in_first_page = 1;
+  this.filter_fields_dict['Serial No'+FILTER_SEP +'From Purchase Date'].df.in_first_page = 1;
+  this.filter_fields_dict['Serial No'+FILTER_SEP +'To Purchase Date'].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/stock/search_criteria/stock_aging_report/stock_aging_report.py b/stock/search_criteria/stock_aging_report/stock_aging_report.py
new file mode 100644
index 0000000..42b0cc3
--- /dev/null
+++ b/stock/search_criteria/stock_aging_report/stock_aging_report.py
@@ -0,0 +1,15 @@
+col = [['In Store Period (in days)', 'Data', '']]
+for c in col:
+  colnames.append(str(c[0]))
+  coltypes.append(str(c[1]))
+  colwidths.append('150px')
+  coloptions.append(str(c[2]))
+  col_idx[str(c)] = len(colnames) - 1
+
+import datetime
+for r in res:
+  if r[col_idx['Purchase Date']]:
+    dt = (datetime.date.today() - getdate(r[col_idx['Purchase Date']])).days
+  else:
+    dt = ''
+  r.append(dt)
\ No newline at end of file
diff --git a/stock/search_criteria/stock_aging_report/stock_aging_report.txt b/stock/search_criteria/stock_aging_report/stock_aging_report.txt
new file mode 100644
index 0000000..ab5ab76
--- /dev/null
+++ b/stock/search_criteria/stock_aging_report/stock_aging_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': '',
+		'add_cond': "`tabSerial No`.status = 'In Store'",
+		'add_tab': None,
+		'columns': 'Serial No\x01ID,Serial No\x01Item Code,Serial No\x01Description,Serial No\x01Item Group,Serial No\x01Purchase Date',
+		'creation': '2010-09-01 15:47:57',
+		'criteria_name': 'Stock Aging Report',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Serial No',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Serial No\x01Saved':1,'Serial No\x01Submitted':1,'Serial No\x01Status':'In Store','Serial No\x01Maintenance Status':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-08-16 13:42:24',
+		'modified_by': 'Administrator',
+		'module': 'Material Management',
+		'name': 'stock_aging_report',
+		'owner': 'ashwini@webnotestech.com',
+		'page_len': 1000,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabSerial No`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_ledger/__init__.py b/stock/search_criteria/stock_ledger/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/stock_ledger/__init__.py
diff --git a/stock/search_criteria/stock_ledger/stock_ledger.js b/stock/search_criteria/stock_ledger/stock_ledger.js
new file mode 100644
index 0000000..89e1dbc
--- /dev/null
+++ b/stock/search_criteria/stock_ledger/stock_ledger.js
@@ -0,0 +1,4 @@
+report.customize_filters = function() {
+  this.add_filter({fieldname:'item_name', label:'Item Name', fieldtype:'Data', options:'', parent:'Item'});
+  this.add_filter({fieldname:'description', label:'Description', fieldtype:'Small Text', options: '', parent:'Item'});
+}
\ No newline at end of file
diff --git a/stock/search_criteria/stock_ledger/stock_ledger.txt b/stock/search_criteria/stock_ledger/stock_ledger.txt
new file mode 100644
index 0000000..8185138
--- /dev/null
+++ b/stock/search_criteria/stock_ledger/stock_ledger.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': '`tabItem`.`item_name`\n`tabItem`.`description`',
+		'add_cond': '`tabItem`.`name` = `tabStock Ledger Entry`.`item_code`',
+		'add_tab': '`tabItem`',
+		'columns': 'Stock Ledger Entry\x01Item Code,Stock Ledger Entry\x01Warehouse,Stock Ledger Entry\x01Posting Date,Stock Ledger Entry\x01Voucher Detail No,Stock Ledger Entry\x01Actual Quantity,Stock Ledger Entry\x01Bin Actual Qty After Transaction',
+		'creation': '2010-10-14 08:43:04',
+		'criteria_name': 'Stock Ledger',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Stock Ledger Entry',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Stock Ledger Entry\x01Is Cancelled':'','Stock Ledger Entry\x01Is Stock Entry':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-10-14 08:31:40',
+		'modified_by': 'Administrator',
+		'module': 'Material Management',
+		'name': 'stock_ledger',
+		'owner': 'Administrator',
+		'page_len': None,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': None,
+		'sort_order': None,
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_level/__init__.py b/stock/search_criteria/stock_level/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/stock_level/__init__.py
diff --git a/stock/search_criteria/stock_level/stock_level.js b/stock/search_criteria/stock_level/stock_level.js
new file mode 100644
index 0000000..e84fe57
--- /dev/null
+++ b/stock/search_criteria/stock_level/stock_level.js
@@ -0,0 +1,4 @@
+report.customize_filters = function() {
+  this.add_filter({fieldname:'item_name', label:'Item Name', fieldtype:'Data', options:'', parent:'Item', in_first_page : 1});
+  this.add_filter({fieldname:'description', label:'Description', fieldtype:'Small Text', options: '', parent:'Item', in_first_page : 1});
+}
\ No newline at end of file
diff --git a/stock/search_criteria/stock_level/stock_level.py b/stock/search_criteria/stock_level/stock_level.py
new file mode 100644
index 0000000..4aa397c
--- /dev/null
+++ b/stock/search_criteria/stock_level/stock_level.py
@@ -0,0 +1,2 @@
+colwidths[col_idx['Reserved Quantity']]= "120px" 
+colwidths[col_idx['Ordered Quantity']] = "120px"
\ No newline at end of file
diff --git a/stock/search_criteria/stock_level/stock_level.txt b/stock/search_criteria/stock_level/stock_level.txt
new file mode 100644
index 0000000..7c87ec0
--- /dev/null
+++ b/stock/search_criteria/stock_level/stock_level.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': '`tabItem`.`item_name`\n`tabItem`.`description`',
+		'add_cond': '`tabItem`.name = `tabBin`.item_code',
+		'add_tab': '`tabItem`',
+		'columns': 'Bin\x01Warehouse,Bin\x01Item Code,Bin\x01UOM,Bin\x01Reserved Quantity,Bin\x01Actual Quantity,Bin\x01Ordered Quantity,Bin\x01Planned Qty,Bin\x01Projected Qty,Bin\x01Indented Quantity,Bin\x01Valuation Rate,Bin\x01Stock Value',
+		'creation': '2010-12-14 10:33:08',
+		'criteria_name': 'Stock Level',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Bin',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': '{}',
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-10-20 16:51:11',
+		'modified_by': 'Administrator',
+		'module': 'Material Management',
+		'name': 'stock_level',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabBin`.`warehouse`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_report/__init__.py b/stock/search_criteria/stock_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/search_criteria/stock_report/__init__.py
diff --git a/stock/search_criteria/stock_report/stock_report.js b/stock/search_criteria/stock_report/stock_report.js
new file mode 100644
index 0000000..9304bd4
--- /dev/null
+++ b/stock/search_criteria/stock_report/stock_report.js
@@ -0,0 +1,74 @@
+//233
+report.customize_filters = function() {
+  this.mytabs.items['Select Columns'].hide()
+  this.mytabs.items['More Filters'].hide()
+  this.hide_all_filters();
+  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Warehouse'+NEWLINE+'Item Code',report_default:'Warehouse',ignore : 1,parent:'Stock Ledger Entry'});
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.filter_hide = 0;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse Type'].df.filter_hide = 0;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 1;
+
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.in_first_page = 1;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Based On'].df.in_first_page = 1;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse Type'].df.in_first_page = 1;
+  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
+}
+
+
+report.get_query = function(){
+  based_on = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Based On'].get_value();
+  as_on = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'To Posting Date'].get_value();
+  warehouse = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Warehouse'].get_value();
+  warehouse_type = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Warehouse Type'].get_value();
+  item_code = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Item Code'].get_value();
+
+  cond = '';
+  date_cond = '';
+  tables = '';
+  cols = '';
+  group_by = '';
+  ware_type_cond = '';
+  war = '';
+  if(!as_on) as_on = get_today();
+
+  date_cond = repl(' AND `tabStock Ledger Entry`.posting_date <= "%(as_on)s" ', {as_on:as_on});
+
+  if(warehouse_type.length > 0 && warehouse_type != ''){
+    for(var i = 0; i<warehouse_type.length; i++) war += "'"+warehouse_type[i]+"',";
+    ware_type_cond = repl(' AND `tabWarehouse`.warehouse_type IN (%(war)s)', {war: war.substr(0,war.length-1)})
+  }
+  
+  if(based_on.length == 1){
+    if(based_on == 'Item Code'){
+      cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM"';
+      cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes"';
+      if(item_code) cond += repl(' AND `tabItem`.name = %(item)s', {item:'"'+item_code+'"'});
+      cond += ' AND `tabStock Ledger Entry`.item_code = `tabItem`.name'
+      tables = '`tabItem`';
+      group_by = '`tabStock Ledger Entry`.item_code';
+    }
+    else if(based_on == 'Warehouse'){
+      cols = '`tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
+      cond = '`tabWarehouse`.docstatus < 2'
+      if(warehouse) cond += repl(' AND `tabWarehouse`.name = %(warehouse)s', {warehouse:'"'+warehouse+'"'});
+      cond += repl(' AND `tabStock Ledger Entry`.warehouse = `tabWarehouse`.name %(ware_type_cond)s', {ware_type_cond:ware_type_cond})
+      tables = '`tabWarehouse`';
+      group_by = '`tabStock Ledger Entry`.warehouse';
+    }
+  }
+  else if(based_on.length == 2){
+    cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM", `tabWarehouse`.name AS "Warehouse",  `tabWarehouse`.warehouse_type AS "Warehouse Type"';
+    cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes" AND `tabWarehouse`.docstatus < 2';
+    if(item_code) cond += repl(" AND `tabItem`.name = %(item)s", {item:"'"+item_code+"'"});
+    if(warehouse) cond += repl(" AND `tabWarehouse`.name = %(warehouse)s", {warehouse:"'"+warehouse+"'"});
+    cond += repl(' AND `tabStock Ledger Entry`.item_code = `tabItem`.name AND `tabStock Ledger Entry`.warehouse = `tabWarehouse`.name %(ware_type_cond)s', {ware_type_cond:ware_type_cond})
+    tables = '`tabItem`, `tabWarehouse`';
+    group_by = '`tabStock Ledger Entry`.item_code, `tabStock Ledger Entry`.warehouse';
+  }
+
+  q = repl("SELECT %(cols)s FROM %(tables)s, `tabStock Ledger Entry` WHERE %(cond)s %(date_cond)s GROUP BY %(group_by)s", {cols:cols, tables:tables, cond:cond, date_cond:date_cond, group_by:group_by});
+  return q;
+}
\ No newline at end of file
diff --git a/stock/search_criteria/stock_report/stock_report.py b/stock/search_criteria/stock_report/stock_report.py
new file mode 100644
index 0000000..1868794
--- /dev/null
+++ b/stock/search_criteria/stock_report/stock_report.py
@@ -0,0 +1,74 @@
+if not filter_values.get('based_on'):
+  msgprint("Please Select Based On")
+  raise Exception
+cols, columns = [], []
+# Add columns
+# ------------
+based_on = filter_values.get('based_on').split(NEWLINE)
+if len(based_on) == 1:
+  if based_on[0] == 'Item Code':
+    cols = ["Item Code", "Item Name", "Description", "Stock UOM"]
+  elif based_on[0] == 'Warehouse':
+    cols = ["Warehouse", "Warehouse Type"]
+elif len(based_on) == 2:
+  cols = ["Item Code", "Item Name", "Description", "Stock UOM", "Warehouse",  "Warehouse Type"]
+
+for d in cols:
+  columns.append([d,'Data','150px',''])
+
+columns.append(['Closing Balance','Currency','200px',''])
+columns.append(['Stock Value','Currency','150px',''])
+
+posting_date = filter_values.get('posting_date1')
+if not posting_date: posting_date = nowdate()
+
+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 get_values(msgprint, flt, posting_date, item_code = '', warehouse = ''):
+  cl_bal, stock_val = 0,0
+  if item_code and not warehouse:
+    war_list = sql("select distinct warehouse from `tabStock Ledger Entry` where item_code = %s", item_code)
+    for d in war_list:
+      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (item_code, d[0], posting_date, '23:55'))
+      cl_bal += act and flt(act[0][0]) or 0.00
+      stock_val += act and flt(act[0][1]) or 0.00
+  elif warehouse and not item_code:
+    item_list = sql("select distinct item_code from `tabStock Ledger Entry` where warehouse = %s", warehouse)
+    for d in item_list:
+      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (d[0], warehouse, posting_date, '23:55'))
+      cl_bal += act and flt(act[0][0]) or 0.00
+      stock_val += act and flt(act[0][1]) or 0.00
+  return cl_bal, stock_val
+
+out=[]
+cl_bal,tot_stock = 0,0
+  
+for r in res:
+  if len(based_on) == 1:
+    if based_on[0] == 'Item Code': closing_balance, stock_value = get_values(msgprint, flt, posting_date, item_code = r[col_idx['Item Code']])
+    elif based_on[0] == 'Warehouse': closing_balance, stock_value = get_values(msgprint, flt, posting_date, warehouse = r[col_idx['Warehouse']])
+    r.append(closing_balance)
+    r.append(stock_value)
+  else:
+    det = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (r[col_idx['Item Code']], r[col_idx['Warehouse']], posting_date, '23:55'))
+    
+    r.append(det and flt(det[0][0]) or 0.00)
+    r.append(det and flt(det[0][1]) or 0.00)
+  cl_bal += flt(r[col_idx['Closing Balance']])
+  tot_stock += flt(r[col_idx['Stock Value']])
+  out.append(r)
+
+# Add the totals row
+l_row = ['' for i in range(len(colnames))]
+if len(based_on) == 1 and based_on[0] == 'Warehouse':
+  l_row[col_idx['Warehouse Type']] = '<b>TOTALS</b>'
+else:
+  l_row[col_idx['Stock UOM']] = '<b>TOTALS</b>'
+l_row[col_idx['Closing Balance']] = cl_bal
+l_row[col_idx['Stock Value']] = tot_stock
+out.append(l_row)
diff --git a/stock/search_criteria/stock_report/stock_report.txt b/stock/search_criteria/stock_report/stock_report.txt
new file mode 100644
index 0000000..323214d
--- /dev/null
+++ b/stock/search_criteria/stock_report/stock_report.txt
@@ -0,0 +1,37 @@
+[
+	{
+		'add_col': None,
+		'add_cond': None,
+		'add_tab': None,
+		'columns': 'Stock Ledger Entry\x01ID',
+		'creation': '2010-11-02 15:37:36',
+		'criteria_name': 'Stock Report',
+		'custom_query': '',
+		'description': None,
+		'dis_filters': None,
+		'disabled': None,
+		'doc_type': 'Stock Ledger Entry',
+		'docstatus': 0,
+		'doctype': 'Search Criteria',
+		'filters': "{'Stock Ledger Entry\x01Is Cancelled':'','Stock Ledger Entry\x01Is Stock Entry':''}",
+		'graph_series': None,
+		'graph_values': None,
+		'group_by': None,
+		'idx': None,
+		'modified': '2010-11-02 15:35:12',
+		'modified_by': 'Administrator',
+		'module': 'Material Management',
+		'name': 'stock_report',
+		'owner': 'Administrator',
+		'page_len': 50,
+		'parent': None,
+		'parent_doc_type': None,
+		'parentfield': None,
+		'parenttype': None,
+		'report_script': None,
+		'server_script': None,
+		'sort_by': '`tabStock Ledger Entry`.`name`',
+		'sort_order': 'DESC',
+		'standard': 'Yes'
+	}
+]
\ No newline at end of file
diff --git a/stock/tests.py b/stock/tests.py
new file mode 100644
index 0000000..a8c0ffd
--- /dev/null
+++ b/stock/tests.py
@@ -0,0 +1,10 @@
+import unittest
+
+import sys
+sys.path.append('/Users/rushabh/Workbench/www/wnframework/cgi-bin/')
+sys.path.append('/Users/rushabh/Workbench/www/erpnext/')
+
+from material_management.doctype.delivery_note.tests import *
+
+if __name__ == '__main__':
+	unittest.main()
\ No newline at end of file