From 6f7a4d94cefb2458c4ec973e35d13d93510c0b0f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 14 Feb 2019 19:34:43 +0530 Subject: [PATCH 1/2] fix: Consider parenttype while updating total qty in transactions --- erpnext/patches/v11_0/update_total_qty_field.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v11_0/update_total_qty_field.py b/erpnext/patches/v11_0/update_total_qty_field.py index fcb76af459..cc8524f3c2 100644 --- a/erpnext/patches/v11_0/update_total_qty_field.py +++ b/erpnext/patches/v11_0/update_total_qty_field.py @@ -19,9 +19,10 @@ def execute(): SELECT parent, SUM(qty) as qty FROM - `tab%s Item` + `tab{0} Item` + where parenttype = %s GROUP BY parent - ''' % (doctype), as_dict = True) + '''.format(doctype), doctype, as_dict = True) # Query to update total_qty might become too big, Update in batches # batch_size is chosen arbitrarily, Don't try too hard to reason about it From a0c9c7501b7aa378cf1001b1bc1c41f61db8bbd9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 15 Feb 2019 14:24:08 +0530 Subject: [PATCH 2/2] Update update_total_qty_field.py --- erpnext/patches/v11_0/update_total_qty_field.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v11_0/update_total_qty_field.py b/erpnext/patches/v11_0/update_total_qty_field.py index cc8524f3c2..992454ac7c 100644 --- a/erpnext/patches/v11_0/update_total_qty_field.py +++ b/erpnext/patches/v11_0/update_total_qty_field.py @@ -20,9 +20,9 @@ def execute(): parent, SUM(qty) as qty FROM `tab{0} Item` - where parenttype = %s + where parenttype = '{0}' GROUP BY parent - '''.format(doctype), doctype, as_dict = True) + '''.format(doctype), as_dict = True) # Query to update total_qty might become too big, Update in batches # batch_size is chosen arbitrarily, Don't try too hard to reason about it