Merge pull request #4153 from rmehta/stock-entry-fix

[fix] [minor] stock_entry.py error for None qty
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index da9650e..8728ac9 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -175,7 +175,7 @@
 			if parent_groups:
 				if allow_blank: parent_groups.append('')
 				condition = " ifnull("+field+", '') in ('" + \
-					"', '".join([d.replace("'", "\\'").replace('"', '\\"') for d in parent_groups])+"')"
+					"', '".join([d.replace("'", "\\'").replace('"', '\\"').replace("%", "%%") for d in parent_groups])+"')"
 		return condition
 
 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index f4c0b46..4a09789 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -1701,6 +1701,29 @@
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
+   "fieldname": "letter_head", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Letter Head", 
+   "no_copy": 0, 
+   "options": "Letter Head", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "select_print_heading", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -2242,7 +2265,7 @@
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
- "modified": "2015-09-30 08:52:56.789115", 
+ "modified": "2015-10-12 06:23:32.141069", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 1eaf8a7..381e4d4 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -51,7 +51,8 @@
 	# sales team
 	if party_type=="Customer":
 		out["sales_team"] = [{
-			"sales_person": d.sales_person
+			"sales_person": d.sales_person,
+			"allocated_percentage": d.allocated_percentage or None
 		} for d in party.get("sales_team")]
 
 	return out
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 76f51ee..e4ae2a4 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -38,7 +38,7 @@
 				"width": 120
 			})
 
-		columns += [_("Age (Days)") + "::80"]
+		columns += [_("Age (Days)") + ":Int:80"]
 
 		if not "range1" in self.filters:
 			self.filters["range1"] = "30"
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 0fbe22d..27ec618 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -355,7 +355,7 @@
 							item.net_amount = flt(item.net_amount + discount_amount_loss,
 								item.precision("net_amount"))
 
-					item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate"))
+					item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate")) if item.qty else 0
 
 					self._set_in_company_currency(item, ["net_rate", "net_amount"])
 
diff --git a/erpnext/projects/doctype/project_task/project_task.json b/erpnext/projects/doctype/project_task/project_task.json
index a108ae6..1affa13 100644
--- a/erpnext/projects/doctype/project_task/project_task.json
+++ b/erpnext/projects/doctype/project_task/project_task.json
@@ -19,7 +19,7 @@
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Title", 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -217,7 +217,7 @@
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 1, 
- "modified": "2015-09-11 12:19:41.832529", 
+ "modified": "2015-10-12 06:24:11.748792", 
  "modified_by": "Administrator", 
  "module": "Projects", 
  "name": "Project Task", 
diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js
index 1a86b2b..9173b71 100644
--- a/erpnext/public/js/utils/party.js
+++ b/erpnext/public/js/utils/party.js
@@ -20,7 +20,10 @@
 				price_list: frm.doc.buying_price_list
 			};
 		}
-		args.posting_date = frm.doc.transaction_date;
+		
+		if (args) {
+			args.posting_date = frm.doc.transaction_date;
+		}
 	}
 	if(!args) return;
 
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index eda8c73..732867f 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -396,7 +396,7 @@
 				"parent": "sales_order",
 			},
 			"postprocess": update_item,
-			"condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount
+			"condition": lambda doc: doc.qty and (doc.base_amount==0 or doc.billed_amt < doc.amount)
 		},
 		"Sales Taxes and Charges": {
 			"doctype": "Sales Taxes and Charges",
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 310f4cc..8a6acd7 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -200,8 +200,8 @@
 			self.set("reorder_levels", [])
 
 		if self.re_order_level or len(self.get("reorder_levels", {"material_request_type": "Purchase"})):
-			if not self.is_purchase_item:
-				frappe.throw(_("""To set reorder level, item must be a Purchase Item"""))
+			if not (self.is_purchase_item or self.is_pro_applicable):
+				frappe.throw(_("""To set reorder level, item must be a Purchase Item or Prodcution Item"""))
 
 	def validate_warehouse_for_reorder(self):
 		warehouse = []