Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/accounts/doctype/budget_detail/budget_detail.txt b/accounts/doctype/budget_detail/budget_detail.txt
index 3feb6f7..10d3a19 100644
--- a/accounts/doctype/budget_detail/budget_detail.txt
+++ b/accounts/doctype/budget_detail/budget_detail.txt
@@ -1,8 +1,8 @@
 [
  {
-  "creation": "2013-02-22 01:27:37", 
+  "creation": "2013-03-07 11:55:04", 
   "docstatus": 0, 
-  "modified": "2013-03-07 07:03:19", 
+  "modified": "2013-07-09 14:44:37", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -44,7 +44,7 @@
   "label": "Budget Allocated", 
   "oldfieldname": "budget_allocated", 
   "oldfieldtype": "Currency", 
-  "options": "Company:company_name:default_currency", 
+  "options": "Company:company:default_currency", 
   "reqd": 1
  }, 
  {
@@ -54,7 +54,7 @@
   "label": "Actual", 
   "oldfieldname": "actual", 
   "oldfieldtype": "Currency", 
-  "options": "Company:company_name:default_currency", 
+  "options": "Company:company:default_currency", 
   "read_only": 1
  }, 
  {
diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js
index 2a98a96..4e2b8de 100644
--- a/accounts/doctype/cost_center/cost_center.js
+++ b/accounts/doctype/cost_center/cost_center.js
@@ -17,7 +17,7 @@
 cur_frm.cscript.refresh = function(doc, cdt, cdn) {
 	var intro_txt = '';
 	cur_frm.toggle_display('cost_center_name', doc.__islocal);
-	cur_frm.toggle_enable(['group_or_ledger', 'company_name'], doc.__islocal);
+	cur_frm.toggle_enable(['group_or_ledger', 'company'], doc.__islocal);
 
 	if(!doc.__islocal && doc.group_or_ledger=='Group') {
 		intro_txt += '<p><b>Note:</b> This Cost Center is a <i>Group</i>, \
@@ -36,16 +36,16 @@
 //Account filtering for cost center
 cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) {
 	var mydoc = locals[this.doctype][this.docname];
-	return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company_name + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
+	return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
 	}
 
 cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
-	return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company_name="'+ doc.company_name+'" AND `tabCost Center`.company_name is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
+	return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company="'+ doc.company+'" AND `tabCost Center`.company is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
 }
 
 //parent cost center
 cur_frm.cscript.parent_cost_center = function(doc,cdt,cdn){
-	if(!doc.company_name){
+	if(!doc.company){
 		alert('Please enter company name first');
 	}
 }
diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py
index 8be14c7..b2b4c90 100644
--- a/accounts/doctype/cost_center/cost_center.py
+++ b/accounts/doctype/cost_center/cost_center.py
@@ -28,16 +28,16 @@
 				
 	def autoname(self):
 		company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", 
-			self.doc.company_name)[0][0]
+			self.doc.company)[0][0]
 		self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr		
 		
 	def validate_mandatory(self):
 		if not self.doc.group_or_ledger:
 			msgprint("Please select Group or Ledger value", raise_exception=1)
 			
-		if self.doc.cost_center_name != self.doc.company_name and not self.doc.parent_cost_center:
+		if self.doc.cost_center_name != self.doc.company and not self.doc.parent_cost_center:
 			msgprint("Please enter parent cost center", raise_exception=1)
-		elif self.doc.cost_center_name == self.doc.company_name and self.doc.parent_cost_center:
+		elif self.doc.cost_center_name == self.doc.company and self.doc.parent_cost_center:
 			msgprint(_("Root cannot have a parent cost center"), raise_exception=1)
 		
 	def convert_group_to_ledger(self):
@@ -81,14 +81,14 @@
 		"""
 			Cost Center name must be unique
 		"""
-		if (self.doc.fields.get("__islocal") or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
+		if (self.doc.fields.get("__islocal") or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)):
 			msgprint("Cost Center Name already exists, please rename", raise_exception=1)
 			
 		self.validate_mandatory()
 		self.validate_budget_details()
 		
 	def on_rename(self, new, old, merge=False):
-		company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr")		
+		company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")		
 		parts = new.split(" - ")	
 
 		if parts[-1].lower() != company_abbr.lower():
diff --git a/accounts/doctype/cost_center/cost_center.txt b/accounts/doctype/cost_center/cost_center.txt
index 7f5fe24..95c4f5a 100644
--- a/accounts/doctype/cost_center/cost_center.txt
+++ b/accounts/doctype/cost_center/cost_center.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-01-23 19:57:17", 
   "docstatus": 0, 
-  "modified": "2013-07-05 14:33:05", 
+  "modified": "2013-07-09 14:43:41", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -81,7 +81,7 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "company_name", 
+  "fieldname": "company", 
   "fieldtype": "Link", 
   "label": "Company", 
   "oldfieldname": "company_name", 
diff --git a/accounts/doctype/cost_center/test_cost_center.py b/accounts/doctype/cost_center/test_cost_center.py
index 8500bd3..94a87fe 100644
--- a/accounts/doctype/cost_center/test_cost_center.py
+++ b/accounts/doctype/cost_center/test_cost_center.py
@@ -3,7 +3,7 @@
 		"doctype": "Cost Center",
 		"cost_center_name": "_Test Cost Center",
 		"parent_cost_center": "_Test Company - _TC",
-		"company_name": "_Test Company",
+		"company": "_Test Company",
 		"group_or_ledger": "Ledger"
 	}],
 ]
\ No newline at end of file
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index d39155d..1d0ec8e 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -120,7 +120,7 @@
 		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")
+					self.doc.cost_center, "company")
 			
 			return self.cost_center_company[self.doc.cost_center]
 			
diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js
index dbe6668..53c8764 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/accounts/doctype/journal_voucher/journal_voucher.js
@@ -197,7 +197,7 @@
 cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
 	return {
 		query: "accounts.utils.get_cost_center_list",
-		filters: { company_name: doc.company}
+		filters: { company: doc.company}
 	}
 }
 
diff --git a/accounts/doctype/pos_setting/pos_setting.js b/accounts/doctype/pos_setting/pos_setting.js
index 3ba60b4..1648bad 100755
--- a/accounts/doctype/pos_setting/pos_setting.js
+++ b/accounts/doctype/pos_setting/pos_setting.js
@@ -38,7 +38,7 @@
 // Cost Center 
 // -----------------------------
 cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
-	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `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';
+	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company` = "' +doc.company+'" AND `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';
 }
 
 //get query select Territory
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js
index e57eb80..512e036 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -191,7 +191,7 @@
 cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
 	return {
 		query: "accounts.utils.get_cost_center_list",
-		filters: { company_name: doc.company}
+		filters: { company: doc.company}
 	}
 }
 
diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
index f04f895..a147ac1 100644
--- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
+++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
@@ -135,7 +135,7 @@
 
 
 cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_query = function(doc) {
-	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `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';
+	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company` = "' +doc.company+'" AND `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';
 }
 
 
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 0d2bf66..c7d7d25 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -263,7 +263,7 @@
 // Write off cost center
 //-----------------------
 cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
-	return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company_name="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
+	return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
 }
 
 //project name
@@ -315,7 +315,7 @@
 cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
 	return {
 		query: "accounts.utils.get_cost_center_list",
-		filters: { company_name: doc.company}
+		filters: { company: doc.company}
 	}
 }
 
diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
index 5787427..9f4cb08 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
@@ -141,7 +141,7 @@
 }
 
 cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
-	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `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';
+	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company` = "' +doc.company+'" AND `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';
 }
 
 
diff --git a/accounts/page/accounts_browser/accounts_browser.js b/accounts/page/accounts_browser/accounts_browser.js
index 0b69fb9..904b4cd 100644
--- a/accounts/page/accounts_browser/accounts_browser.js
+++ b/accounts/page/accounts_browser/accounts_browser.js
@@ -310,7 +310,7 @@
 			var node = me.selected_node();
 			
 			v.parent_cost_center = node.data('label');
-			v.company_name = me.company;
+			v.company = me.company;
 			
 			wn.call({
 				args: v,
diff --git a/accounts/page/accounts_browser/accounts_browser.py b/accounts/page/accounts_browser/accounts_browser.py
index febe22d..4c4162d 100644
--- a/accounts/page/accounts_browser/accounts_browser.py
+++ b/accounts/page/accounts_browser/accounts_browser.py
@@ -28,16 +28,14 @@
 	args = webnotes.form_dict
 	ctype, company = args['ctype'], args['comp']
 	
-	company_field = ctype=='Account' and 'company' or 'company_name'
-
 	# root
 	if args['parent'] in ("Accounts", "Cost Centers"):
 		acc = webnotes.conn.sql(""" select 
 			name as value, if(group_or_ledger='Group', 1, 0) as expandable
 			from `tab%s`
 			where ifnull(parent_%s,'') = ''
-			and %s = %s	and docstatus<2 
-			order by name""" % (ctype, ctype.lower().replace(' ','_'), company_field, '%s'),
+			and `company` = %s	and docstatus<2 
+			order by name""" % (ctype, ctype.lower().replace(' ','_'), '%s'),
 				company, as_dict=1)
 	else:	
 		# other
diff --git a/accounts/report/budget_variance_report/budget_variance_report.py b/accounts/report/budget_variance_report/budget_variance_report.py
index 42bc663..835475f 100644
--- a/accounts/report/budget_variance_report/budget_variance_report.py
+++ b/accounts/report/budget_variance_report/budget_variance_report.py
@@ -79,7 +79,7 @@
 		cc.parent_cost_center, bd.account, bd.budget_allocated 
 		from `tabCost Center` cc, `tabBudget Detail` bd 
 		where bd.parent=cc.name and bd.fiscal_year=%s and 
-		cc.company_name=%s and ifnull(cc.distribution_id, '')!='' 
+		cc.company=%s and ifnull(cc.distribution_id, '')!='' 
 		order by cc.name""" % ('%s', '%s'), 
 		(filters.get("fiscal_year"), filters.get("company")), as_dict=1)
 
diff --git a/patches/july_2013/p03_cost_center_company.py b/patches/july_2013/p03_cost_center_company.py
new file mode 100644
index 0000000..22072ae
--- /dev/null
+++ b/patches/july_2013/p03_cost_center_company.py
@@ -0,0 +1,6 @@
+import webnotes
+
+def execute():
+	webnotes.reload_doc("accounts", "doctype", "cost_center")
+	webnotes.conn.sql("""update `tabCost Center` set company=company_name""")
+	webnotes.conn.sql_ddl("""alter table `tabCost Center` drop column company_name""")
\ No newline at end of file
diff --git a/patches/march_2013/p08_create_aii_accounts.py b/patches/march_2013/p08_create_aii_accounts.py
index 00230d8..0156a17 100644
--- a/patches/march_2013/p08_create_aii_accounts.py
+++ b/patches/march_2013/p08_create_aii_accounts.py
@@ -79,9 +79,9 @@
 def add_aii_cost_center():
 	for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
 		if not webnotes.conn.sql("""select name from `tabCost Center` where cost_center_name = 
-				'Auto Inventory Accounting' and company_name = %s""", company):
+				'Auto Inventory Accounting' and company = %s""", company):
 			parent_cost_center = webnotes.conn.get_value("Cost Center", 
-				{"parent_cost_center['']": '', "company_name": company})
+				{"parent_cost_center['']": '', "company": company})
 				
 			if not parent_cost_center:
 				webnotes.errprint("Company " + company + "does not have a root cost center")
@@ -92,7 +92,7 @@
 				"cost_center_name": "Auto Inventory Accounting",
 				"parent_cost_center": parent_cost_center,
 				"group_or_ledger": "Ledger",
-				"company_name": company
+				"company": company
 			})
 			cc.insert()
 				
diff --git a/patches/patch_list.py b/patches/patch_list.py
index eee00fe..48e521d 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -249,4 +249,5 @@
 	"execute:webnotes.delete_doc('Report', 'Delivered Items To Be Billed')",
 	"execute:webnotes.delete_doc('Report', 'Received Items To Be Billed')",
 	"patches.july_2013.p02_copy_shipping_address",
+	"patches.july_2013.p03_cost_center_company",
 ]
\ No newline at end of file
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index 0ea7f40..55a17f7 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -215,13 +215,13 @@
 		cc_list = [
 			{
 				'cost_center_name': self.doc.name,
-				'company_name':self.doc.name,
+				'company':self.doc.name,
 				'group_or_ledger':'Group',
 				'parent_cost_center':''
 			}, 
 			{
 				'cost_center_name':'Main', 
-				'company_name':self.doc.name,
+				'company':self.doc.name,
 				'group_or_ledger':'Ledger',
 				'parent_cost_center':self.doc.name + ' - ' + self.doc.abbr
 			},
@@ -266,9 +266,9 @@
 			webnotes.conn.sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
 			
 			#delete cost center child table - budget detail
-			webnotes.conn.sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company_name = %s", self.doc.name)
+			webnotes.conn.sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company = %s", self.doc.name)
 			#delete cost center
-			webnotes.conn.sql("delete from `tabCost Center` WHERE company_name = %s order by lft desc, rgt desc", self.doc.name)
+			webnotes.conn.sql("delete from `tabCost Center` WHERE company = %s order by lft desc, rgt desc", self.doc.name)
 			
 		webnotes.defaults.clear_default("company", value=self.doc.name)
 			
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 936ca9e..bbc22b9 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -247,7 +247,7 @@
 	cur_frm.fields_dict.delivery_note_details.grid.get_field("cost_center").get_query = function(doc) {
 		return {
 			query: "accounts.utils.get_cost_center_list",
-			filters: { company_name: doc.company}
+			filters: { company: doc.company}
 		}
 	}
 }
\ No newline at end of file