← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/margin-analysis/7.0-fix_1280221-afe into lp:margin-analysis

 

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

Requested reviews:
  Margin Analysis Core Editors (margin-analysis-core-editors)
Related bugs:
  Bug #1280221 in Financial controlling and costing: "product_cost_incl_bom: infinite recursion when creating a phantom bom without lines for a product"
  https://bugs.launchpad.net/margin-analysis/+bug/1280221

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

fixes the crash by not calling _bom_explode in the case that will cause an infinite recursion
-- 
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-fix_1280221-afe/+merge/206486
Your team Margin Analysis Core Editors is requested to review the proposed merge of lp:~camptocamp/margin-analysis/7.0-fix_1280221-afe into lp:margin-analysis.
=== modified file 'product_cost_incl_bom/__openerp__.py'
--- product_cost_incl_bom/__openerp__.py	2013-12-11 13:27:22 +0000
+++ product_cost_incl_bom/__openerp__.py	2014-02-14 13:26:03 +0000
@@ -72,6 +72,7 @@
  'test': [
     'test/cost_price_update.yml',
     'test/cost_price_update_by_bom.yml',
+    'test/cost_price_empty_phantom_bom.yml',
  ],
  'installable': True,
  'auto_install': False,

=== modified file 'product_cost_incl_bom/product_cost_incl_bom.py'
--- product_cost_incl_bom/product_cost_incl_bom.py	2013-12-12 11:26:17 +0000
+++ product_cost_incl_bom/product_cost_incl_bom.py	2014-02-14 13:26:03 +0000
@@ -147,6 +147,8 @@
             if not bom_id:  # no BoM: use standard_price
                 continue
             bom = bom_obj.browse(cr, uid, bom_id, context=context)
+            if bom.type == 'phantom' and not bom.bom_lines:
+                continue
             subproducts, routes = bom_obj._bom_explode(cr, uid, bom,
                                                        factor=1,
                                                        properties=bom_properties,

=== added file 'product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml'
--- product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml	1970-01-01 00:00:00 +0000
+++ product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml	2014-02-14 13:26:03 +0000
@@ -0,0 +1,16 @@
+-
+  I create a phantom BOM without lines for product_34
+-
+  !record {model: mrp.bom, id: mrp_bom_product_34}:
+    company_id: base.main_company
+    name: product 4
+    product_id: product.product_product_34
+    product_qty: 1.0
+    type: phantom
+-
+  Test the prices of product_34 are updated correctly
+-
+  !python {model: product.product}: |
+    product = self.browse(cr, uid, ref('product.product_product_34'))
+    assert product.standard_price == 38, "02 The standard_price has not been recorded correctly %s" % product.standard_price
+    assert product.cost_price == 38.0, "02 The cost_price has not been recorded correctly %s"  % product.cost_price


Follow ups