Merge branch 'manufacturer_childtable' of https://github.com/dottenbr/erpnext into dottenbr-manufacturer_childtable
diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py
index 53421b7..c21ee00 100644
--- a/erpnext/controllers/item_variant.py
+++ b/erpnext/controllers/item_variant.py
@@ -42,8 +42,10 @@
 
 	copy_attributes_to_variant(template, variant)
 
-	variant.manufacturer = manufacturer
-	variant.manufacturer_part_no = manufacturer_part_no
+	variant.append("manufacturers", {
+		"manufacturer": manufacturer,
+		"manufacturer_part_no": manufacturer_part_no
+	})
 
 	variant.item_code = append_number_if_name_exists('Item', template.name)
 
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 0e34ee6..3c2a372 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -379,3 +379,5 @@
 erpnext.patches.v7_2.move_dates_from_salary_structure_to_employee
 erpnext.patches.v7_2.make_all_assessment_group
 erpnext.patches.v7_2.stock_uom_in_selling
+
+erpnext.patches.v8_0.manufacturer_childtable_migrate
diff --git a/erpnext/patches/v8_0/__init__.py b/erpnext/patches/v8_0/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/patches/v8_0/__init__.py
diff --git a/erpnext/patches/v8_0/manufacturer_childtable_migrate.py b/erpnext/patches/v8_0/manufacturer_childtable_migrate.py
new file mode 100644
index 0000000..6d566b4
--- /dev/null
+++ b/erpnext/patches/v8_0/manufacturer_childtable_migrate.py
@@ -0,0 +1,25 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+
+    # reading from json and writing it to mariadb
+    # reload_doc needed here with information because new table introduced
+    frappe.reload_doc('stock', 'doctype', 'item_manufacturer')
+    # reload_doctype is a simpler concept of reload_doc
+    frappe.reload_doctype('Item')
+
+    item_manufacturers = frappe.get_all("Item", fields=["name", "manufacturer", "manufacturer_part_no"])
+    for item in item_manufacturers:
+        if item.manufacturer or item.manufacturer_part_no:
+            item_doc = frappe.get_doc("Item", item.name)
+            item_doc.append("manufacturers", {
+                "manufacturer": item.manufacturer,
+                "manufacturer_part_no": item.manufacturer_part_no
+            })
+            item_doc.flags.ignore_validate = True
+            item_doc.flags.ignore_mandatory = True
+            item_doc.save()
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index db327cc..f75b89f 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -1533,6 +1533,65 @@
    "bold": 0, 
    "collapsible": 1, 
    "columns": 0, 
+   "fieldname": "manufacturer_part_numbers", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Manufacturer Part Numbers", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "manufacturers", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Item Manufacturers", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Item Manufacturer", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
    "depends_on": "", 
    "fieldname": "supplier_details", 
    "fieldtype": "Section Break", 
@@ -1623,65 +1682,6 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
-   "fieldname": "manufacturer", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Manufacturer", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Manufacturer", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "manufacturer_part_no", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Manufacturer Part Number", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
    "fieldname": "column_break2", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -2837,8 +2837,8 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2017-03-21 21:03:10.715674", 
- "modified_by": "Administrator", 
+ "modified": "2017-03-24 14:41:03.395811", 
+ "modified_by": "d.ottenbreit@eso-electronic.de", 
  "module": "Stock", 
  "name": "Item", 
  "owner": "Administrator", 
diff --git a/erpnext/stock/doctype/item_manufacturer/__init__.py b/erpnext/stock/doctype/item_manufacturer/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/stock/doctype/item_manufacturer/__init__.py
diff --git a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json
new file mode 100644
index 0000000..aa34691
--- /dev/null
+++ b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json
@@ -0,0 +1,100 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2017-03-24 14:05:42.026237", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "manufacturer", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Manufacturer", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Manufacturer", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "manufacturer_part_no", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Manufacturer Part Number", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 1, 
+ "max_attachments": 0, 
+ "modified": "2017-03-24 14:33:56.726460", 
+ "modified_by": "d.ottenbreit@eso-electronic.de", 
+ "module": "Stock", 
+ "name": "Item Manufacturer", 
+ "name_case": "", 
+ "owner": "d.ottenbreit@eso-electronic.de", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py
new file mode 100644
index 0000000..933f7cc
--- /dev/null
+++ b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class ItemManufacturer(Document):
+	pass