mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 06:58:27 +00:00
patch: update item tax rate in json format
This commit is contained in:
16
patches/march_2013/p11_update_attach_files.py
Normal file
16
patches/march_2013/p11_update_attach_files.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
for f in webnotes.conn.sql("""select parent, fieldname
|
||||
from tabDocField where options="attach_files:" """, as_dict=1):
|
||||
if webnotes.conn.get_value("DocType", f.parent, "issingle"):
|
||||
fname = webnotes.conn.get_value(f.parent, None, f.fieldname)
|
||||
if fname:
|
||||
if not (fname.startswith("http") or fname.startswith("files")):
|
||||
webnotes.conn.set_value(f.parent, None, f.fieldname, "files/" + fname)
|
||||
else:
|
||||
webnotes.conn.sql("""update `tab%(parent)s`
|
||||
set %(fieldname)s =
|
||||
if(substr(%(fieldname)s,1,4)='http' or substr(%(fieldname)s,1,5)='files',
|
||||
%(fieldname)s,
|
||||
concat('files/', %(fieldname)s))""" % f)
|
||||
19
patches/march_2013/p12_set_item_tax_rate_in_json.py
Normal file
19
patches/march_2013/p12_set_item_tax_rate_in_json.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import webnotes
|
||||
import json
|
||||
|
||||
def execute():
|
||||
"""replace item_tax_rate stored as string with a json string"""
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
for dt in ["Quotation Item", "Sales Order Item", "Sales Invoice Item",
|
||||
"Delivery Note Item", "Supplier Quotation Item", "Purchase Order Item",
|
||||
"Purchase Invoice Item", "Purchase Receipt Item"]:
|
||||
for d in webnotes.conn.sql("""select name, item_tax_rate from `tab%s`
|
||||
where ifnull(item_tax_rate, '')!=''""" % (dt,), as_dict=1):
|
||||
try:
|
||||
json.loads(d["item_tax_rate"])
|
||||
except ValueError, e:
|
||||
webnotes.conn.sql("""update `tab%s` set item_tax_rate=%s
|
||||
where name=%s""" % (dt, "%s", "%s"),
|
||||
(json.dumps(eval(d["item_tax_rate"])), d["name"]))
|
||||
|
||||
webnotes.conn.auto_commit_on_many_writes = 0
|
||||
@@ -225,4 +225,6 @@ patch_list = [
|
||||
"patches.march_2013.p09_unset_user_type_partner",
|
||||
"patches.march_2013.p10_set_fiscal_year_for_stock",
|
||||
"patches.march_2013.p10_update_against_expense_account",
|
||||
"patches.march_2013.p11_update_attach_files",
|
||||
"patches.march_2013.p12_set_item_tax_rate_in_json",
|
||||
]
|
||||
Reference in New Issue
Block a user