Merge lp:~unifield-team/unifield-addons/uf-715 into lp:unifield-addons

Proposed by jftempo
Status: Merged
Merged at revision: 4508
Proposed branch: lp:~unifield-team/unifield-addons/uf-715
Merge into: lp:unifield-addons
Diff against target: 78 lines (+30/-15)
1 file modified
stock/stock.py (+30/-15)
To merge this branch: bzr merge lp:~unifield-team/unifield-addons/uf-715
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+85658@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/stock.py'
2--- stock/stock.py 2011-11-21 13:19:03 +0000
3+++ stock/stock.py 2011-12-14 13:15:31 +0000
4@@ -1410,7 +1410,9 @@
5 """
6 if context is None:
7 context = {}
8- if 'location_id' not in context:
9+ # when the location_id = False results now in showing stock for all internal locations
10+ # *previously*, was showing the location of no location (= 0.0 for all prodlot)
11+ if 'location_id' not in context or not context['location_id']:
12 locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')], context=context)
13 else:
14 locations = context['location_id'] and [context['location_id']] or []
15@@ -1435,21 +1437,27 @@
16 """ Searches Ids of products
17 @return: Ids of locations
18 """
19- if context.get('location_id', False):
20+ if context is None:
21+ context = {}
22+ # when the location_id = False results now in showing stock for all internal locations
23+ # *previously*, was showing the location of no location (= 0.0 for all prodlot)
24+ if 'location_id' not in context or not context['location_id']:
25+ locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')], context=context)
26+ else:
27 locations = context['location_id'] and [context['location_id']] or []
28- else:
29- locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')])
30
31- cr.execute('''select
32- prodlot_id,
33- sum(qty)
34- from
35- stock_report_prodlots
36- where
37- location_id IN %s group by prodlot_id
38- having sum(qty) '''+ str(args[0][1]) + str(args[0][2]),(tuple(locations),))
39- res = cr.fetchall()
40- ids = [('id', 'in', map(lambda x: x[0], res))]
41+ ids = [('id', 'in', [])]
42+ if locations:
43+ cr.execute('''select
44+ prodlot_id,
45+ sum(qty)
46+ from
47+ stock_report_prodlots
48+ where
49+ location_id IN %s group by prodlot_id
50+ having sum(qty) '''+ str(args[0][1]) + str(args[0][2]),(tuple(locations),))
51+ res = cr.fetchall()
52+ ids = [('id', 'in', map(lambda x: x[0], res))]
53 return ids
54
55 _columns = {
56@@ -2160,6 +2168,13 @@
57 'line_id': move_lines,
58 'ref': move.picking_id and move.picking_id.name})
59
60+ def _hook_action_done_update_out_move_check(self, cr, uid, ids, context=None, *args, **kwargs):
61+ '''
62+ choose if the corresponding out stock move must be updated
63+ '''
64+ move = kwargs['move']
65+ result = move.move_dest_id.id and (move.state != 'done')
66+ return result
67
68 def action_done(self, cr, uid, ids, context=None):
69 """ Makes the move done and if all moves are done, it will finish the picking.
70@@ -2193,7 +2208,7 @@
71
72 if move.picking_id:
73 picking_ids.append(move.picking_id.id)
74- if move.move_dest_id.id and (move.state != 'done'):
75+ if self._hook_action_done_update_out_move_check(cr, uid, ids, context=context, move=move,):
76 self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]})
77 #cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
78 if move.move_dest_id.state in ('waiting', 'confirmed'):

Subscribers

People subscribed via source and target branches

to all changes: