diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 3796c8293cf..1fae69f9da8 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -400,4 +400,5 @@ erpnext.patches.v8_0.delete_schools_depricated_doctypes erpnext.patches.v8_0.update_customer_pos_id erpnext.patches.v8_0.rename_items_in_status_field_of_material_request erpnext.patches.v8_0.delete_bin_indexes -erpnext.patches.v8_0.change_in_words_varchar_length \ No newline at end of file +erpnext.patches.v8_0.update_sales_cost_in_project +erpnext.patches.v8_0.change_in_words_varchar_length diff --git a/erpnext/patches/v8_0/update_sales_cost_in_project.py b/erpnext/patches/v8_0/update_sales_cost_in_project.py new file mode 100644 index 00000000000..cc3798e0565 --- /dev/null +++ b/erpnext/patches/v8_0/update_sales_cost_in_project.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.db.sql(""" + update `tabProject` p + set total_sales_cost = (select sum(base_grand_total) + from `tabSales Order` where project=p.name and docstatus=1) + """) \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 0345f05861e..de198a9cdca 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -178,7 +178,7 @@ class Project(Document): self.total_purchase_cost = total_purchase_cost and total_purchase_cost[0][0] or 0 def update_sales_costing(self): - total_sales_cost = frappe.db.sql("""select sum(grand_total) + total_sales_cost = frappe.db.sql("""select sum(base_grand_total) from `tabSales Order` where project = %s and docstatus=1""", self.name) self.total_sales_cost = total_sales_cost and total_sales_cost[0][0] or 0