From 0df93d61ebd68f865d4256f10e16931cd1775f51 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 16 Nov 2017 14:07:55 +0530 Subject: [PATCH] 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 --- erpnext/patches/v8_0/update_sales_cost_in_project.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 cc3798e0565..8f3aa262410 100644 --- a/erpnext/patches/v8_0/update_sales_cost_in_project.py +++ b/erpnext/patches/v8_0/update_sales_cost_in_project.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2013, Frappé Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals @@ -7,6 +7,6 @@ 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 + set total_sales_cost = ifnull((select sum(base_grand_total) + from `tabSales Order` where project=p.name and docstatus=1), 0) + """)