def execute(): # rename doctypes tables = frappe.db.sql_list("show tables") for old_dt, new_dt in [["Journal Voucher Detail", "Journal Entry Account"], ["Journal Voucher", "Journal Entry"], ["Budget Distribution Detail", "Monthly Distribution Percentage"], ["Budget Distribution", "Monthly Distribution"]]: if "tab"+new_dt not in tables: frappe.rename_doc("DocType", old_dt, new_dt, force=True) # reload new child doctypes frappe.reload_doc("manufacturing", "doctype", "production_order_operation") frappe.reload_doc("manufacturing", "doctype", "workstation_working_hour") frappe.reload_doc("stock", "doctype", "item_variant") frappe.reload_doc("accounts", "doctype", "party_account") frappe.reload_doc("accounts", "doctype", "fiscal_year_company") frappe.reload_doc("workflow", "doctype", "workflow") #rename table fieldnames for dn in rename_map: frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) for dt, field_list in rename_map.items(): for field in field_list: rename_field(dt, field[0], field[1]) # update voucher type for old, new in [["Bank Voucher", "Bank Entry"], ["Cash Voucher", "Cash Entry"], ["Credit Card Voucher", "Credit Card Entry"], ["Contra Voucher", "Contra Entry"], ["Write Off Voucher", "Write Off Entry"], ["Excise Voucher", "Excise Entry"]]: frappe.db.sql("update `tabJournal Entry` set voucher_type=%s where voucher_type=%s", (new, old))
def execute(): for dn in rename_map: frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) for dt, field_list in rename_map.items(): for field in field_list: rename_field(dt, field[0], field[1])
def execute(): tables = frappe.db.sql_list("show tables") if "tabUser" not in tables: frappe.rename_doc("DocType", "Profile", "User", force=True) frappe.reload_doc("website", "doctype", "blogger") if "profile" in get_table_columns("Blogger"): rename_field("Blogger", "profile", "user")
def execute(): frappe.reload_doc("custom", "doctype", "customize_form") frappe.reload_doc("email", "doctype", "email_alert") frappe.reload_doc("desk", "doctype", "event") frappe.reload_doc("workflow", "doctype", "workflow") for dt, field_list in rename_map.items(): for field in field_list: rename_field(dt, field[0], field[1])
def execute(): for doctypes, fields in [[selling_doctypes, selling_renamed_fields], [buying_doctypes, buying_renamed_fields]]: for dt in doctypes: frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt)) table_columns = frappe.db.get_table_columns(dt) base_net_total = frappe.db.sql("select sum(ifnull({0}, 0)) from `tab{1}`".format(fields[0][1], dt))[0][0] if not base_net_total: for f in fields: if f[0] in table_columns: rename_field(dt, f[0], f[1]) # Added new field "total_taxes_and_charges" in buying cycle, updating value if dt in ("Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"): frappe.db.sql("""update `tab{0}` set total_taxes_and_charges = round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))
def execute(): for doctypes, fields in [[selling_doctypes, selling_renamed_fields], [buying_doctypes, buying_renamed_fields]]: for dt in doctypes: meta = frappe.get_meta(dt) frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt)) base_net_total = frappe.db.sql( "select sum(ifnull({0}, 0)) from `tab{1}`".format( fields[0][1], dt))[0][0] if not base_net_total: for f in fields: if meta.get_field(f[0]): rename_field(dt, f[0], f[1]) # Added new field "total_taxes_and_charges" in buying cycle, updating value if dt in ("Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"): frappe.db.sql( """update `tab{0}` set total_taxes_and_charges = round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))
def execute(): tables = frappe.db.sql_list("show tables") if "tabWebsite Route" not in tables: frappe.rename_doc("DocType", "Website Sitemap", "Website Route", force=True) if "tabWebsite Template" not in tables: frappe.rename_doc("DocType", "Website Sitemap Config", "Website Template", force=True) try: if "tabWebsite Route Permission" not in tables: frappe.rename_doc("DocType", "Website Sitemap Permission", "Website Route Permission", force=True) for d in ("Blog Category", "Blog Post", "Web Page", "Website Route", "Website Group"): rename_field(d, "parent_website_sitemap", "parent_website_route") rename_field("Website Route", "website_sitemap_config", "website_template") rename_field("Website Route Permission", "website_sitemap", "website_route") except Exception, e: if e.args[0] != 1054: raise
def execute(): tables = frappe.db.sql_list("show tables") if "tabWebsite Route" not in tables: frappe.rename_doc("DocType", "Website Sitemap", "Website Route", force=True) if "tabWebsite Template" not in tables: frappe.rename_doc("DocType", "Website Sitemap Config", "Website Template", force=True) try: if "tabWebsite Route Permission" not in tables: frappe.rename_doc("DocType", "Website Sitemap Permission", "Website Route Permission", force=True) for d in ("Blog Category", "Blog Post", "Web Page", "Website Route", "Website Group"): frappe.reload_doc("website", "doctype", frappe.scrub(d)) rename_field(d, "parent_website_sitemap", "parent_website_route") rename_field("Website Route", "website_sitemap_config", "website_template") rename_field("Website Route Permission", "website_sitemap", "website_route") except Exception, e: if e.args[0] != 1054: raise
def rename_field_if_exists(doctype, old_fieldname, new_fieldname): try: rename_field(doctype, old_fieldname, new_fieldname) except Exception, e: if e.args[0] != 1054: raise
def execute(): rename_map = { "Quotation Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"] ], "Sales Order Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"], ["reserved_warehouse", "warehouse"] ], "Delivery Note Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"] ], "Sales Invoice Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"] ], "Supplier Quotation Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["purchase_rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"] ], "Purchase Order Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["purchase_rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"] ], "Purchase Receipt Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["purchase_rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"] ], "Purchase Invoice Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"], ["expense_head", "expense_account"] ], "Item": [ ["purchase_account", "expense_account"], ["default_sales_cost_center", "selling_cost_center"], ["cost_center", "buying_cost_center"], ["default_income_account", "income_account"], ], "Item Price": [ ["ref_rate", "price_list_rate"] ] } reload_docs(rename_map) for dt, field_list in rename_map.items(): for field in field_list: rename_field(dt, field[0], field[1])
def execute(): rename_map = { "Quotation Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"], ], "Sales Order Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"], ["reserved_warehouse", "warehouse"], ], "Delivery Note Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"], ], "Sales Invoice Item": [ ["ref_rate", "price_list_rate"], ["base_ref_rate", "base_price_list_rate"], ["adj_rate", "discount_percentage"], ["export_rate", "rate"], ["basic_rate", "base_rate"], ["amount", "base_amount"], ["export_amount", "amount"], ], "Supplier Quotation Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["purchase_rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"], ], "Purchase Order Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["purchase_rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"], ], "Purchase Receipt Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["purchase_rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"], ], "Purchase Invoice Item": [ ["import_ref_rate", "price_list_rate"], ["purchase_ref_rate", "base_price_list_rate"], ["discount_rate", "discount_percentage"], ["import_rate", "rate"], ["rate", "base_rate"], ["amount", "base_amount"], ["import_amount", "amount"], ["expense_head", "expense_account"], ], "Item": [ ["purchase_account", "expense_account"], ["default_sales_cost_center", "selling_cost_center"], ["cost_center", "buying_cost_center"], ["default_income_account", "income_account"], ], "Item Price": [["ref_rate", "price_list_rate"]], } reload_docs(rename_map) for dt, field_list in rename_map.items(): for field in field_list: rename_field(dt, field[0], field[1])