Merge lp:~numerigraphe/openobject-addons/6.0-inventory-dummy-moves into lp:openobject-addons/6.0

Proposed by Numérigraphe
Status: Needs review
Proposed branch: lp:~numerigraphe/openobject-addons/6.0-inventory-dummy-moves
Merge into: lp:openobject-addons/6.0
Diff against target: 80 lines (+54/-0)
3 files modified
stock/__openerp__.py (+1/-0)
stock/test/stock_inventory_dummy_moves.yml (+51/-0)
stock/wizard/stock_fill_inventory.py (+2/-0)
To merge this branch: bzr merge lp:~numerigraphe/openobject-addons/6.0-inventory-dummy-moves
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+187045@code.launchpad.net

Description of the change

Fixes a corner-case bug when importing inventories

To post a comment you must log in.

Unmerged revisions

5494. By Lionel Sausin, Loïc Bellier

[FIX] Inventory fill wizard gives wrong results when there are stock moves having source = destination.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/__openerp__.py'
2--- stock/__openerp__.py 2011-01-14 00:11:01 +0000
3+++ stock/__openerp__.py 2013-09-23 15:27:09 +0000
4@@ -74,6 +74,7 @@
5 ],
6 'test': ['test/stock_test.yml',
7 'test/stock_report.yml',
8+ 'test/stock_inventory_dummy_moves.yml',
9 ],
10 'installable': True,
11 'active': False,
12
13=== added file 'stock/test/stock_inventory_dummy_moves.yml'
14--- stock/test/stock_inventory_dummy_moves.yml 1970-01-01 00:00:00 +0000
15+++ stock/test/stock_inventory_dummy_moves.yml 2013-09-23 15:27:09 +0000
16@@ -0,0 +1,51 @@
17+-
18+ This file test will verify the bug reported at https://bugs.launchpad.net/openobject-addons/+bug/1228156.
19+ In order, to test the bug fix, i will create stock move with same location for source and destination location,
20+ create inventory, import inventory lines
21+-
22+ I create stock move with same source and destination location for product_pc2.
23+-
24+ !record {model: stock.move, id: same_location_move}:
25+ name: 'Test move with same source and destination location'
26+ location_id: stock_location_14
27+ location_dest_id: stock_location_14
28+ product_id: product.product_product_pc2
29+ product_qty: 12.0
30+ product_uom: product.product_uom_unit
31+ state: 'done'
32+-
33+ I create inventory.
34+-
35+ !record {model: stock.inventory, id: stock_inventory_same_location}:
36+ company_id: base.main_company
37+ date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
38+ date_done: !eval time.strftime('%Y-%m-%d %H:%M:%S')
39+ name: Physical inventory
40+ state: draft
41+-
42+ I create a stock.fill.inventory wizard .
43+-
44+ !record {model: stock.fill.inventory, id: stock_fill_inventory_1}:
45+ location_id: stock.stock_location_14
46+-
47+ I fill the inventory for location stock_location_14.
48+-
49+ !python {model: stock.fill.inventory}: |
50+ from osv import osv
51+ try:
52+ self.fill_inventory(cr, uid, [ref("stock_fill_inventory_1")], {"lang": 'en_US',
53+ "full": "1", "tz": False, "active_model": "stock.inventory", "active_ids":
54+ [ref("stock_inventory_same_location")], "active_id": ref("stock_inventory_same_location"), })
55+ except osv.except_osv:
56+ # The wizard may throw an exception since there is actually nothing to import
57+ pass
58+-
59+ I confirm and validate inventory - the quantity available must not change
60+-
61+ !python {model: stock.inventory}: |
62+ prod_obj = self.pool.get("product.product")
63+ old_qty = prod_obj.read(cr, uid, [ref('product.product_product_pc2')], ['qty_available'])[0]['qty_available']
64+ self.action_confirm(cr,uid,[ref('stock_inventory_same_location')])
65+ self.action_done(cr,uid,[ref('stock_inventory_same_location')])
66+ new_qty = prod_obj.read(cr, uid, [ref('product.product_product_pc2')], ['qty_available'])[0]['qty_available']
67+ assert old_qty == new_qty, "The quantity available should not change (%s -> %s)." % (old_qty, new_qty)
68
69=== modified file 'stock/wizard/stock_fill_inventory.py'
70--- stock/wizard/stock_fill_inventory.py 2012-04-25 12:22:20 +0000
71+++ stock/wizard/stock_fill_inventory.py 2013-09-23 15:27:09 +0000
72@@ -90,6 +90,8 @@
73 move_ids = move_obj.search(cr, uid, ['|',('location_dest_id','=',location),('location_id','=',location),('state','=','done')], context=context)
74
75 for move in move_obj.browse(cr, uid, move_ids, context=context):
76+ if move.location_dest_id.id == move.location_id.id:
77+ continue
78 lot_id = move.prodlot_id.id
79 prod_id = move.product_id.id
80 if move.location_dest_id.id == location: