patch fix

This commit is contained in:
Nabin Hait 2015-05-27 16:14:00 +05:30
parent f52b5ac8af
commit 54a10cd2af
2 changed files with 5 additions and 25 deletions

View File

@ -19,7 +19,7 @@ def create_receivable_payable_account():
receivable_payable_accounts = frappe._dict()
def _create_account(args):
if args["parent_account"]:
if args["parent_account"] and frappe.db.exists("Account", args["parent_account"]):
account_id = frappe.db.get_value("Account",
{"account_name": args["account_name"], "company": args["company"]})
if not account_id:

View File

@ -16,9 +16,6 @@ def execute():
for name, script in frappe.db.sql("select name, {0} as script from `tab{1}` where ({2}) {3}".format(script_field, dt, cond1, cond2)):
update_script(dt, name, script_field, script, renamed_fields)
# update fieldnames in property setter for idx
update_idx_property(renamed_fields)
def get_all_renamed_fields():
from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
@ -49,9 +46,9 @@ def get_all_renamed_fields():
)
for fields in rename_map.values():
if fields[0] != "entries":
renamed_fields += tuple(fields)
valid_fields = [d for d in fields if d[0] != "entries"]
renamed_fields += tuple(valid_fields)
return renamed_fields
def update_script(dt, name, script_field, script, renamed_fields):
@ -65,21 +62,4 @@ def update_script(dt, name, script_field, script, renamed_fields):
elif dt in ("Sales Invoice", "Purchase Invoice"):
script = re.sub(r"\bentries\b", "items", script)
frappe.db.set_value(dt, name, script_field, script)
def update_idx_property(renamed_fields):
for ps, ordered_fields, dt in frappe.db.sql("select name, value, doc_type from `tabProperty Setter` where property = '_idx'"):
for from_field, to_field in renamed_fields:
if from_field in ordered_fields:
ordered_fields[ordered_fields.index(from_field)] = to_field
# remove invalid fields
valid_fields = [f.fieldname for f in frappe.get_meta(dt).fields]
for fld in ordered_fields:
if fld not in valid_fields:
ordered_fields.pop(fld)
frappe.db.set_value("Property Setter", ps, "value", ordered_fields)
frappe.db.sql("delete from `tabProperty Setter` where `property` = 'idx'")
frappe.db.set_value(dt, name, script_field, script)