Alexandre Fayolle - camptocamp has proposed merging 
lp:~camptocamp/margin-analysis/7.0-fix_1296778-afe into lp:margin-analysis.

Requested reviews:
  Margin Analysis Core Editors (margin-analysis-core-editors)
Related bugs:
  Bug #1296778 in Financial controlling and costing: "product_price_history: 
crash when installing on empty db"
  https://bugs.launchpad.net/margin-analysis/+bug/1296778

For more details, see:
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-fix_1296778-afe/+merge/212467

fix a crash which happens when an invoice line has no linked product
-- 
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-fix_1296778-afe/+merge/212467
Your team Margin Analysis Core Editors is requested to review the proposed 
merge of lp:~camptocamp/margin-analysis/7.0-fix_1296778-afe into 
lp:margin-analysis.
=== modified file 'product_historical_margin/invoice.py'
--- product_historical_margin/invoice.py	2013-11-29 15:38:55 +0000
+++ product_historical_margin/invoice.py	2014-03-24 15:49:58 +0000
@@ -30,7 +30,7 @@
     def _refund_cleanup_lines(self, cr, uid, lines, context=None):
         for line in lines:
             line.invoice_user_id = False
-        return super(account_invoice, self)._refund_cleanup_lines(cr, uid, 
+        return super(account_invoice, self)._refund_cleanup_lines(cr, uid,
           lines, context=context)
 
 
@@ -65,7 +65,7 @@
         res = {}
         if not ids:
             return res
-        
+
         if context is None:
             context = {}
         ctx = context.copy()
@@ -73,7 +73,7 @@
         currency_obj = self.pool.get('res.currency')
         product_obj = self.pool.get('product.product')
         company_obj = self.pool.get('res.company')
-       
+
         fields = [
                 'subtotal_cost_price_company',
                 'subtotal_cost_price',
@@ -83,10 +83,13 @@
                 ]
         for line_id in ids:
             res[line_id] = dict.fromkeys(fields, 0.0)
+
         for obj in self.browse(cr, uid, ids, context=context):
             # The company must be the one of the invoice in case a ir.cron create the invoice
             # with admin user. We need to pass it in the context as well
             # if we use also product_price_history with this module
+            if not obj.product_id:
+                continue
             if obj.company_id:
                 company = obj.company_id
             else:
@@ -225,9 +228,9 @@
 
         }
 
-    def read_group(self, cr, uid, domain, fields, groupby, 
+    def read_group(self, cr, uid, domain, fields, groupby,
             offset=0, limit=None, context=None, orderby=False):
-        """The percentage of the relative margin has to be recomputed asit is nor 
+        """The percentage of the relative margin has to be recomputed asit is nor
         a sum, nor a avg, but a percentage of 2 valuesof the line computed as:
         margin_relative = margin_absolute / subtotal_company * 100"""
         if not context:

-- 
Mailing list: https://launchpad.net/~openerp-community-reviewer
Post to     : openerp-community-reviewer@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-community-reviewer
More help   : https://help.launchpad.net/ListHelp

Reply via email to