nsm bug in customer_group and removed abbr in Cost Center
diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js
index 3dde661..e63fa04 100644
--- a/accounts/doctype/cost_center/cost_center.js
+++ b/accounts/doctype/cost_center/cost_center.js
@@ -47,12 +47,6 @@
}
}
-//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 f0fc6fd..d23b086 100644
--- a/accounts/doctype/cost_center/cost_center.py
+++ b/accounts/doctype/cost_center/cost_center.py
@@ -27,15 +27,9 @@
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 00902d6..5fbc43b 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"
},
@@ -90,16 +90,6 @@
},
{
"doctype": "DocField",
- "fieldname": "company_abbr",
- "fieldtype": "Data",
- "hidden": 1,
- "label": "Company Abbr",
- "oldfieldname": "company_abbr",
- "oldfieldtype": "Data",
- "read_only": 1
- },
- {
- "doctype": "DocField",
"fieldname": "cb0",
"fieldtype": "Column Break",
"width": "50%"
diff --git a/accounts/doctype/gl_control/gl_control.py b/accounts/doctype/gl_control/gl_control.py
index fb7076a..bafe758 100644
--- a/accounts/doctype/gl_control/gl_control.py
+++ b/accounts/doctype/gl_control/gl_control.py
@@ -47,37 +47,23 @@
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/patch_list.py b/patches/patch_list.py
index 3b013e4..3ba2048 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -158,4 +158,5 @@
"patches.january_2013.enable_currencies",
"patches.january_2013.remove_unwanted_permission",
"patches.january_2013.remove_landed_cost_master",
+ "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 a3baaa9..b34d3c6 100644
--- a/setup/doctype/customer_group/customer_group.py
+++ b/setup/doctype/customer_group/customer_group.py
@@ -39,6 +39,7 @@
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):