brotherton-erpnext/erpnext/patches/v8_0/update_sales_cost_in_project.py
Neil Trini Lasrado 0df93d61eb Update update_sales_cost_in_project.py (#11595)
Will break if select sum(base_grand_total) from `tabSales Order` where project=p.name and docstatus=1 returns Null. Gives - "OperationalError: (1048, "Column 'total_sales_cost' cannot be null")" Error
2017-11-16 14:07:55 +05:30

13 lines
377 B
Python

# Copyright (c) 2013, Frappé 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 = ifnull((select sum(base_grand_total)
from `tabSales Order` where project=p.name and docstatus=1), 0)
""")