From b1095bb91ba1d352792bec7f7d81810d41f9ef9f Mon Sep 17 00:00:00 2001 From: venkat102 Date: Thu, 13 Feb 2025 23:07:45 +0530 Subject: [PATCH] fix(sales invoice): check fetch_timesheet_in_sales_invoice enabled before fetching the timesheet (cherry picked from commit 914ad357fd4172e4f34c0b61ace65f04a1430ffb) # Conflicts: # erpnext/accounts/doctype/sales_invoice/sales_invoice.py --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 8 ++++++-- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index a074c9b1c0a..36351bb3d12 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -897,8 +897,12 @@ frappe.ui.form.on("Sales Invoice", { project: function (frm) { if (frm.doc.project) { - frm.events.add_timesheet_data(frm, { - project: frm.doc.project, + frappe.db.get_value("Projects Settings", {}, "fetch_timesheet_in_sales_invoice", (r) => { + if (r.fetch_timesheet_in_sales_invoice) { + frm.events.add_timesheet_data(frm, { + project: frm.doc.project, + }); + } }); } }, diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7345a5ef78d..49bdd34bb43 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1090,7 +1090,15 @@ class SalesInvoice(SellingController): timesheet.billing_amount = ts_doc.total_billable_amount def update_timesheet_billing_for_project(self): +<<<<<<< HEAD if not self.timesheets and self.project: +======= + if ( + not self.timesheets + and self.project + and frappe.db.get_single_value("Projects Settings", "fetch_timesheet_in_sales_invoice") + ): +>>>>>>> 914ad357fd (fix(sales invoice): check fetch_timesheet_in_sales_invoice enabled before fetching the timesheet) self.add_timesheet_data() else: self.calculate_billing_amount_for_timesheet()