Merge branch 'master' into responsive
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index 2a0985b..64d84b0 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -35,8 +35,9 @@
 		self.check_credit_limit()
 		self.check_pl_account()
 
-	def on_update(self,adv_adj, cancel, update_outstanding = 'Yes'):
+	def on_update(self, adv_adj, cancel, update_outstanding = 'Yes'):
 		self.validate_account_details(adv_adj)
+		self.validate_cost_center()
 		self.check_freezing_date(adv_adj)
 		self.check_negative_balance(adv_adj)
 
@@ -97,21 +98,36 @@
 			from tabAccount where name=%s""", self.doc.account, as_dict=1)
 		
 		if ret and ret[0]["group_or_ledger"]=='Group':
-			msgprint(_("Account: ") + self.doc.account + _(" is not a ledger"), raise_exception=1)
+			msgprint(_("Account") + ": " + self.doc.account + _(" is not a ledger"), raise_exception=1)
 
 		if ret and ret[0]["docstatus"]==2:
-			msgprint(_("Account: ") + self.doc.account + _(" is not active"), raise_exception=1)
+			msgprint(_("Account") + ": " + self.doc.account + _(" is not active"), raise_exception=1)
 			
 		# Account has been freezed for other users except account manager
 		if ret and ret[0]["freeze_account"]== 'Yes' and not adv_adj \
 				and not 'Accounts Manager' in webnotes.user.get_roles():
-			msgprint(_("Account: ") + self.doc.account + _(" has been freezed. \
+			msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
 				Only Accounts Manager can do transaction against this account"), raise_exception=1)
 			
 		if ret and ret[0]["company"] != self.doc.company:
-			msgprint(_("Account: ") + self.doc.account + _(" does not belong to the company: ") + 
-				self.doc.company, raise_exception=1)
-
+			msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
+				+ ": " + self.doc.company, raise_exception=1)
+				
+	def validate_cost_center(self):
+		if not hasattr(self, "cost_center_company"):
+			self.cost_center_company = {}
+		
+		def _get_cost_center_company():
+			if not self.cost_center_company.get(self.doc.cost_center):
+				self.cost_center_company[self.doc.cost_center] = webnotes.conn.get_value("Cost Center",
+					self.doc.cost_center, "company_name")
+			
+			return self.cost_center_company[self.doc.cost_center]
+			
+		if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
+			msgprint(_("Cost Center") + ": " + self.doc.cost_center \
+				+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
+		
 	def check_freezing_date(self, adv_adj):
 		"""
 			Nobody can do GL Entries where posting date is before freezing date 
diff --git a/accounts/doctype/mode_of_payment/mode_of_payment.txt b/accounts/doctype/mode_of_payment/mode_of_payment.txt
index 2d01996..0841af0 100644
--- a/accounts/doctype/mode_of_payment/mode_of_payment.txt
+++ b/accounts/doctype/mode_of_payment/mode_of_payment.txt
@@ -1,68 +1,68 @@
 [
  {
-  "owner": "harshada@webnotestech.com", 
+  "creation": "2012-12-04 17:49:20", 
   "docstatus": 0, 
-  "creation": "2012-07-03 13:30:49", 
+  "modified": "2013-04-19 10:59:05", 
   "modified_by": "Administrator", 
-  "modified": "2012-12-04 16:33:37"
+  "owner": "harshada@webnotestech.com"
  }, 
  {
-  "name": "__common__", 
+  "allow_rename": 1, 
   "autoname": "field:mode_of_payment", 
-  "module": "Accounts", 
   "doctype": "DocType", 
-  "document_type": "Master"
+  "document_type": "Master", 
+  "module": "Accounts", 
+  "name": "__common__"
  }, 
  {
+  "doctype": "DocField", 
   "name": "__common__", 
   "parent": "Mode of Payment", 
-  "doctype": "DocField", 
+  "parentfield": "fields", 
   "parenttype": "DocType", 
   "permlevel": 0, 
-  "parentfield": "fields"
+  "read_only": 0
  }, 
  {
-  "parent": "Mode of Payment", 
-  "read": 1, 
-  "doctype": "DocPerm", 
-  "cancel": 1, 
-  "name": "__common__", 
-  "amend": 0, 
   "create": 1, 
-  "submit": 0, 
-  "write": 1, 
+  "doctype": "DocPerm", 
+  "name": "__common__", 
+  "parent": "Mode of Payment", 
+  "parentfield": "permissions", 
   "parenttype": "DocType", 
-  "role": "Accounts Manager", 
-  "report": 1, 
   "permlevel": 0, 
-  "parentfield": "permissions"
+  "read": 1, 
+  "report": 1, 
+  "role": "Accounts Manager", 
+  "submit": 0, 
+  "write": 1
  }, 
  {
-  "name": "Mode of Payment", 
-  "doctype": "DocType"
+  "doctype": "DocType", 
+  "name": "Mode of Payment"
  }, 
  {
-  "oldfieldtype": "Data", 
   "doctype": "DocField", 
-  "label": "Mode of Payment", 
-  "oldfieldname": "mode_of_payment", 
   "fieldname": "mode_of_payment", 
   "fieldtype": "Data", 
+  "label": "Mode of Payment", 
+  "oldfieldname": "mode_of_payment", 
+  "oldfieldtype": "Data", 
   "reqd": 1
  }, 
  {
   "doctype": "DocField", 
-  "label": "Company", 
   "fieldname": "company", 
   "fieldtype": "Link", 
+  "label": "Company", 
   "options": "Company"
  }, 
  {
   "description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.", 
   "doctype": "DocField", 
-  "label": "Default Account", 
   "fieldname": "default_account", 
   "fieldtype": "Link", 
+  "label": "Default Account", 
   "options": "Account"
  }, 
  {
diff --git a/home/page/attributions/attributions.html b/home/page/attributions/attributions.html
index e6142f7..3b35283 100644
--- a/home/page/attributions/attributions.html
+++ b/home/page/attributions/attributions.html
@@ -41,6 +41,11 @@
 				<li>dateutil
 				<li>termcolor
 				<li>python-memcached
+				<li>requests
+				<li>chardet
+				<li>pygeoip
+				<li>dropbox
+				<li>google-api-python-client
 			</ul>
 			</td>
 		</tr>
@@ -100,7 +105,12 @@
 		<tr>
 			<td><a href="https://github.com/dcneiner/Downloadify">Downloadify - Flash Download Widget</a></td>
 			<td>A tiny javascript + Flash library that enables the creation and download of text files without server interaction.</td>
-		</tr>				
+		</tr>
+		<tr>
+			<td><a href="http://dev.maxmind.com/geoip/geolite">GeoLite data by MaxMind</a></td>
+			<td>GeoLite data created by MaxMind, available from
+			  <a href="https://www.maxmind.com">https://www.maxmind.com</a></td>
+		</tr>
 		</tbody>
 	</table>
 	
diff --git a/patches/april_2013/p06_default_cost_center.py b/patches/april_2013/p06_default_cost_center.py
new file mode 100644
index 0000000..4f80d95
--- /dev/null
+++ b/patches/april_2013/p06_default_cost_center.py
@@ -0,0 +1,10 @@
+import webnotes
+
+def execute():
+	for dt, fieldname in \
+		(("Journal Voucher Detail", "cost_center"), 
+		("Sales Taxes and Charges", "cost_center_other_charges"), 
+		("Purchase Taxes and Charges", "cost_center"), ("Delivery Note Item", "cost_center"),
+		("Purchase Invoice Item", "cost_center"), ("Sales Invoice Item", "cost_center")):
+			webnotes.conn.sql_ddl("""alter table `tab%s` alter `%s` drop default""" % (dt, fieldname))
+			webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 698b062..abee4f0 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -243,5 +243,7 @@
 	"patches.april_2013.p05_update_file_data",
 	"patches.april_2013.p06_update_file_size",
 	"patches.april_2013.p05_fixes_in_reverse_modules",
-	"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')"
+	"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')",
+    "execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
+	"patches.april_2013.p06_default_cost_center",
 ]
\ No newline at end of file