Merge pull request #3576 from nabinhait/variant

[fix][patch] delete item variant attributes if no variants exists against that item
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index dcbc605..69b0708 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -38,7 +38,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "in_list_view": 0, 
-   "label": "Name", 
+   "label": "Supplier Name", 
    "oldfieldname": "supplier_name", 
    "oldfieldtype": "Data", 
    "permlevel": 0, 
@@ -940,7 +940,7 @@
  "icon": "icon-file-text", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2015-06-22 07:30:06.743438", 
+ "modified": "2015-07-03 03:26:32.934540", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 045678d..70d5f4a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -47,7 +47,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "in_list_view": 0, 
-   "label": "Name", 
+   "label": "Customer Name", 
    "oldfieldname": "customer_name", 
    "oldfieldtype": "Data", 
    "permlevel": 0, 
@@ -1253,7 +1253,7 @@
  "icon": "icon-file-text", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2015-06-22 06:39:22.072544", 
+ "modified": "2015-07-03 03:25:40.519956", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice", 
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index f65ba40..8ca8ed0 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -53,7 +53,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "in_list_view": 0, 
-   "label": "Name", 
+   "label": "Supplier Name", 
    "permlevel": 0, 
    "read_only": 1
   }, 
@@ -882,7 +882,7 @@
  "icon": "icon-file-text", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2015-06-22 07:30:36.259753", 
+ "modified": "2015-07-03 03:26:43.080551", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Purchase Order", 
diff --git a/erpnext/config/accounts.py b/erpnext/config/accounts.py
index 64508b8..f32aeed 100644
--- a/erpnext/config/accounts.py
+++ b/erpnext/config/accounts.py
@@ -75,6 +75,11 @@
 			"items": [
 				{
 					"type": "doctype",
+					"name": "Company",
+					"description": _("Company (not Customer or Supplier) master.")
+				},
+				{
+					"type": "doctype",
 					"name": "Fiscal Year",
 					"description": _("Financial / accounting year.")
 				},
diff --git a/erpnext/config/setup.py b/erpnext/config/setup.py
index 961e4f7..a660942 100644
--- a/erpnext/config/setup.py
+++ b/erpnext/config/setup.py
@@ -110,43 +110,7 @@
 					"description": _("Setup SMS gateway settings")
 				},
 			]
-		},
-		{
-			"label": _("Masters"),
-			"icon": "icon-star",
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Company",
-					"description": _("Company (not Customer or Supplier) master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Item",
-					"description": _("Item master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Customer",
-					"description": _("Customer master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Supplier",
-					"description": _("Supplier master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Contact",
-					"description": _("Contact master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Address",
-					"description": _("Address master.")
-				},
-			]
-		},
+		}
 	]
 
 	for module, label, icon in (
diff --git a/erpnext/crm/doctype/lead/lead.json b/erpnext/crm/doctype/lead/lead.json
index e095426..b2aa31a 100644
--- a/erpnext/crm/doctype/lead/lead.json
+++ b/erpnext/crm/doctype/lead/lead.json
@@ -29,7 +29,7 @@
    "fieldtype": "Data", 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "label": "Contact Name", 
+   "label": "Person Name", 
    "oldfieldname": "lead_name", 
    "oldfieldtype": "Data", 
    "permlevel": 0, 
@@ -344,7 +344,7 @@
  ], 
  "icon": "icon-user", 
  "idx": 1, 
- "modified": "2015-04-02 15:13:02.621854", 
+ "modified": "2015-07-03 03:26:18.579905", 
  "modified_by": "Administrator", 
  "module": "CRM", 
  "name": "Lead", 
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index cb0ce11..a2bb10c 100644
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -45,6 +45,10 @@
 		if self.user_id:
 			self.validate_for_enabled_user_id()
 			self.validate_duplicate_user_id()
+		else:
+			existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
+			if existing_user_id:
+				frappe.permissions.remove_user_permission("Employee", self.name, existing_user_id)
 
 	def on_update(self):
 		if self.user_id:
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index 59f54fb..28f98e4 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -52,7 +52,7 @@
    "fieldname": "customer_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
-   "label": "Name", 
+   "label": "Customer Name", 
    "permlevel": 0, 
    "read_only": 1
   }, 
@@ -1089,7 +1089,7 @@
  "idx": 1, 
  "is_submittable": 1, 
  "issingle": 0, 
- "modified": "2015-06-22 07:29:24.379272", 
+ "modified": "2015-07-03 03:25:20.180721", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Sales Order", 
diff --git a/erpnext/stock/doctype/manage_variants/manage_variants.js b/erpnext/stock/doctype/manage_variants/manage_variants.js
index ba5c46e..e8b7ade 100644
--- a/erpnext/stock/doctype/manage_variants/manage_variants.js
+++ b/erpnext/stock/doctype/manage_variants/manage_variants.js
@@ -3,7 +3,7 @@
 
 frappe.ui.form.on("Manage Variants", {
 	onload: function(frm) {
-		var df = frappe.meta.get_docfield("Variant Attribute", "attribute_value");
+		var df = frappe.meta.get_docfield("Variant Attribute", "attribute_value", "Manage Variants");
 		df.on_make = function(field) {
 			$(field.input_area).addClass("ui-front");
 			field.$input.autocomplete({
diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
index 69e1321..9cba203 100644
--- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
+++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
@@ -20,10 +20,11 @@
 		for wh in sorted(iwb_map[item]):
 			for batch in sorted(iwb_map[item][wh]):
 				qty_dict = iwb_map[item][wh][batch]
-				data.append([item, item_map[item]["item_name"], item_map[item]["description"], wh, batch,
-					flt(qty_dict.opening_qty, float_precision), flt(qty_dict.in_qty, float_precision),
-					flt(qty_dict.out_qty, float_precision), flt(qty_dict.bal_qty, float_precision)
-				])
+				if qty_dict.opening_qty or qty_dict.in_qty or qty_dict.out_qty or qty_dict.bal_qty:
+					data.append([item, item_map[item]["item_name"], item_map[item]["description"], wh, batch,
+						flt(qty_dict.opening_qty, float_precision), flt(qty_dict.in_qty, float_precision),
+						flt(qty_dict.out_qty, float_precision), flt(qty_dict.bal_qty, float_precision)
+					])
 
 	return columns, data
 
diff --git a/erpnext/templates/print_formats/includes/item_table_description.html b/erpnext/templates/print_formats/includes/item_table_description.html
index f259626..ece5386 100644
--- a/erpnext/templates/print_formats/includes/item_table_description.html
+++ b/erpnext/templates/print_formats/includes/item_table_description.html
@@ -1,6 +1,7 @@
 {% if doc.in_format_data("image") and doc.get("image") and not doc.is_print_hide("image")-%}
 <div class="pull-left" style="max-width: 38.2%; margin-right: 10px;">
-    <img src="{{ doc.image }}" style="max-width: 100%">
+    <!-- width: 100% is a mozilla bug -->
+    <img src="{{ doc.image }}" class="img-responsive" style="width: 100%;">
 </div>
 {%- endif %}
 <div>
@@ -8,14 +9,14 @@
     	<div class="primary">{{ doc.item_code }}</div>
     {%- endif %}
     {% if (doc.in_format_data("item_name") and not doc.is_print_hide("item_name") and
-    	(not doc.in_format_data("item_code") or doc.is_print_hide("item_code") 
+    	(not doc.in_format_data("item_code") or doc.is_print_hide("item_code")
 			or doc.item_code != doc.item_name)) -%}
     	<div class="primary">{{ doc.get_formatted("item_name") }}</div>
     {%- endif %}
     {% if (doc.in_format_data("description") and doc.description and
     	(
 			(
-				(not doc.in_format_data("item_code") or doc.is_print_hide("item_code")) and 
+				(not doc.in_format_data("item_code") or doc.is_print_hide("item_code")) and
 				(not doc.in_format_data("item_name") or doc.is_print_hide("item_name"))
 			) or not (doc.item_code == doc.item_name == doc.description)
 		))