From 3df2639a32e86524f79f13afb42f9bccc68fac5d Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Thu, 30 Aug 2018 17:24:03 +0530 Subject: [PATCH 1/3] Optimize patch (#15263) --- erpnext/patches/v10_0/set_discount_amount.py | 46 +++++--------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/erpnext/patches/v10_0/set_discount_amount.py b/erpnext/patches/v10_0/set_discount_amount.py index 019d245d45..eb8bb2d48f 100644 --- a/erpnext/patches/v10_0/set_discount_amount.py +++ b/erpnext/patches/v10_0/set_discount_amount.py @@ -15,42 +15,20 @@ def execute(): buying_doctypes = ["Purchase Order Item", "Purchase Invoice Item", "Purchase Receipt Item", "Supplier Quotation Item"] for doctype in selling_doctypes: - values = frappe.db.sql(''' - SELECT - discount_percentage, rate_with_margin, price_list_rate, name - FROM - `tab%s` - WHERE - ifnull(discount_percentage, 0) > 0 - ''' % (doctype), as_dict=True) - calculate_discount(doctype, values) - - for doctype in buying_doctypes: - values = frappe.db.sql(''' - SELECT - discount_percentage, price_list_rate, name - FROM - `tab%s` - WHERE - discount_percentage > 0 - ''' % (doctype), as_dict=True) - calculate_discount(doctype, values) - -def calculate_discount(doctype, values): - rate = None - if not values: return - for d in values: - if d.rate_with_margin and d.rate_with_margin > 0: - rate = d.rate_with_margin - else: - rate = d.price_list_rate - - discount_value = rate * d.get('discount_percentage') / 100 frappe.db.sql(''' UPDATE `tab%s` SET - discount_amount = %s + discount_amount = if(rate_with_margin > 0, rate_with_margin, price_list_rate) * discount_percentage / 100 WHERE - name = '%s' - ''' % (doctype, discount_value, d.get('name'))) + discount_percentage > 0 + ''' % (doctype)) + for doctype in buying_doctypes: + frappe.db.sql(''' + UPDATE + `tab%s` + SET + discount_amount = price_list_rate * discount_percentage / 100 + WHERE + discount_percentage > 0 + ''' % (doctype)) \ No newline at end of file From 624927bf0b60d8d170a6a495906fce807e9fa719 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 30 Aug 2018 19:19:14 +0530 Subject: [PATCH 2/3] [Fix] Not able to export the Supplier-Wise Sales Analytics report (#15271) --- .../supplier_wise_sales_analytics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.py b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.py index 78d1c44907..1d694293ce 100644 --- a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.py +++ b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.py @@ -33,7 +33,7 @@ def execute(filters=None): row = [cd.item_code, cd.item_name, cd.description, cd.stock_uom, \ consumed_qty, consumed_amount, delivered_qty, delivered_amount, \ - total_qty, total_amount, list(set(suppliers))] + total_qty, total_amount, ','.join(list(set(suppliers)))] data.append(row) return columns, data From 648191b9e8dc9f2d5e92e59c611a600ddb9281b1 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 31 Aug 2018 11:59:13 +0600 Subject: [PATCH 3/3] bumped to version 10.1.50 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index e04509fd95..e977b612cf 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.49' +__version__ = '10.1.50' def get_default_company(user=None): '''Get default company for user'''