diff --git a/accounts/doctype/budget_detail/budget_detail.txt b/accounts/doctype/budget_detail/budget_detail.txt index 3feb6f75add..10d3a195f3d 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 2a98a960c77..4e2b8deed8b 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 += '
Note: This Cost Center is a Group, \ @@ -36,16 +36,16 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { //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 8be14c78c34..b2b4c907458 100644 --- a/accounts/doctype/cost_center/cost_center.py +++ b/accounts/doctype/cost_center/cost_center.py @@ -28,16 +28,16 @@ class DocType(DocTypeNestedSet): 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 @@ class DocType(DocTypeNestedSet): """ 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 7f5fe24c7b7..95c4f5a7af1 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 8500bd3ef0a..94a87fe70aa 100644 --- a/accounts/doctype/cost_center/test_cost_center.py +++ b/accounts/doctype/cost_center/test_cost_center.py @@ -3,7 +3,7 @@ test_records = [ "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 d39155d76f3..1d0ec8e72af 100644 --- a/accounts/doctype/gl_entry/gl_entry.py +++ b/accounts/doctype/gl_entry/gl_entry.py @@ -120,7 +120,7 @@ class DocType: 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 dbe666881a4..53c8764f750 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('account').get_query = function(do 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 3ba60b46443..1648bad4052 100755 --- a/accounts/doctype/pos_setting/pos_setting.js +++ b/accounts/doctype/pos_setting/pos_setting.js @@ -38,7 +38,7 @@ cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { // 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 e57eb80c85a..512e036ae0f 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -191,7 +191,7 @@ cur_frm.cscript.expense_head = function(doc, cdt, cdn){ 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 f04f895baf2..a147ac17b79 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("account_head").get_q 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 0d2bf661abf..c7d7d25734a 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -263,7 +263,7 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) { // 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('warehouse').get_query= function(d 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 57874273391..9f4cb08745c 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("account_head").get_query = } 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 0b69fb9aaa8..904b4cd26bd 100644 --- a/accounts/page/accounts_browser/accounts_browser.js +++ b/accounts/page/accounts_browser/accounts_browser.js @@ -310,7 +310,7 @@ erpnext.AccountsChart = Class.extend({ 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 febe22d7079..4c4162d3c18 100644 --- a/accounts/page/accounts_browser/accounts_browser.py +++ b/accounts/page/accounts_browser/accounts_browser.py @@ -28,16 +28,14 @@ def get_children(): 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 42bc6639edb..835475f7808 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 @@ def get_costcenter_target_details(filters): 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 00000000000..22072ae4685 --- /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 00230d8c666..0156a17c28d 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_accounts(accounts_to_add, check_fn=None): 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 @@ def add_aii_cost_center(): "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 eee00fe855f..48e521d20c6 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -249,4 +249,5 @@ patch_list = [ "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 0ea7f4039ac..55a17f74838 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -215,13 +215,13 @@ class DocType: 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 @@ class DocType: 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 936ca9eb5e1..bbc22b9ade6 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -247,7 +247,7 @@ if (sys_defaults.auto_inventory_accounting) { 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