brotherton-erpnext/erpnext/patches/v8_0/update_sales_cost_in_project.py
Zarrar 6e0acbe4d0 Patch to copy old field data to new field (#11997)
* patch to copy old fields data to new ones

* fix for patches related to project

* use rename_field function, copy if only field present
2017-12-14 12:21:00 +05:30

11 lines
303 B
Python

from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("projects", "doctype", "project")
frappe.db.sql("""
update `tabProject` p
set total_sales_amount = ifnull((select sum(base_grand_total)
from `tabSales Order` where project=p.name and docstatus=1), 0)
""")