From 6976b690bb81d08ee92c7a1ca72e6bb1cdfe5c08 Mon Sep 17 00:00:00 2001 From: "olt@tinyerp.com" <> Date: Fri, 1 Oct 2010 14:00:56 +0200 Subject: [PATCH] [IMP] sale_layout: pep8 on report bzr revid: olt@tinyerp.com-20101001120056-q4np9gq4io7kien2 --- .../sale_layout/report/report_sale_layout.py | 169 +++++++++--------- 1 file changed, 83 insertions(+), 86 deletions(-) diff --git a/addons/sale_layout/report/report_sale_layout.py b/addons/sale_layout/report/report_sale_layout.py index 20ad66313a2..78c07f97046 100755 --- a/addons/sale_layout/report/report_sale_layout.py +++ b/addons/sale_layout/report/report_sale_layout.py @@ -1,5 +1,5 @@ ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -14,21 +14,22 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## import time -import pooler from report import report_sxw rml_parents = { - 'tr':1, - 'li':1, + 'tr': 1, + 'li': 1, 'story': 0, 'section': 0 } + + class sale_order_1(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(sale_order_1, self).__init__(cr, uid, name, context) @@ -39,98 +40,94 @@ class sale_order_1(report_sxw.rml_parse): }) self.context = context -# + def sale_order_lines(self, sale_order): + result = [] + sub_total = {} + info = [] + order_lines = [] + res = {} - def sale_order_lines(self,sale_order): - result =[] - sub_total={} - info=[] - order_lines=[] - res={} - list_in_seq=[] ids = self.pool.get('sale.order.line').search(self.cr, self.uid, [('order_id', '=', sale_order.id)]) - for id in range(0,len(ids)): - order = self.pool.get('sale.order.line').browse(self.cr, self.uid,ids[id], self.context.copy()) + for id in range(0, len(ids)): + order = self.pool.get('sale.order.line').browse(self.cr, self.uid, ids[id], self.context.copy()) order_lines.append(order) - - i=1 - j=0 - sum_flag={} - sum_flag[j]=-1 + + i = 1 + j = 0 + sum_flag = {} + sum_flag[j] = -1 for entry in order_lines: - res={} + res = {} - if entry.layout_type=='article': - res['tax_id']=', '.join(map(lambda x: x.name, entry.tax_id)) or '' - res['name']=entry.name - res['product_uom_qty']="%.2f"%(entry.product_uos and entry.product_uos_qty or entry.product_uom_qty or 0.00) - res['product_uom']=entry.product_uos and entry.product_uos.name or entry.product_uom.name - res['price_unit']="%.2f"%(entry.price_unit or 0.00) - res['discount']="%.2f"%(entry.discount and entry.discount or 0.00) - res['price_subtotal']="%.2f"%(entry.price_subtotal and entry.price_subtotal or 0.00) - sub_total[i]= entry.price_subtotal and entry.price_subtotal - i=i+1 - res['note']=entry.notes or '' - res['currency']=sale_order.pricelist_id.currency_id.name - res['layout_type']=entry.layout_type - + if entry.layout_type == 'article': + res['tax_id'] = ', '.join(map(lambda x: x.name, entry.tax_id)) or '' + res['name'] = entry.name + res['product_uom_qty'] = self.digits_fmt(entry, 'product_uos') % (entry.product_uos and entry.product_uos_qty or entry.product_uom_qty or 0.00) + res['product_uom'] = entry.product_uos and entry.product_uos.name or entry.product_uom.name + res['price_unit'] = self.digits_fmt(entry, 'price_unit') % (entry.price_unit or 0.00) + res['discount'] = self.digits_fmt(entry, 'discount') % (entry.discount and entry.discount or 0.00) + res['price_subtotal'] = self.digits_fmt(entry, 'price_subtotal') % (entry.price_subtotal and entry.price_subtotal or 0.00) + sub_total[i] = entry.price_subtotal and entry.price_subtotal + i = i + 1 + res['note'] = entry.notes or '' + res['currency'] = sale_order.pricelist_id.currency_id.name + res['layout_type'] = entry.layout_type else: + res['product_uom_qty'] = '' + res['price_unit'] = '' + res['discount'] = '' + res['tax_id'] = '' + res['layout_type'] = entry.layout_type + res['note'] = entry.notes or '' + res['product_uom'] = '' - res['product_uom_qty']='' - res['price_unit']='' - res['discount']='' - res['tax_id']='' - res['layout_type']=entry.layout_type - res['note']=entry.notes or '' - res['product_uom']='' - - if entry.layout_type=='subtotal': - res['name']=entry.name - sum=0 - sum_id=0 - if sum_flag[j]==-1: - temp=1 + if entry.layout_type == 'subtotal': + res['name'] = entry.name + sum = 0 + sum_id = 0 + if sum_flag[j] == -1: + temp = 1 else: - temp=sum_flag[j] + temp = sum_flag[j] - for sum_id in range(temp,len(sub_total)+1): - sum+=sub_total[sum_id] - sum_flag[j+1]= sum_id +1 + for sum_id in range(temp, len(sub_total)+1): + sum += sub_total[sum_id] + sum_flag[j+1] = sum_id +1 - j=j+1 - res['price_subtotal']="%.2f"%(sum) - res['currency']=sale_order.pricelist_id.currency_id.name - res['quantity']='' - res['price_unit']='' - res['discount']='' - res['tax_id']='' - res['product_uom']='' - elif entry.layout_type=='title': - res['name']=entry.name - res['price_subtotal']='' - res['currency']='' - elif entry.layout_type=='text': - res['name']=entry.name - res['price_subtotal']='' - res['currency']='' - elif entry.layout_type=='line': - res['product_uom_qty']='__________' - res['price_unit']='______________' - res['discount']='___________' - res['tax_id']='_________________' - res['product_uom']='_____' - res['name']='_______________________________________' - res['price_subtotal']='_________' - res['currency']='_______' - elif entry.layout_type=='break': - res['layout_type']=entry.layout_type - res['name']=entry.name - res['price_subtotal']='' - res['currency']='' + j = j + 1 + res['price_subtotal'] = self.digits_fmt(entry, 'price_subtotal') % (sum) + res['currency'] = sale_order.pricelist_id.currency_id.name + res['quantity'] = '' + res['price_unit'] = '' + res['discount'] = '' + res['tax_id'] = '' + res['product_uom'] = '' + elif entry.layout_type == 'title': + res['name'] = entry.name + res['price_subtotal'] = '' + res['currency'] = '' + elif entry.layout_type == 'text': + res['name'] = entry.name + res['price_subtotal'] = '' + res['currency'] = '' + elif entry.layout_type == 'line': + res['product_uom_qty'] = '__________' + res['price_unit'] = '______________' + res['discount'] = '___________' + res['tax_id'] = '_________________' + res['product_uom'] = '_____' + res['name'] = '_______________________________________' + res['price_subtotal'] = '_________' + res['currency'] = '_______' + elif entry.layout_type == 'break': + res['layout_type'] = entry.layout_type + res['name'] = entry.name + res['price_subtotal'] = '' + res['currency'] = '' else: - res['name']=entry.name - res['price_subtotal']='' - res['currency']=sale_order.pricelist_id.currency_id.name + res['name'] = entry.name + res['price_subtotal'] = '' + res['currency'] = sale_order.pricelist_id.currency_id.name result.append(res) return result