Merge lp:~unifield-team/unifield-wm/uf-2134 into lp:unifield-wm

Proposed by Quentin THEURET @Amaris
Status: Merged
Merged at revision: 1843
Proposed branch: lp:~unifield-team/unifield-wm/uf-2134
Merge into: lp:unifield-wm
Diff against target: 145 lines (+68/-5)
3 files modified
msf_cross_docking/cross_docking.py (+3/-3)
msf_outgoing/msf_outgoing.py (+11/-0)
stock_override/stock.py (+54/-2)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/uf-2134
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+191569@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 'msf_cross_docking/cross_docking.py'
2--- msf_cross_docking/cross_docking.py 2013-09-26 15:25:50 +0000
3+++ msf_cross_docking/cross_docking.py 2013-10-17 08:16:07 +0000
4@@ -590,11 +590,11 @@
5 ret = self.write(cr, uid, todo, {'location_id': cross_docking_location, 'move_cross_docking_ok': True}, context=context)
6
7 # we cancel availability
8- self.cancel_assign(cr, uid, todo, context=context)
9+ todo = self.cancel_assign(cr, uid, todo, context=context)
10 # we rechech availability
11 self.action_assign(cr, uid, todo)
12 #FEFO
13- self.fefo_update(cr, uid, ids, context)
14+ self.fefo_update(cr, uid, todo, context)
15 # below we cancel availability to recheck it
16 # stock_picking_id = self.read(cr, uid, todo, ['picking_id'], context=context)[0]['picking_id'][0]
17 # picking_todo.append(stock_picking_id)
18@@ -639,7 +639,7 @@
19
20 if todo:
21 # we cancel availability
22- self.cancel_assign(cr, uid, todo, context=context)
23+ todo = self.cancel_assign(cr, uid, todo, context=context)
24 # we rechech availability
25 self.action_assign(cr, uid, todo)
26
27
28=== modified file 'msf_outgoing/msf_outgoing.py'
29--- msf_outgoing/msf_outgoing.py 2013-10-14 12:45:55 +0000
30+++ msf_outgoing/msf_outgoing.py 2013-10-17 08:16:07 +0000
31@@ -2271,6 +2271,7 @@
32 date_tools = self.pool.get('date.tools')
33 fields_tools = self.pool.get('fields.tools')
34 db_date_format = date_tools.get_db_date_format(cr, uid, context=context)
35+ moves_states = {}
36 for obj in self.browse(cr, uid, ids, context=context):
37 # the convert function should only be called on draft picking ticket
38 assert obj.subtype == 'picking' and obj.state == 'draft', 'the convert function should only be called on draft picking ticket objects'
39@@ -2295,6 +2296,8 @@
40 if move.product_qty == 0.0:
41 vals = {'state': 'done'}
42 else:
43+ # Save the state of this stock move to set it before action_assign()
44+ moves_states.setdefault(move.state, []).append(move.id)
45 vals = {'state': 'draft'}
46 # If the move comes from a DPO, don't change the destination location
47 if not move.dpo_id:
48@@ -2314,8 +2317,16 @@
49
50 # trigger workflow (confirm picking)
51 self.draft_force_assign(cr, uid, [obj.id])
52+
53+ for s in moves_states:
54+ self.pool.get('stock.move').write(cr, uid, moves_states[s], {'state': s}, context=context)
55+
56 # check availability
57 self.action_assign(cr, uid, [obj.id], context=context)
58+
59+ if 'assigned' in moves_states:
60+ # Add an empty write to display the 'Process' button on OUT
61+ self.write(cr, uid, [obj.id], {'state': 'assigned'}, context=context)
62
63 # TODO which behavior
64 data_obj = self.pool.get('ir.model.data')
65
66=== modified file 'stock_override/stock.py'
67--- stock_override/stock.py 2013-10-14 13:24:26 +0000
68+++ stock_override/stock.py 2013-10-17 08:16:07 +0000
69@@ -1106,7 +1106,7 @@
70 prodlot_obj = self.pool.get('stock.production.lot')
71 for move in self.browse(cr, uid, ids, context):
72 # FEFO logic
73- if move.state == 'assigned': # a check_availability has already been done in action_assign, so we take only the 'assigned' lines
74+ if move.state == 'assigned' and not move.prodlot_id: # a check_availability has already been done in action_assign, so we take only the 'assigned' lines
75 needed_qty = move.product_qty
76 res = loc_obj.compute_availability(cr, uid, [move.location_id.id], True, move.product_id.id, move.product_uom.id, context=context)
77 if 'fefo' in res:
78@@ -1145,7 +1145,7 @@
79 needed_qty -= selected_qty
80 dict_for_create = {}
81 dict_for_create = values.copy()
82- dict_for_create.update({'product_uom': loc['uom_id'], 'product_qty': selected_qty, 'location_id': loc['location_id'], 'prodlot_id': loc['prodlot_id'], 'line_number': move.line_number})
83+ dict_for_create.update({'product_uom': loc['uom_id'], 'product_qty': selected_qty, 'location_id': loc['location_id'], 'prodlot_id': loc['prodlot_id'], 'line_number': move.line_number, 'move_cross_docking_ok': move.move_cross_docking_ok})
84 self.create(cr, uid, dict_for_create, context)
85 self.write(cr, uid, move.id, {'product_qty': needed_qty})
86 # if the batch is outdated, we remove it
87@@ -1225,6 +1225,58 @@
88 self.write(cr, uid, ids, {'location_id': line.location_id.location_id.id})
89 return True
90
91+ def cancel_assign(self, cr, uid, ids, context=None):
92+ res = super(stock_move, self).cancel_assign(cr, uid, ids, context=context)
93+ res = []
94+
95+ fields_to_read = ['picking_id', 'product_id', 'product_uom', 'location_id',
96+ 'product_qty', 'product_uos_qty', 'location_dest_id',
97+ 'prodlot_id', 'asset_id', 'composition_list_id', 'line_number']
98+
99+ for move_data in self.read(cr, uid, ids, fields_to_read, context=context):
100+ search_domain = [('state', '=', 'confirmed'), ('id', '!=', move_data['id'])]
101+
102+ for f in fields_to_read:
103+ if f in ('product_qty', 'product_uos_qty'):
104+ continue
105+ d = move_data[f]
106+ if isinstance(move_data[f], tuple):
107+ d = move_data[f][0]
108+ search_domain.append((f, '=', d))
109+
110+ move_ids = self.search(cr, uid, search_domain, context=context)
111+ if move_ids:
112+ move = self.browse(cr, uid, move_ids[0], context=context)
113+ res.append(move.id)
114+ self.write(cr, uid, [move.id], {'product_qty': move.product_qty + move_data['product_qty'],
115+ 'product_uos_qty': move.product_uos_qty + move_data['product_uos_qty']}, context=context)
116+
117+ # Update all link objects
118+ proc_ids = self.pool.get('procurement.order').search(cr, uid, [('move_id', '=', move_data['id'])], context=context)
119+ if proc_ids:
120+ self.pool.get('procurement.order').write(cr, uid, proc_ids, {'move_id': move.id}, context=context)
121+
122+ pol_ids = self.pool.get('purchase.order.line').search(cr, uid, [('move_dest_id', '=', move_data['id'])], context=context)
123+ if pol_ids:
124+ self.pool.get('purchase.order.line').write(cr, uid, pol_ids, {'move_dest_id': move.id}, context=context)
125+
126+ move_dest_ids = self.search(cr, uid, [('move_dest_id', '=', move_data['id'])], context=context)
127+ if move_dest_ids:
128+ self.write(cr, uid, move_dest_ids, {'move_dest_id': move.id}, context=context)
129+
130+ backmove_ids = self.search(cr, uid, [('backmove_id', '=', move_data['id'])], context=context)
131+ if backmove_ids:
132+ self.write(cr, uid, backmove_ids, {'backmove_id': move.id}, context=context)
133+
134+ pack_backmove_ids = self.search(cr, uid, [('backmove_packing_id', '=', move_data['id'])], context=context)
135+ if pack_backmove_ids:
136+ self.write(cr, uid, pack_backmove_ids, {'backmove_packing_id': move.id}, context=context)
137+
138+ self.write(cr, uid, [move_data['id']], {'state': 'draft'}, context=context)
139+ self.unlink(cr, uid, move_data['id'], context=context)
140+
141+ return res
142+
143 def _hook_copy_stock_move(self, cr, uid, res, move, done, notdone):
144 while res:
145 r = res.pop(0)

Subscribers

People subscribed via source and target branches