Merge lp:~openerp-dev/openobject-addons/6.1-opw-575875-rha into lp:openobject-addons/6.1

Proposed by Rifakat Husen (OpenERP)
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: no longer in the source branch.
Merged at revision: 7144
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-575875-rha
Merge into: lp:openobject-addons/6.1
Diff against target: 53 lines (+32/-0)
2 files modified
stock/product.py (+2/-0)
stock/test/opening_stock.yml (+30/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-575875-rha
Reviewer Review Type Date Requested Status
Numérigraphe (community) Approve
Olivier Dony (Odoo) Needs Fixing
Review via email: mp+110601@code.launchpad.net

Description of the change

Hello,

When filling the inventory line with product and does not provide production lot then totol qty
should return qty withouht production lot(prodlot_id==Null) but currently it does not distinguish
and retund all qty with and without lot. It leads to wrong creation of stock moves.

Also I have put check on inventory line for production lot, when product's incoming tracking is
required so one must have to provide production lot in inventory line.

One should have general practice to fill the inventory lines using 'Fill Inventory' wizard in
order to avoid problem for stock.

Please review this fix.

Regards,
Rifakat

To post a comment you must log in.
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Since this bug was a bit hard to illustrate and explain, can you please add an automatic test for this fix, so we make sure it does not come back as a regression later on?

review: Needs Fixing (automatic test)
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Your revision 6842 is dubious: that's quite a functional change, and I don't think it's consistent with the button on the product form that lets quickly enter a new quantity.

review: Needs Fixing (functional)
Revision history for this message
Numérigraphe (numerigraphe) :
review: Disapprove
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

On a functional aspect this change looks fine to me. I double-checked our addons and there is no place where we put prodlot_id: False value in the context for get_product_available's, except here. Therefore we can safely introduce this new semantics: if prodlot_id is False in context, it means we're explicitly looking for products that have *no* production lot. When we mean to count all products regardless of their production lot, the key should be omitted instead.

I also agree with Lionel's remarks:
1. We could really use an extra test to cover this fix. It should be as simple as adding 1-2 extra steps at the end of stock/test/opening_stock.yml to perform an extra product qty change with Ice Cream and prod_lot_id = False. The result before and after the fix should be different, so you can assert that the final stock quantity for Ice Cream is correct.
2. I don't think the change on l.32-34 is needed, appropriate exceptions will be triggered when confirming the stock moves anyway, if the production lot tracking conditions are not met, so this change is unnecessary.

Now one small technical remark on the patch:
- l.9 and 19: the code is becoming quite unreadable due to this overlong inline condition. Please make it a separate variable (e.g. prodlot_condition) that is computed above the call to cr.execute() and inserted in the query string. In fact you need to update your code with the latest 6.1 changes, as the code was refactored a little bit.

Thanks!

review: Needs Fixing
Revision history for this message
Numérigraphe (numerigraphe) wrote :

That looks fine, thanks a lot.
Lionel

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/product.py'
2--- stock/product.py 2012-06-19 07:40:07 +0000
3+++ stock/product.py 2012-10-22 09:39:22 +0000
4@@ -256,6 +256,8 @@
5 if prodlot_id:
6 prodlot_clause = ' and prodlot_id = %s '
7 where += [prodlot_id]
8+ elif 'prodlot_id' in context and not prodlot_id:
9+ prodlot_clause = 'and prodlot_id is null '
10
11 # TODO: perhaps merge in one query.
12 if 'in' in what:
13
14=== modified file 'stock/test/opening_stock.yml'
15--- stock/test/opening_stock.yml 2011-12-23 11:06:43 +0000
16+++ stock/test/opening_stock.yml 2012-10-22 09:39:22 +0000
17@@ -33,6 +33,36 @@
18 product = self.browse(cr, uid, ref('product_icecream'), context=context)
19 assert product.qty_available == 10, "Stock is not updated."
20 -
21+ I update the current stock of the Ice-cream with 10 kgm in Small Refrigerator without Production Lot.
22+-
23+ !record {model: stock.change.product.qty, id: change_qty_nolot}:
24+ location_id: location_refrigerator_small
25+ new_quantity: 10
26+ product_id: product_icecream
27+-
28+ !python {model: stock.change.product.qty}: |
29+ self.change_product_qty(cr, uid, [ref('change_qty_nolot')], context=context)
30+-
31+ I check available stock of Ice-cream after update stock.
32+-
33+ !python {model: product.product}: |
34+ product = self.browse(cr, uid, ref('product_icecream'), context=context)
35+ assert product.qty_available == 20, "Real stock is not updated."
36+-
37+ I revert 10kgm updated stock again with no production lot in order to level the stock
38+-
39+ !record {model: stock.change.product.qty, id: change_qty_nolot_1}:
40+ location_id: location_refrigerator_small
41+ new_quantity: 0
42+ product_id: product_icecream
43+-
44+ !python {model: stock.change.product.qty}: |
45+ self.change_product_qty(cr, uid, [ref('change_qty_nolot_1')], context=context)
46+-
47+ !python {model: product.product}: |
48+ product = self.browse(cr, uid, ref('product_icecream'), context=context)
49+ assert product.qty_available == 10, "Real stock is not updated."
50+-
51 I merge inventory.
52 -
53 !python {model: stock.inventory.merge }: |