brotherton-erpnext/erpnext/patches/v5_4/update_purchase_cost_against_project.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
536 B
Python
Raw Normal View History

2015-08-18 07:09:50 +00:00
# Copyright (c) 2015, 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():
for p in frappe.get_all("Project"):
purchase_cost = frappe.db.sql("""select sum(ifnull(base_net_amount, 0))
2016-03-09 11:32:59 +00:00
from `tabPurchase Invoice Item` where project = %s and docstatus=1""", p.name)
purchase_cost = purchase_cost and purchase_cost[0][0] or 0
frappe.db.set_value("Project", p.name, "total_purchase_cost", purchase_cost)