mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-11 14:29:12 +00:00
fix(sales invoice): check fetch_timesheet_in_sales_invoice enabled before fetching the timesheet
This commit is contained in:
@@ -895,8 +895,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,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1096,16 +1096,17 @@ 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
|
||||
and frappe.db.get_single_value("Projects Settings", "fetch_timesheet_in_sales_invoice")
|
||||
):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user