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

32 lines
893 B
Python
Raw Normal View History

2021-05-20 18:13:19 +00:00
import frappe
from frappe.model.utils.rename_field import rename_field
2021-05-20 18:13:19 +00:00
def execute():
frappe.reload_doc("projects", "doctype", "timesheet")
frappe.reload_doc("projects", "doctype", "timesheet_detail")
if frappe.db.has_column("Timesheet Detail", "billable"):
rename_field("Timesheet Detail", "billable", "is_billable")
2022-03-28 13:22:46 +00:00
base_currency = frappe.defaults.get_global_default("currency")
2021-05-20 18:13:19 +00:00
2022-03-28 13:22:46 +00:00
frappe.db.sql(
"""UPDATE `tabTimesheet Detail`
2021-05-20 18:13:19 +00:00
SET base_billing_rate = billing_rate,
base_billing_amount = billing_amount,
base_costing_rate = costing_rate,
2022-03-28 13:22:46 +00:00
base_costing_amount = costing_amount"""
)
2021-05-20 18:13:19 +00:00
2022-03-28 13:22:46 +00:00
frappe.db.sql(
"""UPDATE `tabTimesheet`
2021-05-20 18:13:19 +00:00
SET currency = '{0}',
exchange_rate = 1.0,
base_total_billable_amount = total_billable_amount,
base_total_billed_amount = total_billed_amount,
2022-03-28 13:22:46 +00:00
base_total_costing_amount = total_costing_amount""".format(
base_currency
)
)