Merge lp:~openerp-dev/openobject-addons/trunk-bug-725908-ksa into lp:openobject-addons

Proposed by Kirti Savalia(OpenERP)
Status: Superseded
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-725908-ksa
Merge into: lp:openobject-addons
Diff against target: 114 lines (+49/-28)
1 file modified
stock/wizard/stock_fill_inventory.py (+49/-28)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-725908-ksa
Reviewer Review Type Date Requested Status
Rucha (Open ERP) (community) Needs Fixing
Review via email: mp+52181@code.launchpad.net

This proposal has been superseded by a proposal from 2011-03-08.

To post a comment you must log in.
Revision history for this message
Rucha (Open ERP) (rpa-openerp) :
review: Needs Fixing

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-01-14 00:11:01 +0000
3+++ stock/wizard/stock_fill_inventory.py 2011-03-08 07:02:23 +0000
4@@ -58,62 +58,83 @@
5 @return:
6 """
7 if context is None:
8- context = {}
9+ context = {}
10 inventory_line_obj = self.pool.get('stock.inventory.line')
11 location_obj = self.pool.get('stock.location')
12 product_obj = self.pool.get('product.product')
13 stock_location_obj = self.pool.get('stock.location')
14- if ids and len(ids):
15+ move_obj = self.pool.get('stock.move')
16+ if ids and len(ids):
17 ids = ids[0]
18 else:
19- return {'type': 'ir.actions.act_window_close'}
20+ return {'type': 'ir.actions.act_window_close'}
21 fill_inventory = self.browse(cr, uid, ids, context=context)
22 res = {}
23 res_location = {}
24 if fill_inventory.recursive :
25 location_ids = location_obj.search(cr, uid, [('location_id',
26 'child_of', fill_inventory.location_id.id)])
27+
28 for location in location_ids :
29 res = location_obj._product_get(cr, uid, location)
30 res_location[location] = res
31+ data = res_location.keys()
32+ data.sort()
33 else:
34 context.update({'compute_child': False})
35 res = location_obj._product_get(cr, uid,
36 fill_inventory.location_id.id, context=context)
37 res_location[fill_inventory.location_id.id] = res
38-
39+ data = res_location.keys()
40+ data.sort()
41+
42 product_ids = []
43- for location in res_location.keys():
44- res = res_location[location]
45- for product_id in res.keys():
46- prod = product_obj.browse(cr, uid, product_id, context=context)
47- uom = prod.uom_id.id
48- context.update(uom=uom, compute_child=False)
49- amount = stock_location_obj._product_get(cr, uid,
50- location, [product_id], context=context)[product_id]
51- if(amount):
52+ res = {}
53+ for location in data:
54+ datas = {}
55+ res[location] = {}
56+ if fill_inventory.recursive :
57+ move_ids = move_obj.search(cr, uid, [('location_dest_id','child_of',location),('state','=','done')], context=context)
58+ else:
59+ move_ids = move_obj.search(cr, uid, [('location_dest_id','=',location),('state','=','done')], context=context)
60+ if not move_ids:
61+ raise osv.except_osv(_('Message !'), _('No product in this location.'))
62+
63+ for move in move_obj.browse(cr, uid, move_ids, context=context):
64+ lot_id = move.prodlot_id.id
65+ prod_id = move.product_id.id
66+ qty = move.product_qty
67+ location_dest_id = move.location_dest_id.id
68+ if datas.get((prod_id, lot_id)):
69+ qty = datas[(prod_id, lot_id)]['product_qty'] + qty
70+ datas[(prod_id, lot_id)] = {'product_id': prod_id, 'location_dest_id': location_dest_id, 'product_qty': qty, 'product_uom': move.product_id.uom_id.id, 'prodlot_id': lot_id}
71+ res[location] = datas
72+
73+ for i in datas.items():
74+ if(i[1]['product_qty']):
75 if fill_inventory.set_stock_zero:
76- amount = 0
77- line_ids=inventory_line_obj.search(cr, uid,
78- [('inventory_id', '=', context['active_ids']),
79- ('location_id', '=', location),
80- ('product_id', '=', product_id),
81- ('product_uom', '=', uom),
82- ('product_qty', '=', amount)])
83+ i[1]['product_qty'] = 0
84+
85+ line_ids = inventory_line_obj.search(cr, uid,
86+ [('inventory_id','=', context['active_ids']),
87+ ('location_id','=', i[1]['location_dest_id']),
88+ ('product_id','=', i[1]['product_id']),
89+ ('product_uom','=', i[1]['product_uom']),
90+ ('product_qty','=', i[1]['product_qty']),
91+ ('prod_lot_id','=', i[1]['prodlot_id'])
92+ ])
93 if not len(line_ids):
94 inventory_line = {
95 'inventory_id': context['active_ids'][0],
96- 'location_id': location,
97- 'product_id': product_id,
98- 'product_uom': uom,
99- 'product_qty': amount
100+ 'location_id': i[1]['location_dest_id'],
101+ 'product_id': i[1]['product_id'],
102+ 'product_uom': i[1]['product_uom'],
103+ 'product_qty': i[1]['product_qty'],
104+ 'prod_lot_id': i[1]['prodlot_id']
105 }
106 inventory_line_obj.create(cr, uid, inventory_line)
107- product_ids.append(product_id)
108
109- if(len(product_ids) == 0):
110- raise osv.except_osv(_('Message !'), _('No product in this location.'))
111- return {'type': 'ir.actions.act_window_close'}
112+ return {'type': 'ir.actions.act_window_close'}
113
114 stock_fill_inventory()
115

Subscribers

People subscribed via source and target branches

to all changes: