From 967b12f89f806186cbdd8d4b6f8a7df52dac28c7 Mon Sep 17 00:00:00 2001 From: "SME,VRA" <> Date: Thu, 16 Jul 2009 15:44:17 +0530 Subject: [PATCH] [FIX] Product : Pricelist report corrected bzr revid: jvo@tinyerp.com-20090716101417-92ke0zddxj02sux9 --- addons/product/report/product_pricelist.py | 38 ++- addons/product/report/product_pricelist.rml | 324 ++++++++++---------- 2 files changed, 191 insertions(+), 171 deletions(-) diff --git a/addons/product/report/product_pricelist.py b/addons/product/report/product_pricelist.py index 9387a7cb33d..69b95d1ac8f 100644 --- a/addons/product/report/product_pricelist.py +++ b/addons/product/report/product_pricelist.py @@ -36,13 +36,28 @@ class product_pricelist(report_sxw.rml_parse): 'get_currency': self._get_currency, 'get_categories': self._get_categories, 'get_price': self._get_price, + 'get_titles': self._get_titles, }) + def _get_titles(self,form): + lst = [] + vals = {} + qtys = 1 + + for i in range(1,6): + if form['qty'+str(i)] >= 0 and form['qty'+str(i)] not in vals.values(): + vals['qty'+str(qtys)] = form['qty'+str(i)] + qtys += 1 + lst.append(vals) + return lst + def _set_quantity(self,form): for i in range(1,6): q = 'qty%d'%i - if form[q]: + if form[q] >=0 and form[q] not in self.quantity: self.quantity.append(form[q]) +# else: +# self.quantity.append(0) return True def _get_pricelist(self, pricelist_id): @@ -66,22 +81,25 @@ class product_pricelist(report_sxw.rml_parse): pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) - cats=pool.get('product.category').browse(self.cr,self.uid,cat_ids) + cats = pool.get('product.category').read(self.cr,self.uid,cat_ids,['name']) for cat in cats: - product_ids=pool.get('product.product').search(self.cr,self.uid,[('id','in',pro_ids),('categ_id','=',cat.id)]) + product_ids=pool.get('product.product').search(self.cr,self.uid,[('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] - for product in pool.get('product.product').browse(self.cr,self.uid,product_ids): + for product in pool.get('product.product').read(self.cr,self.uid,product_ids,['name','code']): val={ - 'id':product.id, - 'name':product.name, - 'code':product.code + 'id':product['id'], + 'name':product['name'], + 'code':product['code'] } i = 1 for qty in self.quantity: - val['qty'+str(i)]=self._get_price(self.pricelist,product.id,qty) - i += 1 + if qty == 0: + val['qty'+str(i)] = "" + else: + val['qty'+str(i)]=self._get_price(self.pricelist,product['id'],qty) + i += 1 products.append(val) - res.append({'name':cat.name,'products':products}) + res.append({'name':cat['name'],'products':products}) return res def _get_price(self,pricelist_id, product_id,qty): diff --git a/addons/product/report/product_pricelist.rml b/addons/product/report/product_pricelist.rml index 7bf31a4fb05..7ce4ca4e19d 100644 --- a/addons/product/report/product_pricelist.rml +++ b/addons/product/report/product_pricelist.rml @@ -2,7 +2,7 @@ @@ -13,220 +13,222 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - Products Price List - - - - - - - - - - - - - Price List Name: - - - [[ get_pricelist(data['form']['price_list']) ]] - - - - - Currency : - - - [[ get_currency ( data['form']['price_list']) ]] - - - - - Printing Date : - - - [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] + Products Price List - + - + - Description + Price List Name: - [[str( data['form']['qty1']) ]] units + [[ get_pricelist(data['form']['price_list']) ]] + + + + + Currency : - [[ str(data['form']['qty2'] )]] units + [[ get_currency ( data['form']['price_list']) ]] + + + + + Printing Date : - [[ str(data['form']['qty3']) ]] units + [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] + + + + + + + + + + + + + Description + [[repeatIn(get_titles(data['form']), 'k')]] - [[ str(data['form']['qty4']) ]] units + [[ k['qty1'] or removeParentNode('font') ]] units - [[ str(data['form']['qty5'] ) ]] units + [[ k['qty2'] or removeParentNode('font') ]] units + + + [[ k['qty3'] or removeParentNode('font') ]] units + + + [[ k['qty4'] or removeParentNode('font') ]] units + + + [[ k['qty5'] or removeParentNode('font') ]] units
- - [[repeatIn(get_categories(objects,data['form']), 'c')]][[ c['name'] ]] - + [[repeatIn(get_categories(objects,data['form']), 'c')]] + - [[repeatIn(c['products'], 'p')]][[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]] + [[ c['name'] ]] - [[p['qty1'] ]] - - - [[ p['qty2'] ]] - - - [[ p['qty3'] ]] - - - [[ p['qty4'] ]] - - - [[ p['qty5'] ]] + + + - + + + + +
+ [[repeatIn(c['products'], 'p')]] + + + + [[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]] + + + [[ p['qty1'] or removeParentNode('font') ]] + + + [[ p['qty2'] or removeParentNode('font') ]] + + + [[ p['qty3'] or removeParentNode('font') ]] + + + [[ p['qty4'] or removeParentNode('font') ]] + + + [[ p['qty5'] or removeParentNode('font') ]] + + + + + + +
+ + +
- - - -
-
- + \ No newline at end of file