diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js index 3dde661b92..e63fa042ea 100644 --- a/accounts/doctype/cost_center/cost_center.js +++ b/accounts/doctype/cost_center/cost_center.js @@ -47,12 +47,6 @@ cur_frm.cscript.parent_cost_center = function(doc,cdt,cdn){ } } -//company abbr -cur_frm.cscript.company_name = function(doc,cdt,cdn){ - get_server_fields('get_abbr','','',doc,cdt,cdn,1); -} - - // Hide/unhide group or ledger // ----------------------------------------- cur_frm.cscript.hide_unhide_group_ledger = function(doc) { diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py index f0fc6fdff2..d23b08681c 100644 --- a/accounts/doctype/cost_center/cost_center.py +++ b/accounts/doctype/cost_center/cost_center.py @@ -27,15 +27,9 @@ class DocType(DocTypeNestedSet): self.nsm_parent_field = 'parent_cost_center' def autoname(self): - self.doc.name = self.doc.cost_center_name + ' - ' + self.doc.company_abbr - - def get_abbr(self): - abbr = webnotes.conn.sql("select abbr from tabCompany where company_name=%s", - self.doc.company_name)[0][0] or '' - ret = { - 'company_abbr' : abbr - } - return ret + company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", + self.doc.company_name)[0][0] + self.doc.name = self.doc.cost_center_name + ' - ' + company_abbr def validate_mandatory(self): if not self.doc.group_or_ledger: diff --git a/accounts/doctype/cost_center/cost_center.txt b/accounts/doctype/cost_center/cost_center.txt index 00902d6732..5fbc43b940 100644 --- a/accounts/doctype/cost_center/cost_center.txt +++ b/accounts/doctype/cost_center/cost_center.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-10 16:34:06", + "creation": "2013-01-23 19:57:17", "docstatus": 0, - "modified": "2013-01-22 14:55:59", + "modified": "2013-01-25 15:04:03", "modified_by": "Administrator", "owner": "Administrator" }, @@ -88,16 +88,6 @@ "options": "Company", "reqd": 1 }, - { - "doctype": "DocField", - "fieldname": "company_abbr", - "fieldtype": "Data", - "hidden": 1, - "label": "Company Abbr", - "oldfieldname": "company_abbr", - "oldfieldtype": "Data", - "read_only": 1 - }, { "doctype": "DocField", "fieldname": "cb0", diff --git a/accounts/doctype/gl_control/gl_control.py b/accounts/doctype/gl_control/gl_control.py index fb7076ae5f..bafe7581ca 100644 --- a/accounts/doctype/gl_control/gl_control.py +++ b/accounts/doctype/gl_control/gl_control.py @@ -47,37 +47,23 @@ class DocType: return flt(bal) def add_ac(self,arg): - arg = eval(arg) - ac = Document('Account') - for d in arg.keys(): - ac.fields[d] = arg[d] - ac.old_parent = '' - ac_obj = get_obj(doc=ac) - ac_obj.doc.freeze_account='No' - ac_obj.validate() - ac_obj.doc.save(1) - ac_obj.on_update() + ac = webnotes.model_wrapper(eval(arg)) + ac.doc.doctype = "Account" + ac.doc.old_parent = "" + ac.doc.freeze_account = "No" + ac.insert() - return ac_obj.doc.name + return ac.doc.name # Add a new cost center #---------------------- def add_cc(self,arg): - arg = eval(arg) - cc = Document('Cost Center') - # map fields - for d in arg.keys(): - cc.fields[d] = arg[d] - # map company abbr - other_info = webnotes.conn.sql("select company_abbr from `tabCost Center` where name='%s'"%arg['parent_cost_center']) - cc.company_abbr = other_info and other_info[0][0] or arg['company_abbr'] + cc = webnotes.model_wrapper(eval(arg)) + cc.doc.doctype = "Cost Center" + cc.doc.old_parent = "" + cc.insert() - cc_obj = get_obj(doc=cc) - cc_obj.validate() - cc_obj.doc.save(1) - cc_obj.on_update() - - return cc_obj.doc.name + return cc.doc.name # Get field values from the voucher diff --git a/patches/january_2013/rebuild_tree.py b/patches/january_2013/rebuild_tree.py new file mode 100644 index 0000000000..7552090258 --- /dev/null +++ b/patches/january_2013/rebuild_tree.py @@ -0,0 +1,8 @@ +from __future__ import unicode_literals +def execute(): + from webnotes.utils.nestedset import rebuild_tree + + rebuild_tree("Item Group", "parent_item_group") + rebuild_tree("Customer Group", "parent_customer_group") + rebuild_tree("Territory", "parent_territory") + rebuild_tree("Sales Person", "parent_sales_person") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index a2789ade73..19c8ed7403 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -159,4 +159,5 @@ patch_list = [ "patches.january_2013.remove_unwanted_permission", "patches.january_2013.remove_landed_cost_master", "patches.january_2013.reload_print_format", + "patches.january_2013.rebuild_tree", ] \ No newline at end of file diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py index a3baaa9926..b34d3c6425 100644 --- a/setup/doctype/customer_group/customer_group.py +++ b/setup/doctype/customer_group/customer_group.py @@ -39,6 +39,7 @@ class DocType(DocTypeNestedSet): def on_update(self): self.validate_name_with_customer() + super(DocType, self).on_update() def validate_name_with_customer(self): if webnotes.conn.exists("Customer", self.doc.name):