mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 04:45:09 +00:00
feat(Sales Invoice): allow linking to project without adding timesheets (#44295)
* feat(Sales Invoice): allow linking to project without adding timesheets
* test: add timesheet data
(cherry picked from commit 11f65f20a0)
Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
@@ -1083,13 +1083,16 @@ class SalesInvoice(SellingController):
|
|||||||
timesheet.billing_amount = ts_doc.total_billable_amount
|
timesheet.billing_amount = ts_doc.total_billable_amount
|
||||||
|
|
||||||
def update_timesheet_billing_for_project(self):
|
def update_timesheet_billing_for_project(self):
|
||||||
if not self.timesheets and self.project:
|
if self.timesheets:
|
||||||
self.add_timesheet_data()
|
|
||||||
else:
|
|
||||||
self.calculate_billing_amount_for_timesheet()
|
self.calculate_billing_amount_for_timesheet()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist(methods=["PUT"])
|
||||||
def add_timesheet_data(self):
|
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", [])
|
self.set("timesheets", [])
|
||||||
if self.project:
|
if self.project:
|
||||||
for data in get_projectwise_timesheet_data(self.project):
|
for data in get_projectwise_timesheet_data(self.project):
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class TestTimesheet(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
sales_invoice = create_sales_invoice(do_not_save=True)
|
sales_invoice = create_sales_invoice(do_not_save=True)
|
||||||
sales_invoice.project = project
|
sales_invoice.project = project
|
||||||
|
sales_invoice._add_timesheet_data()
|
||||||
sales_invoice.submit()
|
sales_invoice.submit()
|
||||||
|
|
||||||
ts = frappe.get_doc("Timesheet", timesheet.name)
|
ts = frappe.get_doc("Timesheet", timesheet.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user