From aeb88385bbae9470956aefec57d69eb3a6fbc0fa Mon Sep 17 00:00:00 2001 From: Anupam Date: Thu, 20 May 2021 14:11:36 +0530 Subject: [PATCH] patch: timesheet changes --- erpnext/patches.txt | 2 +- ...me_billable_to_is_billable_in_timesheet.py | 7 ------ .../patches/v13_0/update_timesheet_changes.py | 24 +++++++++++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) delete mode 100644 erpnext/patches/v13_0/rename_billable_to_is_billable_in_timesheet.py create mode 100644 erpnext/patches/v13_0/update_timesheet_changes.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0caad586e5a..d4655e19b91 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -779,4 +779,4 @@ erpnext.patches.v12_0.add_ewaybill_validity_field erpnext.patches.v13_0.germany_make_custom_fields erpnext.patches.v13_0.germany_fill_debtor_creditor_number erpnext.patches.v13_0.set_pos_closing_as_failed -erpnext.patches.v13_0.rename_billable_to_is_billable_in_timesheet +erpnext.patches.v13_0.update_timesheet_changes diff --git a/erpnext/patches/v13_0/rename_billable_to_is_billable_in_timesheet.py b/erpnext/patches/v13_0/rename_billable_to_is_billable_in_timesheet.py deleted file mode 100644 index 6860a37559e..00000000000 --- a/erpnext/patches/v13_0/rename_billable_to_is_billable_in_timesheet.py +++ /dev/null @@ -1,7 +0,0 @@ -from __future__ import unicode_literals -import frappe -from frappe.model.utils.rename_field import rename_field - -def execute(): - if "billable" in frappe.db.get_table_columns("Timesheet Detail"): - rename_field("Timesheet Detail", "billable", "is_billable") \ No newline at end of file diff --git a/erpnext/patches/v13_0/update_timesheet_changes.py b/erpnext/patches/v13_0/update_timesheet_changes.py new file mode 100644 index 00000000000..87178b2f842 --- /dev/null +++ b/erpnext/patches/v13_0/update_timesheet_changes.py @@ -0,0 +1,24 @@ +from __future__ import unicode_literals +import frappe +from frappe.model.utils.rename_field import rename_field + +def execute(): + if "billable" in frappe.db.get_table_columns("Timesheet Detail"): + rename_field("Timesheet Detail", "billable", "is_billable") + + base_currency = frappe.defaults.get_global_default('currency') + frappe.reload_doc("projects", "doctype", "timesheet") + frappe.reload_doc("projects", "doctype", "timesheet_detail") + + frappe.db.sql("""UPDATE `tabTimesheet Detail` + SET base_billing_rate = billing_rate, + base_billing_amount = billing_amount, + base_costing_rate = costing_rate, + base_costing_amount = costing_amount""") + + frappe.db.sql("""UPDATE `tabTimesheet` + SET currency = '{0}', + 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)) \ No newline at end of file