From 70abac00616a66a5d72129adea9535a26cc9f1c7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 15 Mar 2018 12:18:58 +0530 Subject: [PATCH 1/3] Get territory from sales invoice --- .../report/sales_register/sales_register.py | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py index ace8d54916..f74ccc7cd8 100644 --- a/erpnext/accounts/report/sales_register/sales_register.py +++ b/erpnext/accounts/report/sales_register/sales_register.py @@ -25,8 +25,6 @@ def _execute(filters, additional_table_columns=None, additional_query_columns=No #Cost Center & Warehouse Map invoice_cc_wh_map = get_invoice_cc_wh_map(invoice_list) invoice_so_dn_map = get_invoice_so_dn_map(invoice_list) - customers = list(set([inv.customer for inv in invoice_list])) - customer_map = get_customer_details(customers) company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency") mode_of_payments = get_mode_of_payments([inv.name for inv in invoice_list]) @@ -38,7 +36,6 @@ def _execute(filters, additional_table_columns=None, additional_query_columns=No cost_center = list(set(invoice_cc_wh_map.get(inv.name, {}).get("cost_center", []))) warehouse = list(set(invoice_cc_wh_map.get(inv.name, {}).get("warehouse", []))) - customer_details = customer_map.get(inv.customer, {}) row = [ inv.name, inv.posting_date, inv.customer, inv.customer_name ] @@ -48,8 +45,8 @@ def _execute(filters, additional_table_columns=None, additional_query_columns=No row.append(inv.get(col)) row +=[ - customer_details.get("customer_group"), - customer_details.get("territory"), + inv.get("customer_group"), + inv.get("territory"), inv.debit_to, ", ".join(mode_of_payments.get(inv.name, [])), inv.project, inv.owner, inv.remarks, ", ".join(sales_order), ", ".join(delivery_note),", ".join(cost_center), @@ -162,7 +159,9 @@ def get_invoices(filters, additional_query_columns): additional_query_columns = ', ' + ', '.join(additional_query_columns) conditions = get_conditions(filters) - return frappe.db.sql("""select name, posting_date, debit_to, project, customer, customer_name, owner, remarks, + return frappe.db.sql(""" + select name, posting_date, debit_to, project, customer, + customer_name, owner, remarks, territory, customer_group, base_net_total, base_grand_total, base_rounded_total, outstanding_amount {0} from `tabSales Invoice` where docstatus = 1 %s order by posting_date desc, name desc""".format(additional_query_columns or '') % @@ -241,15 +240,6 @@ def get_invoice_cc_wh_map(invoice_list): return invoice_cc_wh_map -def get_customer_details(customers): - customer_map = {} - for cust in frappe.db.sql("""select name, territory, customer_group from `tabCustomer` - where name in (%s)""" % ", ".join(["%s"]*len(customers)), tuple(customers), as_dict=1): - customer_map.setdefault(cust.name, cust) - - return customer_map - - def get_mode_of_payments(invoice_list): mode_of_payments = {} if invoice_list: From 1e4cfb4bf5ae0575dcae51fe36432c5fd5771585 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 15 Mar 2018 12:27:24 +0530 Subject: [PATCH 2/3] Fixes in setting po nos manually in sales invoice --- erpnext/controllers/selling_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index ad32ab5958..606cc90866 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -332,7 +332,7 @@ class SellingController(StockController): def set_po_nos(self): if self.doctype in ("Delivery Note", "Sales Invoice"): ref_fieldname = "against_sales_order" if self.doctype == "Delivery Note" else "sales_order" - sales_orders = list(set([d.get(ref_fieldname) for d in self.items])) + sales_orders = list(set([d.get(ref_fieldname) for d in self.items if d.get(ref_fieldname)])) if sales_orders: po_nos = frappe.get_all('Sales Order', 'po_no', filters = {'name': ('in', sales_orders)}) self.po_no = ', '.join(list(set([d.po_no for d in po_nos if d.po_no]))) From 60200eaf0dc7711390f2054b38e8eba641955298 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 15 Mar 2018 13:08:41 +0600 Subject: [PATCH 3/3] bumped to version 10.1.13 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index ee72dfd62b..416aaf4454 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '10.1.12' +__version__ = '10.1.13' def get_default_company(user=None): '''Get default company for user'''