2014-02-10 09:17:54 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
2014-02-14 10:17:51 +00:00
|
|
|
import frappe
|
|
|
|
from frappe.model import rename_field
|
2014-02-11 06:26:51 +00:00
|
|
|
|
2014-02-10 09:17:54 +00:00
|
|
|
|
|
|
|
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"],
|
2014-02-12 10:34:17 +00:00
|
|
|
["cost_center", "buying_cost_center"],
|
|
|
|
["default_income_account", "income_account"],
|
2014-02-10 09:17:54 +00:00
|
|
|
],
|
2014-02-10 12:00:28 +00:00
|
|
|
"Item Price": [
|
|
|
|
["ref_rate", "price_list_rate"]
|
|
|
|
]
|
2014-02-10 09:17:54 +00:00
|
|
|
}
|
|
|
|
|
2014-02-11 06:26:51 +00:00
|
|
|
reload_docs(rename_map)
|
2014-02-10 09:17:54 +00:00
|
|
|
|
|
|
|
for dt, field_list in rename_map.items():
|
|
|
|
for field in field_list:
|
2014-02-11 06:26:51 +00:00
|
|
|
rename_field(dt, field[0], field[1])
|
|
|
|
|
|
|
|
def reload_docs(docs):
|
|
|
|
for dn in docs:
|
2014-02-14 10:17:51 +00:00
|
|
|
frappe.reload_doc(get_module(dn), "doctype", dn.lower().replace(" ", "_"))
|
2014-02-11 06:26:51 +00:00
|
|
|
|
|
|
|
# reload all standard print formats
|
2014-02-14 10:17:51 +00:00
|
|
|
for pf in frappe.conn.sql("""select name, module from `tabPrint Format`
|
2014-02-11 06:26:51 +00:00
|
|
|
where ifnull(standard, 'No') = 'Yes'""", as_dict=1):
|
2014-02-12 09:23:18 +00:00
|
|
|
try:
|
2014-02-14 10:17:51 +00:00
|
|
|
frappe.reload_doc(pf.module, "Print Format", pf.name)
|
2014-02-12 09:23:18 +00:00
|
|
|
except Exception, e:
|
|
|
|
print e
|
|
|
|
pass
|
2014-02-11 06:26:51 +00:00
|
|
|
|
|
|
|
# reload all standard reports
|
2014-02-14 10:17:51 +00:00
|
|
|
for r in frappe.conn.sql("""select name, ref_doctype from `tabReport`
|
2014-02-11 06:26:51 +00:00
|
|
|
where ifnull(is_standard, 'No') = 'Yes'
|
|
|
|
and report_type in ('Report Builder', 'Query Report')""", as_dict=1):
|
2014-02-14 10:17:51 +00:00
|
|
|
frappe.reload_doc(get_module(r.ref_doctype), "Report", r.name)
|
2014-02-12 09:23:18 +00:00
|
|
|
|
|
|
|
def get_module(dn):
|
2014-02-14 10:17:51 +00:00
|
|
|
return frappe.conn.get_value("DocType", dn, "module").lower().replace(" ", "_")
|