From 91fd29a9636c46d0a069be2e8d6665dd632c5b45 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 17 Jan 2018 16:14:31 +0530 Subject: [PATCH] Remove enqueuing update_total_sales method, sometimes it does not include current invoice (#12522) --- .../accounts/doctype/sales_invoice/sales_invoice.py | 11 ++--------- erpnext/setup/doctype/company/company.py | 2 -- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 477e37d45e..f6d43c7f70 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -142,7 +142,7 @@ class SalesInvoice(SellingController): 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 @@ class SalesInvoice(SellingController): 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 cbb747e509..ac7c830675 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -358,7 +358,6 @@ def update_company_current_month_sales(company): 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 @@ def update_company_monthly_sales(company): "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")]