Merge branch 'latest' of github.com:webnotes/erpnext into latest
diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
index b19db79..d4ce9e4 100644
--- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
+++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
@@ -61,12 +61,16 @@
}
var callback2 = function(r,rt){
- var doc = locals[cur_frm.doctype][cur_frm.docname];
+ var doc = locals[cur_frm.doctype][cur_frm.docname];
var el = getchildren('PV Detail',doc.name,'entries');
for(var i in el){
if(el[i].item_code && (!el[i].expense_head || !el[i].cost_center)){
- args = "{'item_code':'" + el[i].item_code + "','expense_head':'" + el[i].expense_head + "','cost_center':'" + el[i].cost_center + "'}";
- get_server_fields('get_default_values', args, 'entries', doc, el[i].doctype, el[i].name, 1);
+ args = {
+ item_code: el[i].item_code,
+ expense_head: el[i].expense_head,
+ cost_center: el[i].cost_center
+ };
+ get_server_fields('get_default_values', JSON.stringify(args), 'entries', doc, el[i].doctype, el[i].name, 1);
}
}
cur_frm.cscript.calc_amount(doc, 1);
diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.py b/erpnext/accounts/doctype/payable_voucher/payable_voucher.py
index e220756..14d5e5e 100644
--- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.py
+++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.py
@@ -61,7 +61,8 @@
# Get Default Cost Center and Expense Head from Item Master
# ----------------------------------------------------------
def get_default_values(self,args):
- args = eval(args)
+ import json
+ args = json.loads(args)
ret = {}
if sql("select name from `tabItem` where name = '%s'" % args['item_code']):
if not args['expense_head'] or args['expense_head'] == 'undefined':
@@ -105,6 +106,7 @@
def get_pv_details(self, arg):
+ import json
item_det = sql("select item_name, brand, description, item_group,purchase_account,cost_center from tabItem where name=%s",arg,as_dict=1)
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
t = {}
@@ -119,7 +121,7 @@
'amount' : 0.00,
'expense_head' : item_det and item_det[0]['purchase_account'] or '',
'cost_center' : item_det and item_det[0]['cost_center'] or '',
- 'item_tax_rate' : str(t)
+ 'item_tax_rate' : json.dumps(t)
}
return ret
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 541a225..d7d88bb 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -34,7 +34,7 @@
// Update existing item details
cur_frm.cscript.update_item_details = function(doc, dt, dn) {
- if(!cur_frm.doc.__islocal) return;
+ if(!cur_frm.doc.__islocal) { return; }
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(children) {
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index 1420ad6..2498381 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -197,17 +197,19 @@
#---------------------------------------- Get Tax Details -------------------------------#
def get_tax_details(self, item_code, obj):
+ import json
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
t = {}
for x in tax: t[x[0]] = flt(x[1])
ret = {
- 'item_tax_rate' : tax and str(t) or ''
+ 'item_tax_rate' : tax and json.dumps(t) or ''
}
return ret
# Get Serial No Details
# ==========================================================================
def get_serial_details(self, serial_no, obj):
+ import json
item = webnotes.conn.sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
t = {}
@@ -218,7 +220,7 @@
'label' : item and item[0]['label'] or '',
'brand' : item and item[0]['brand'] or '',
'description' : item and item[0]['description'] or '',
- 'item_tax_rate' : str(t)
+ 'item_tax_rate' : json.dumps(t)
}
return ret
diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
index c791e86..ea63d04 100644
--- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
+++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
@@ -112,6 +112,7 @@
def cal_charges_and_item_tax_amt(self):
""" Re-calculates other charges values and itemwise tax amount for getting valuation rate"""
+ import json
for pr in self.selected_pr:
obj = get_obj('Purchase Receipt', pr, with_children = 1)
total = 0
@@ -121,7 +122,11 @@
prev_total, item_tax = flt(prd.amount), 0
total += flt(prd.qty) * flt(prd.purchase_rate)
- item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
+ try:
+ item_tax_rate = prd.item_tax_rate and json.loads(prd.item_tax_rate) or {}
+ except ValueError:
+ item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
+
ocd = getlist(obj.doclist, 'purchase_tax_details')
# calculate tax for other charges
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 5d4310f..db5215a 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -241,7 +241,7 @@
'from_docname': cur_frm.doc.name,
'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail'],['Purchase Tax Detail','Purchase Tax Detail']]"
}, function(r,rt) {
- loaddoc('Payable Voucher', n);
+ loaddoc('Payable Voucher', n);
}
);
}