Merge lp:~camptocamp/margin-analysis/7.0-fix_1280221-afe into lp:~margin-analysis-core-editors/margin-analysis/7.0

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Merged at revision: 58
Proposed branch: lp:~camptocamp/margin-analysis/7.0-fix_1280221-afe
Merge into: lp:~margin-analysis-core-editors/margin-analysis/7.0
Diff against target: 46 lines (+20/-0)
3 files modified
product_cost_incl_bom/__openerp__.py (+1/-0)
product_cost_incl_bom/product_cost_incl_bom.py (+3/-0)
product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml (+16/-0)
To merge this branch: bzr merge lp:~camptocamp/margin-analysis/7.0-fix_1280221-afe
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review, no tests Approve
Pedro Manuel Baeza Approve
Review via email: mp+206486@code.launchpad.net

Description of the change

fixes the crash by not calling _bom_explode in the case that will cause an infinite recursion

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM, but I wonder if there is any possibility to test the infinite recursion itself, because for now, if we have a future regression, test will enter also in an infinite loop.

Don't you think it's better to propose a patch for _bom_explode that avoid infinite recursion? Or is it a specific problem of this module?

Regards.

review: Needs Information (code review)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Hello Pedro,

Thanks for looking into this.

I wrote the fix in this way to avoid going through the hassle of a fix in openobject-addons. I just reported a bug about this (lp:1281054).

58. By Alexandre Fayolle - camptocamp

product_cost_incl_bom: add comment about the bug we are working around here

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Great, Alexandre, thank you very much!

Regards.

review: Approve
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM thanks

review: Approve (code review, no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product_cost_incl_bom/__openerp__.py'
2--- product_cost_incl_bom/__openerp__.py 2013-12-11 13:27:22 +0000
3+++ product_cost_incl_bom/__openerp__.py 2014-02-17 10:46:27 +0000
4@@ -72,6 +72,7 @@
5 'test': [
6 'test/cost_price_update.yml',
7 'test/cost_price_update_by_bom.yml',
8+ 'test/cost_price_empty_phantom_bom.yml',
9 ],
10 'installable': True,
11 'auto_install': False,
12
13=== modified file 'product_cost_incl_bom/product_cost_incl_bom.py'
14--- product_cost_incl_bom/product_cost_incl_bom.py 2013-12-12 11:26:17 +0000
15+++ product_cost_incl_bom/product_cost_incl_bom.py 2014-02-17 10:46:27 +0000
16@@ -147,6 +147,9 @@
17 if not bom_id: # no BoM: use standard_price
18 continue
19 bom = bom_obj.browse(cr, uid, bom_id, context=context)
20+ if bom.type == 'phantom' and not bom.bom_lines:
21+ continue # work around lp:1281054 calling _bom_explode in that
22+ # case will cause an infinite recursion
23 subproducts, routes = bom_obj._bom_explode(cr, uid, bom,
24 factor=1,
25 properties=bom_properties,
26
27=== added file 'product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml'
28--- product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml 1970-01-01 00:00:00 +0000
29+++ product_cost_incl_bom/test/cost_price_empty_phantom_bom.yml 2014-02-17 10:46:27 +0000
30@@ -0,0 +1,16 @@
31+-
32+ I create a phantom BOM without lines for product_34
33+-
34+ !record {model: mrp.bom, id: mrp_bom_product_34}:
35+ company_id: base.main_company
36+ name: product 4
37+ product_id: product.product_product_34
38+ product_qty: 1.0
39+ type: phantom
40+-
41+ Test the prices of product_34 are updated correctly
42+-
43+ !python {model: product.product}: |
44+ product = self.browse(cr, uid, ref('product.product_product_34'))
45+ assert product.standard_price == 38, "02 The standard_price has not been recorded correctly %s" % product.standard_price
46+ assert product.cost_price == 38.0, "02 The cost_price has not been recorded correctly %s" % product.cost_price

Subscribers

People subscribed via source and target branches