2015-03-03 09:25:30 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
2014-12-24 11:34:48 +00:00
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
import frappe
|
2015-07-17 09:43:29 +00:00
|
|
|
from frappe.model.utils.rename_field import rename_field
|
2014-12-24 11:34:48 +00:00
|
|
|
from frappe.modules import scrub, get_doctype_module
|
|
|
|
|
|
|
|
rename_map = {
|
2014-12-25 12:49:39 +00:00
|
|
|
"Opportunity": [
|
|
|
|
["enquiry_details", "items"]
|
|
|
|
],
|
|
|
|
"Quotation": [
|
|
|
|
["quotation_details", "items"],
|
|
|
|
["other_charges", "taxes"]
|
|
|
|
],
|
|
|
|
"Sales Order": [
|
|
|
|
["sales_order_details", "items"],
|
|
|
|
["other_charges", "taxes"],
|
|
|
|
["packing_details", "packed_items"]
|
|
|
|
],
|
|
|
|
"Delivery Note": [
|
|
|
|
["delivery_note_details", "items"],
|
|
|
|
["other_charges", "taxes"],
|
|
|
|
["packing_details", "packed_items"]
|
|
|
|
],
|
2014-12-24 11:34:48 +00:00
|
|
|
"Sales Invoice": [
|
|
|
|
["entries", "items"],
|
2014-12-25 12:49:39 +00:00
|
|
|
["other_charges", "taxes"],
|
|
|
|
["packing_details", "packed_items"],
|
|
|
|
["advance_adjustment_details", "advances"]
|
|
|
|
],
|
|
|
|
"Material Request": [
|
|
|
|
["indent_details", "items"]
|
|
|
|
],
|
|
|
|
"Supplier Quotation": [
|
|
|
|
["quotation_items", "items"],
|
|
|
|
["other_charges", "taxes"]
|
|
|
|
],
|
|
|
|
"Purchase Order": [
|
|
|
|
["po_details", "items"],
|
|
|
|
["other_charges", "taxes"],
|
|
|
|
["po_raw_material_details", "supplied_items"]
|
|
|
|
],
|
|
|
|
"Purchase Receipt": [
|
|
|
|
["purchase_receipt_details", "items"],
|
|
|
|
["other_charges", "taxes"],
|
|
|
|
["pr_raw_material_details", "supplied_items"]
|
|
|
|
],
|
2014-12-24 11:34:48 +00:00
|
|
|
"Purchase Invoice": [
|
|
|
|
["entries", "items"],
|
2014-12-25 12:49:39 +00:00
|
|
|
["other_charges", "taxes"],
|
|
|
|
["advance_allocation_details", "advances"]
|
|
|
|
],
|
|
|
|
"Production Order": [
|
|
|
|
["production_order_operations", "operations"]
|
|
|
|
],
|
|
|
|
"BOM": [
|
|
|
|
["bom_operations", "operations"],
|
|
|
|
["bom_materials", "items"],
|
|
|
|
["flat_bom_details", "exploded_items"]
|
|
|
|
],
|
|
|
|
"Payment Reconciliation": [
|
|
|
|
["payment_reconciliation_payments", "payments"],
|
|
|
|
["payment_reconciliation_invoices", "invoices"]
|
|
|
|
],
|
2015-05-11 05:45:14 +00:00
|
|
|
"Sales Taxes and Charges Template": [
|
2014-12-25 12:49:39 +00:00
|
|
|
["other_charges", "taxes"],
|
|
|
|
["valid_for_territories", "territories"]
|
|
|
|
],
|
2015-05-11 05:45:14 +00:00
|
|
|
"Purchase Taxes and Charges Template": [
|
2014-12-25 12:49:39 +00:00
|
|
|
["other_charges", "taxes"]
|
|
|
|
],
|
|
|
|
"Shipping Rule": [
|
|
|
|
["shipping_rule_conditions", "conditions"],
|
|
|
|
["valid_for_territories", "territories"]
|
|
|
|
],
|
|
|
|
"Price List": [
|
|
|
|
["valid_for_territories", "territories"]
|
|
|
|
],
|
|
|
|
"Appraisal": [
|
|
|
|
["appraisal_details", "goals"]
|
|
|
|
],
|
|
|
|
"Appraisal Template": [
|
|
|
|
["kra_sheet", "goals"]
|
|
|
|
],
|
2014-12-24 11:34:48 +00:00
|
|
|
"Bank Reconciliation": [
|
|
|
|
["entries", "journal_entries"]
|
|
|
|
],
|
2014-12-25 12:49:39 +00:00
|
|
|
"Cost Center": [
|
|
|
|
["budget_details", "budgets"]
|
|
|
|
],
|
|
|
|
"C-Form": [
|
|
|
|
["invoice_details", "invoices"]
|
|
|
|
],
|
|
|
|
"Employee": [
|
|
|
|
["employee_leave_approvers", "leave_approvers"],
|
2014-12-26 06:11:15 +00:00
|
|
|
["educational_qualification_details", "education"],
|
|
|
|
["previous_experience_details", "external_work_history"],
|
|
|
|
["experience_in_company_details", "internal_work_history"]
|
2014-12-25 12:49:39 +00:00
|
|
|
],
|
|
|
|
"Expense Claim": [
|
|
|
|
["expense_voucher_details", "expenses"]
|
|
|
|
],
|
|
|
|
"Fiscal Year": [
|
|
|
|
["fiscal_year_companies", "companies"]
|
|
|
|
],
|
|
|
|
"Holiday List": [
|
|
|
|
["holiday_list_details", "holidays"]
|
|
|
|
],
|
|
|
|
"Installation Note": [
|
|
|
|
["installed_item_details", "items"]
|
|
|
|
],
|
|
|
|
"Item": [
|
|
|
|
["item_reorder", "reorder_levels"],
|
|
|
|
["uom_conversion_details", "uoms"],
|
2014-12-26 06:11:15 +00:00
|
|
|
["item_supplier_details", "supplier_items"],
|
|
|
|
["item_customer_details", "customer_items"],
|
2014-12-25 12:49:39 +00:00
|
|
|
["item_tax", "taxes"],
|
|
|
|
["item_specification_details", "quality_parameters"],
|
|
|
|
["item_website_specifications", "website_specifications"]
|
|
|
|
],
|
|
|
|
"Item Group": [
|
|
|
|
["item_website_specifications", "website_specifications"]
|
|
|
|
],
|
|
|
|
"Landed Cost Voucher": [
|
|
|
|
["landed_cost_purchase_receipts", "purchase_receipts"],
|
|
|
|
["landed_cost_items", "items"],
|
|
|
|
["landed_cost_taxes_and_charges", "taxes"]
|
|
|
|
],
|
|
|
|
"Maintenance Schedule": [
|
|
|
|
["item_maintenance_detail", "items"],
|
|
|
|
["maintenance_schedule_detail", "schedules"]
|
|
|
|
],
|
|
|
|
"Maintenance Visit": [
|
|
|
|
["maintenance_visit_details", "purposes"]
|
|
|
|
],
|
|
|
|
"Packing Slip": [
|
|
|
|
["item_details", "items"]
|
|
|
|
],
|
|
|
|
"Customer": [
|
|
|
|
["party_accounts", "accounts"]
|
|
|
|
],
|
|
|
|
"Customer Group": [
|
|
|
|
["party_accounts", "accounts"]
|
|
|
|
],
|
|
|
|
"Supplier": [
|
|
|
|
["party_accounts", "accounts"]
|
|
|
|
],
|
|
|
|
"Supplier Type": [
|
|
|
|
["party_accounts", "accounts"]
|
|
|
|
],
|
|
|
|
"Payment Tool": [
|
2014-12-26 06:11:15 +00:00
|
|
|
["payment_tool_details", "vouchers"]
|
2014-12-25 12:49:39 +00:00
|
|
|
],
|
|
|
|
"Production Planning Tool": [
|
|
|
|
["pp_so_details", "sales_orders"],
|
|
|
|
["pp_details", "items"]
|
|
|
|
],
|
|
|
|
"Quality Inspection": [
|
|
|
|
["qa_specification_details", "readings"]
|
|
|
|
],
|
|
|
|
"Salary Slip": [
|
|
|
|
["earning_details", "earnings"],
|
|
|
|
["deduction_details", "deductions"]
|
|
|
|
],
|
|
|
|
"Salary Structure": [
|
|
|
|
["earning_details", "earnings"],
|
|
|
|
["deduction_details", "deductions"]
|
|
|
|
],
|
2015-07-16 06:49:57 +00:00
|
|
|
"Product Bundle": [
|
2014-12-25 12:49:39 +00:00
|
|
|
["sales_bom_items", "items"]
|
|
|
|
],
|
|
|
|
"SMS Settings": [
|
2014-12-26 06:11:15 +00:00
|
|
|
["static_parameter_details", "parameters"]
|
2014-12-25 12:49:39 +00:00
|
|
|
],
|
|
|
|
"Stock Entry": [
|
|
|
|
["mtn_details", "items"]
|
|
|
|
],
|
|
|
|
"Sales Partner": [
|
|
|
|
["partner_target_details", "targets"]
|
|
|
|
],
|
|
|
|
"Sales Person": [
|
|
|
|
["target_details", "targets"]
|
|
|
|
],
|
|
|
|
"Territory": [
|
|
|
|
["target_details", "targets"]
|
|
|
|
],
|
|
|
|
"Time Log Batch": [
|
|
|
|
["time_log_batch_details", "time_logs"]
|
|
|
|
],
|
|
|
|
"Workstation": [
|
|
|
|
["workstation_operation_hours", "working_hours"]
|
|
|
|
],
|
2014-12-25 11:44:18 +00:00
|
|
|
"Payment Reconciliation Payment": [
|
|
|
|
["journal_voucher", "journal_entry"],
|
|
|
|
],
|
|
|
|
"Purchase Invoice Advance": [
|
|
|
|
["journal_voucher", "journal_entry"],
|
|
|
|
],
|
|
|
|
"Sales Invoice Advance": [
|
|
|
|
["journal_voucher", "journal_entry"],
|
2014-12-25 12:49:39 +00:00
|
|
|
],
|
|
|
|
"Journal Entry": [
|
|
|
|
["entries", "accounts"]
|
2015-01-10 10:33:49 +00:00
|
|
|
],
|
|
|
|
"Monthly Distribution": [
|
|
|
|
["budget_distribution_details", "percentages"]
|
2014-12-25 11:44:18 +00:00
|
|
|
]
|
2014-12-24 11:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def execute():
|
2014-12-25 10:31:55 +00:00
|
|
|
# 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"]]:
|
2015-01-01 08:10:18 +00:00
|
|
|
if "tab"+new_dt not in tables:
|
2014-12-25 10:31:55 +00:00
|
|
|
frappe.rename_doc("DocType", old_dt, new_dt, force=True)
|
2014-12-25 11:44:18 +00:00
|
|
|
|
2015-01-02 07:16:49 +00:00
|
|
|
# reload new child doctypes
|
2015-01-01 08:10:18 +00:00
|
|
|
frappe.reload_doc("manufacturing", "doctype", "production_order_operation")
|
2015-01-02 07:16:49 +00:00
|
|
|
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")
|
2015-01-01 08:10:18 +00:00
|
|
|
|
2014-12-25 12:49:39 +00:00
|
|
|
#rename table fieldnames
|
2015-05-11 10:38:14 +00:00
|
|
|
for dn in rename_map:
|
|
|
|
if not frappe.db.exists("DocType", dn):
|
|
|
|
continue
|
|
|
|
frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn))
|
2014-12-25 12:49:39 +00:00
|
|
|
|
2015-05-11 10:38:14 +00:00
|
|
|
for dt, field_list in rename_map.items():
|
|
|
|
if not frappe.db.exists("DocType", dt):
|
|
|
|
continue
|
|
|
|
for field in field_list:
|
|
|
|
rename_field(dt, field[0], field[1])
|
2014-12-25 12:49:39 +00:00
|
|
|
|
2014-12-25 11:44:18 +00:00
|
|
|
# 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))
|