brotherton-erpnext/erpnext/patches/v13_0/update_timesheet_changes.py

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

25 lines
914 B
Python
Raw Normal View History

2021-05-20 14:11:36 +05:30
from __future__ import unicode_literals
import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
frappe.reload_doc("projects", "doctype", "timesheet")
frappe.reload_doc("projects", "doctype", "timesheet_detail")
2021-05-20 19:53:30 +05:30
if frappe.db.has_column("Timesheet Detail", "billable"):
rename_field("Timesheet Detail", "billable", "is_billable")
base_currency = frappe.defaults.get_global_default('currency')
2021-05-20 14:11:36 +05:30
frappe.db.sql("""UPDATE `tabTimesheet Detail`
2021-05-20 14:15:58 +05:30
SET base_billing_rate = billing_rate,
2021-05-20 14:11:36 +05:30
base_billing_amount = billing_amount,
base_costing_rate = costing_rate,
base_costing_amount = costing_amount""")
2021-05-20 19:53:30 +05:30
2021-05-20 14:11:36 +05:30
frappe.db.sql("""UPDATE `tabTimesheet`
2021-05-20 14:15:58 +05:30
SET currency = '{0}',
2021-05-20 14:11:36 +05:30
exchange_rate = 1.0,
base_total_billable_amount = total_billable_amount,
base_total_billed_amount = total_billed_amount,
base_total_costing_amount = total_costing_amount""".format(base_currency))