Remove enqueuing update_total_sales method, sometimes it does not include current invoice (#12522)
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 477e37d..f6d43c7 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -142,7 +142,7 @@
self.update_time_sheet(self.name)
- self.update_current_month_sales()
+ update_company_current_month_sales(self.company)
self.update_project()
def validate_pos_paid_amount(self):
@@ -181,16 +181,9 @@
self.make_gl_entries_on_cancel()
frappe.db.set(self, 'status', 'Cancelled')
- self.update_current_month_sales()
+ update_company_current_month_sales(self.company)
self.update_project()
- def update_current_month_sales(self):
- if frappe.flags.in_test:
- update_company_current_month_sales(self.company)
- else:
- frappe.enqueue('erpnext.setup.doctype.company.company.update_company_current_month_sales',
- company=self.company)
-
def update_status_updater_args(self):
if cint(self.update_stock):
self.status_updater.extend([{
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index cbb747e..ac7c830 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -358,7 +358,6 @@
monthly_total = results[0]['total'] if len(results) > 0 else 0
frappe.db.set_value("Company", company, "total_monthly_sales", monthly_total)
- frappe.db.commit()
def update_company_monthly_sales(company):
'''Cache past year monthly sales of every company based on sales invoices'''
@@ -369,7 +368,6 @@
"posting_date", filter_str, "sum")
frappe.db.set_value("Company", company, "sales_monthly_history", json.dumps(month_to_value_dict))
- frappe.db.commit()
def cache_companies_monthly_sales_history():
companies = [d['name'] for d in frappe.get_list("Company")]