From 7663bb91c501c006583b74f10cd9921d1bc6f0c9 Mon Sep 17 00:00:00 2001 From: neckos Date: Wed, 23 May 2018 17:15:34 +0300 Subject: [PATCH] return list(filter()) not filter() (#14191) filter constructs an iterator that is iterable only once --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 242f42d1da..6c2ae7ab75 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -305,8 +305,8 @@ def filter_pricing_rules(args, pricing_rules): if pricing_rules: stock_qty = flt(args.get('qty')) * args.get('conversion_factor', 1) - pricing_rules = filter(lambda x: (flt(stock_qty)>=flt(x.min_qty) - and (flt(stock_qty)<=x.max_qty if x.max_qty else True)), pricing_rules) + pricing_rules = list(filter(lambda x: (flt(stock_qty)>=flt(x.min_qty) + and (flt(stock_qty)<=x.max_qty if x.max_qty else True)), pricing_rules)) # add variant_of property in pricing rule for p in pricing_rules: @@ -319,7 +319,7 @@ def filter_pricing_rules(args, pricing_rules): if pricing_rules: max_priority = max([cint(p.priority) for p in pricing_rules]) if max_priority: - pricing_rules = filter(lambda x: cint(x.priority)==max_priority, pricing_rules) + pricing_rules = list(filter(lambda x: cint(x.priority)==max_priority, pricing_rules)) # apply internal priority all_fields = ["item_code", "item_group", "brand", "customer", "customer_group", "territory",