From a2e2d4bd19953f0a7bd1841b0d65b5e7eee91981 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 12 Jun 2013 17:44:10 +0530 Subject: [PATCH] [price list] [fix] fix in buying selling price list patch --- patches/june_2013/p03_buying_selling_for_price_list.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py index a41bda1ce8f..089f0be5598 100644 --- a/patches/june_2013/p03_buying_selling_for_price_list.py +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -2,6 +2,9 @@ import webnotes from webnotes.utils import cint def execute(): + webnotes.reload_doc("setup", "doctype", "price_list") + webnotes.reload_doc("stock", "doctype", "item_price") + for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): buying, selling = False, False for b, s in webnotes.conn.sql("""select distinct buying, selling @@ -9,6 +12,7 @@ def execute(): buying = buying or cint(b) selling = selling or cint(s) - webnotes.conn.set_value("Price List", price_list, "buying_or_selling", ("Selling" if selling else "Buying")) - webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s where price_list_name=%s""", - (("Selling" if selling else "Buying"), price_list)) + buying_or_selling = "Selling" if selling else "Buying" + webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s + where price_list_name=%s""", (buying_or_selling, price_list))