From b004855e7cfe522cf138f803ca46840f5f018b60 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 27 Jan 2025 14:31:44 +0530 Subject: [PATCH] Revert "feat(Sales Invoice): allow linking to project without adding timesheets (backport #44295)" (#45531) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "feat(Sales Invoice): allow linking to project without adding timeshee…" This reverts commit 2c2a25ab16f5b53ddf17dc23abff6e9ab14f1e4d. --- .../accounts/doctype/sales_invoice/sales_invoice.py | 11 ++++------- erpnext/projects/doctype/timesheet/test_timesheet.py | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 97871ba7d6f..6e039b4b34f 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1083,16 +1083,13 @@ class SalesInvoice(SellingController): timesheet.billing_amount = ts_doc.total_billable_amount def update_timesheet_billing_for_project(self): - if self.timesheets: + if not self.timesheets and self.project: + self.add_timesheet_data() + else: self.calculate_billing_amount_for_timesheet() - @frappe.whitelist(methods=["PUT"]) + @frappe.whitelist() def add_timesheet_data(self): - if not self.timesheets and self.project: - self._add_timesheet_data() - self.save() - - def _add_timesheet_data(self): self.set("timesheets", []) if self.project: for data in get_projectwise_timesheet_data(self.project): diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 39140b335c9..da042f36aef 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -62,7 +62,6 @@ class TestTimesheet(unittest.TestCase): ) sales_invoice = create_sales_invoice(do_not_save=True) sales_invoice.project = project - sales_invoice._add_timesheet_data() sales_invoice.submit() ts = frappe.get_doc("Timesheet", timesheet.name)