[imp] product_margin: fix stray whitespace
authorXavier Morel <xmo@tinyerp.com>
Tue, 23 Feb 2010 13:26:49 +0000 (14:26 +0100)
committerXavier Morel <xmo@tinyerp.com>
Tue, 23 Feb 2010 13:26:49 +0000 (14:26 +0100)
bzr revid: xmo@tinyerp.com-20100223132649-mxoylhjl6a0g96s0

addons/product_margin/product_margin.py

index 776d17a..a63592d 100644 (file)
@@ -1,7 +1,7 @@
 # -*- encoding: utf-8 -*-
 ##############################################################################
 #
-#    OpenERP, Open Source Management Solution  
+#    OpenERP, Open Source Management Solution
 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 #    $Id$
 #
@@ -26,24 +26,24 @@ from tools import config
 import time
 
 class product_product(osv.osv):
-    _inherit = "product.product"     
-    
-    
+    _inherit = "product.product"
+
+
     def _product_margin(self, cr, uid, ids, field_names, arg, context):
-        res = {}               
+        res = {}
         for val in self.browse(cr, uid, ids,context=context):
             res[val.id] = {}
-            date_from=context.get('date_from', time.strftime('%Y-01-01'))      
-            date_to=context.get('date_to', time.strftime('%Y-12-31'))  
-            invoice_state=context.get('invoice_state', 'open_paid')    
+            date_from=context.get('date_from', time.strftime('%Y-01-01'))
+            date_to=context.get('date_to', time.strftime('%Y-12-31'))
+            invoice_state=context.get('invoice_state', 'open_paid')
             if 'date_from' in field_names:
-               res[val.id]['date_from']=date_from
+                res[val.id]['date_from']=date_from
             if 'date_to' in field_names:
                 res[val.id]['date_to']=date_to
             if 'invoice_state' in field_names:
-               res[val.id]['invoice_state']=invoice_state
+                res[val.id]['invoice_state']=invoice_state
+
 
-            
             invoice_types=[]
             states=[]
             if invoice_state=='paid':
@@ -52,26 +52,26 @@ class product_product(osv.osv):
                 states=['open','paid']
             elif invoice_state=='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']
             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']
             if len(invoice_types):
                 sql="""
-                select 
-                       avg(l.price_unit) as avg_unit_price,
-                       sum(l.quantity) as num_qty,
-                       sum(l.quantity * l.price_unit) as total,
-                       sum(l.quantity * product.list_price) as sale_expected,
-                       sum(l.quantity * product.standard_price) as normal_cost 
+                select
+                    avg(l.price_unit) as avg_unit_price,
+                    sum(l.quantity) as num_qty,
+                    sum(l.quantity * l.price_unit) as total,
+                    sum(l.quantity * product.list_price) as sale_expected,
+                    sum(l.quantity * product.standard_price) as normal_cost
                 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 in ('%s') and i.type in ('%s') and i.date_invoice>='%s' and i.date_invoice<='%s'           
-                """%(val.id,"','".join(states),"','".join(invoice_types),date_from,date_to)                
+                left join product_template product on (product.id=l.product_id)
+                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,"','".join(states),"','".join(invoice_types),date_from,date_to)
                 cr.execute(sql)
-                result=cr.fetchall()[0]                
+                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:
                     res[val.id]['sale_avg_price']=result[0] and result[0] or 0.0
                     res[val.id]['sale_num_invoiced']=result[1] and result[1] or 0.0
@@ -83,8 +83,8 @@ class product_product(osv.osv):
                     res[val.id]['purchase_num_invoiced']=result[1] and result[1] or 0.0
                     res[val.id]['total_cost']=result[2] and result[2] or 0.0
                     res[val.id]['normal_cost']=result[4] and result[4] or 0.0
-                    res[val.id]['purchase_gap']=res[val.id]['normal_cost']-res[val.id]['total_cost']                 
-            
+                    res[val.id]['purchase_gap']=res[val.id]['normal_cost']-res[val.id]['total_cost']
+
             if 'total_margin' in field_names:
                 res[val.id]['total_margin']=val.turnover-val.total_cost
             if 'expected_margin' in field_names:
@@ -92,15 +92,15 @@ class product_product(osv.osv):
             if 'total_margin_rate' in field_names:
                 res[val.id]['total_margin_rate']=val.turnover and val.total_margin * 100 / val.turnover or 0.0
             if 'expected_margin_rate' in field_names:
-                res[val.id]['expected_margin_rate']=val.sale_expected and val.expected_margin * 100 / val.sale_expected or 0.0 
+                res[val.id]['expected_margin_rate']=val.sale_expected and val.expected_margin * 100 / val.sale_expected or 0.0
         return res
-    
+
     _columns = {
         'date_from': fields.function(_product_margin, method=True, type='date', string='From Date', multi=True),
         'date_to': fields.function(_product_margin, method=True, type='date', string='To Date', multi=True),
         'invoice_state': fields.function(_product_margin, method=True, type='selection', selection=[
-                       ('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid')
-                       ], string='Invoice State',multi=True, readonly=True),        
+            ('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid')
+            ], string='Invoice State',multi=True, readonly=True),
         'sale_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='sale',help="Avg. Price in Customer Invoices)"),
         'purchase_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='purchase',help="Avg. Price in Supplier Invoices "),
         'sale_num_invoiced' : fields.function(_product_margin, method=True, type='float', string='# Invoiced', multi='sale',help="Sum of Quantity in Customer Invoices"),