From 8354496c6dfd84bc1cff77260f24079760170ac5 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Wed, 25 Nov 2009 16:04:50 +0530 Subject: [PATCH] [FIX]:fix string problem bzr revid: nch@tinyerp.com-20091125103450-gla544qdr273udgy --- addons/product_margin/product_margin.py | 16 ++++++++-------- addons/stock/product.py | 4 ++-- addons/stock/report/product_stock.py | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/product_margin/product_margin.py b/addons/product_margin/product_margin.py index 9d948fc09d0..51933fd6cdd 100644 --- a/addons/product_margin/product_margin.py +++ b/addons/product_margin/product_margin.py @@ -41,19 +41,19 @@ class product_product(osv.osv): res[val.id]['date_to']=date_to if 'invoice_state' in field_names: res[val.id]['invoice_state']=invoice_state - invoice_types=[] - states=[] + invoice_types=() + states=() if invoice_state=='paid': - states=['paid'] + states=('paid') elif invoice_state=='open_paid': - states=['open','paid'] + states=('open','paid') elif invoice_state=='draft_open_paid': - states=['draft','open','paid'] + states=('draft','open','paid') if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: - invoice_types=['out_invoice','in_refund'] + invoice_types=('out_invoice','in_refund') if 'purchase_avg_price' in field_names or 'purchase_num_invoiced' in field_names or 'total_cost' in field_names or 'normal_cost' in field_names: - invoice_types=['in_invoice','out_refund'] + invoice_types=('in_invoice','out_refund') if len(invoice_types): cr.execute("""select avg(l.price_unit) as avg_unit_price, @@ -64,7 +64,7 @@ class product_product(osv.osv): from account_invoice_line l left join account_invoice i on (l.invoice_id = i.id) left join product_template product on (product.id=l.product_id) - where l.product_id = %s and i.state =ANY(%s) and i.type =ANY(%s) and i.date_invoice>=%s and i.date_invoice<=%s + where l.product_id = %s and i.state in %s and i.type in %s and i.date_invoice>=%s and i.date_invoice<=%s """,(val.id,states,invoice_types,date_from,date_to)) result=cr.fetchall()[0] if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: diff --git a/addons/stock/product.py b/addons/stock/product.py index def19749503..1724b8bc86e 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -101,7 +101,7 @@ class product_product(osv.osv): 'and location_dest_id =ANY(%s)'\ 'and product_id =ANY(%s)'\ 'and state in %s' + (date_str and 'and '+date_str+' ' or '') +''\ - 'group by product_id,product_uom',(location_ids,location_ids,ids,states,) + 'group by product_id,product_uom',(location_ids,location_ids,ids,tuple(states),) ) results = cr.fetchall() if 'out' in what: @@ -113,7 +113,7 @@ class product_product(osv.osv): 'and location_dest_id <> ANY(%s) '\ 'and product_id =ANY(%s)'\ 'and state in %s' + (date_str and 'and '+date_str+' ' or '') + ''\ - 'group by product_id,product_uom',(location_ids,location_ids,ids,states,) + 'group by product_id,product_uom',(location_ids,location_ids,ids,tuple(states),) ) results2 = cr.fetchall() uom_obj = self.pool.get('product.uom') diff --git a/addons/stock/report/product_stock.py b/addons/stock/report/product_stock.py index 19742c86786..615b65e5e35 100644 --- a/addons/stock/report/product_stock.py +++ b/addons/stock/report/product_stock.py @@ -68,10 +68,10 @@ class report_stock(report_int): cr.execute("select sum(r.product_qty * u.factor), r.date_planned, r.product_id " "from stock_move r left join product_uom u on (r.product_uom=u.id) " - "where state =ANY(%s)" + "where state in %s" "and location_id=ANY(%s)" "and product_id=ANY(%s)" - "group by date_planned,product_id",(['confirmed','assigned','waiting'],loc_ids ,product_ids,)) + "group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,)) for (qty, dt, prod_id) in cr.fetchall(): if dt<=dt_from: dt= (DateTime.now() + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d') @@ -82,10 +82,10 @@ class report_stock(report_int): cr.execute("select sum(r.product_qty * u.factor), r.date_planned, r.product_id " "from stock_move r left join product_uom u on (r.product_uom=u.id) " - "where state=ANY(%s)" + "where state in %s" "and location_dest_id=ANY(%s)" "and product_id=ANY(%s)" - "group by date_planned,product_id",(['confirmed','assigned','waiting'],loc_ids ,product_ids,)) + "group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,)) for (qty, dt, prod_id) in cr.fetchall(): if dt<=dt_from: