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

Proposed by Rifakat Husen (OpenERP)
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: 6978
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-578768-rha
Merge into: lp:openobject-addons/6.1
Diff against target: 25 lines (+5/-3)
1 file modified
stock/wizard/stock_fill_inventory.py (+5/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-578768-rha
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+122627@code.launchpad.net

Description of the change

Hello,

Fixed problem of 'Fill Inventory' wizards which adds qty for dummy moves also,
Ex. Stock -> Stock

If we try to fill inventory for location 'Stock',
It search for all the stock movements with location 'Stock' as Source or Destination
which includes dummy movement too and adds qty for dummy movement which results into
posting wrong move for inventory.

Detail steps are provided in lp:1045334

Please review this fix.

Regards,
Rifakat

To post a comment you must log in.
6978. By Rifakat Husen (OpenERP)

[IMP] improved code, fetch result in a single search() domain

Revision history for this message
Ferdinand (office-chricar) wrote :

Hello!

I do not know how the SQL statement will look like and how postgresql will optimize the search.

performance is critical and full table scans must be avoided

a statement like
select id from stock_move where (location_id = 12 and location_dest_id != 12) or (location_id !=12 and location_dest_id =12);

would generate an optimized query plan
explain select id from stock_move where (location_id = 12 and location_dest_id != 12) or (location_id !=12 and location_dest_id =12);
                                                     QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on stock_move (cost=68.96..324.66 rows=2632 width=4)
   Recheck Cond: ((location_id = 12) OR (location_dest_id = 12))
   Filter: (((location_id = 12) AND (location_dest_id <> 12)) OR ((location_id <> 12) AND (location_dest_id = 12)))
   -> BitmapOr (cost=68.96..68.96 rows=3085 width=0)
         -> Bitmap Index Scan on stock_move_location_id_index (cost=0.00..55.68 rows=2590 width=0)
               Index Cond: (location_id = 12)
         -> Bitmap Index Scan on stock_move_location_dest_id_index (cost=0.00..11.96 rows=495 width=0)
               Index Cond: (location_dest_id = 12)

Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-578768-port-mma/+merge/132541 and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Thanks,
Naresh Soni

Unmerged revisions

6978. By Rifakat Husen (OpenERP)

[IMP] improved code, fetch result in a single search() domain

6977. By Rifakat Husen (OpenERP)

[IMP] optimized code

6976. By Rifakat Husen (OpenERP)

[IMP] removed unused imports

6975. By Rifakat Husen (OpenERP)

[FIX] stock: fixed import invertory wizard problem, restricted dummy moves' qty to be added into total

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/wizard/stock_fill_inventory.py'
2--- stock/wizard/stock_fill_inventory.py 2011-12-08 05:58:41 +0000
3+++ stock/wizard/stock_fill_inventory.py 2012-09-04 13:09:20 +0000
4@@ -67,8 +67,6 @@
5
6 inventory_line_obj = self.pool.get('stock.inventory.line')
7 location_obj = self.pool.get('stock.location')
8- product_obj = self.pool.get('product.product')
9- stock_location_obj = self.pool.get('stock.location')
10 move_obj = self.pool.get('stock.move')
11 uom_obj = self.pool.get('product.uom')
12 if ids and len(ids):
13@@ -92,7 +90,11 @@
14 for location in location_ids:
15 datas = {}
16 res[location] = {}
17- move_ids = move_obj.search(cr, uid, ['|',('location_dest_id','=',location),('location_id','=',location),('state','=','done')], context=context)
18+ move_ids = move_obj.search(cr, uid, ['|', '&', ('location_id', '!=', location),
19+ ('location_dest_id', '=', location),
20+ '&', ('location_id', '=', location),
21+ ('location_dest_id', '!=', location),
22+ ('state', '=', 'done')], context=context)
23
24 for move in move_obj.browse(cr, uid, move_ids, context=context):
25 lot_id = move.prodlot_id.id