Merge lp:~camptocamp/margin-analysis/7.0-fix-product_historical_margin-no-product-yvr into lp:~margin-analysis-core-editors/margin-analysis/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 61
Proposed branch: lp:~camptocamp/margin-analysis/7.0-fix-product_historical_margin-no-product-yvr
Merge into: lp:~margin-analysis-core-editors/margin-analysis/7.0
Diff against target: 16 lines (+2/-2)
1 file modified
product_historical_margin/invoice.py (+2/-2)
To merge this branch: bzr merge lp:~camptocamp/margin-analysis/7.0-fix-product_historical_margin-no-product-yvr
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Pedro Manuel Baeza code review Approve
Alexandre Fayolle - camptocamp code review, test Approve
Review via email: mp+211354@code.launchpad.net

Description of the change

Make sure we don't read a product of invoice line without product.

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

Why do you need to re-read product record? You can make:

product = obj.product_id

Or there is something I'm missing?

Regards.

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

Read operation is made with a specific context using company as a product can have a different cost_price with different company.

By the way I have to test if I should keep the second test as this context could implies there is no product for a company.

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

OK, I understand. Thanks for the explanation. I wait for your test then.

Regards.

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

LGTM

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

@Pedro I checked and found no way to have the read method gives a False or an empty list when giving a valid id to it.

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

OK, thanks for the investigation.

Regards.

review: Approve (code review)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product_historical_margin/invoice.py'
2--- product_historical_margin/invoice.py 2013-11-29 15:38:55 +0000
3+++ product_historical_margin/invoice.py 2014-03-17 16:13:09 +0000
4@@ -98,10 +98,10 @@
5 company = company_obj.browse(cr, uid, company_id, context=context)
6 company_currency_id = company.currency_id.id
7 ctx['company_id'] = company.id
8+ if not obj.product_id:
9+ continue
10 product = product_obj.read(cr, uid, obj.product_id.id,
11 ['id','cost_price'], context=ctx)
12- if not product:
13- continue
14 if obj.invoice_id.currency_id is None:
15 currency_id = company_currency_id
16 else:

Subscribers

People subscribed via source and target branches