diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c0ad07f953..d2e6adf983 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -479,4 +479,5 @@ erpnext.patches.v9_2.rename_net_weight_in_item_master erpnext.patches.v9_2.delete_process_payroll erpnext.patches.v10_0.add_agriculture_domain erpnext.patches.v10_0.add_non_profit_domain -erpnext.patches.v10_0.setup_vat_for_uae_and_saudi_arabia \ No newline at end of file +erpnext.patches.v10_0.setup_vat_for_uae_and_saudi_arabia +erpnext.patches.v10_0.copy_projects_renamed_fields \ No newline at end of file diff --git a/erpnext/patches/v10_0/copy_projects_renamed_fields.py b/erpnext/patches/v10_0/copy_projects_renamed_fields.py new file mode 100644 index 0000000000..58e32b0de8 --- /dev/null +++ b/erpnext/patches/v10_0/copy_projects_renamed_fields.py @@ -0,0 +1,12 @@ +import frappe +from frappe.model.utils.rename_field import rename_field + +def execute(): + """ copy data from old fields to new """ + frappe.reload_doc("projects", "doctype", "project") + + if frappe.db.has_column('Project', 'total_sales_cost'): + rename_field('Project', "total_sales_cost", "total_sales_amount") + + if frappe.db.has_column('Project', 'total_billing_amount'): + rename_field('Project', "total_billing_amount", "total_billable_amount") \ No newline at end of file diff --git a/erpnext/patches/v8_0/update_sales_cost_in_project.py b/erpnext/patches/v8_0/update_sales_cost_in_project.py index 4f89ba036d..1a29fc4db4 100644 --- a/erpnext/patches/v8_0/update_sales_cost_in_project.py +++ b/erpnext/patches/v8_0/update_sales_cost_in_project.py @@ -2,8 +2,10 @@ from __future__ import unicode_literals import frappe def execute(): + frappe.reload_doc("projects", "doctype", "project") + frappe.db.sql(""" update `tabProject` p - set total_sales_cost = ifnull((select sum(base_grand_total) + set total_sales_amount = ifnull((select sum(base_grand_total) from `tabSales Order` where project=p.name and docstatus=1), 0) """) \ No newline at end of file