brotherton-erpnext/erpnext/patches/v7_1/update_total_billing_hours.py

14 lines
609 B
Python
Raw Normal View History

2016-08-23 05:11:15 +00:00
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('projects', 'doctype', 'timesheet_detail')
frappe.reload_doc('accounts', 'doctype', 'sales_invoice_timesheet')
frappe.db.sql("""update tabTimesheet set total_billing_hours=total_hours
where total_billing_amount>0 and docstatus = 1""")
frappe.db.sql("""update `tabTimesheet Detail` set billing_hours=hours where docstatus < 2""")
frappe.db.sql(""" update `tabSales Invoice Timesheet` set billing_hours = (select total_billing_hours from `tabTimesheet`
where name = time_sheet) where time_sheet is not null""")