Merge lp:~openerp-dev/openobject-addons/7.0-opw-603094-rha into lp:openobject-addons/7.0

Proposed by Rifakat Husen (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-603094-rha
Merge into: lp:openobject-addons/7.0
Diff against target: 35 lines (+10/-3)
1 file modified
stock/stock.py (+10/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-603094-rha
Reviewer Review Type Date Requested Status
Paulius Sladkevičius @ hbee (community) test Approve
Naresh(OpenERP) Pending
Review via email: mp+203273@code.launchpad.net

Description of the change

When there is a move(upstream) chained with another move(downstream), and we split the upstream move into several moves in the picking(using Serial Number split wizard). The downstream move should be triggered when we process the last move among the upstream moves, but currently this is not working. Processing last upstream move does not trigger the downstream move, so downstream move always be in state "Waiting Another Move" even if all upstream moves/picking is validated.

Steps to reproduce:
* Create chaining for location, Stock -> Quality Control(Chaining Type:Manual Operation)
* Create incoming shipment for 10 unit of "USB Adapter", Supplier -> Stock. Confirm it.
* It will create chained internal picking. Stock -> Quality Control.
* For Incoming Shipment, Split move for Serial Number with 5 qty. so you will have 2 moves with 5 qty each.
* When we validate shipment with these 2 (upstream)moves together with full qty, it should mark internal picking(downstream move) as "Ready to Transfer". But it doesn't. Downstream move remain as "Waiting Another Move".

Problem:
When action_done() for stock.move is called for all the upstream moves, logic is to trigger(confirm) downstream move while last upstream move is validated. Logic for checking the last upstream move is not working because, those moves are still inside action_done() and their state is not marked as 'done' while loop execution.

Solution:
Instead of checking upstream moves and state=done, it created a dict which keeps information of processed upstream moves.

To post a comment you must log in.
Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

I've tested this patch and it looks it solved my issue, an infinitive loop that I've faced in the procurement cron job.

review: Approve (test)

Unmerged revisions

9782. By Rifakat Husen (OpenERP)

[FIX] stock: when several moves shares the same downstream move(move_dest_id) then
downstream move should be trigerred only when the last upstream move is reached and others are already processed

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 2014-01-22 13:38:22 +0000
3+++ stock/stock.py 2014-01-27 06:21:43 +0000
4@@ -2385,6 +2385,7 @@
5 """
6 picking_ids = []
7 move_ids = []
8+ checked_upstream_moves = {}
9 wf_service = netsvc.LocalService("workflow")
10 if context is None:
11 context = {}
12@@ -2401,14 +2402,20 @@
13 if move.state in ['done','cancel']:
14 continue
15 move_ids.append(move.id)
16-
17+
18 if move.picking_id:
19 picking_ids.append(move.picking_id.id)
20- if move.move_dest_id.id and (move.state != 'done'):
21+ if move.move_dest_id.id:
22+ # Build a dict to save the info for which upsteam moves has been checked over the downstream move
23+ if not move.move_dest_id.id in checked_upstream_moves:
24+ move_dest_id = move.move_dest_id.id
25+ checked_upstream_moves.update({move_dest_id:[move.id]})
26+ else:
27+ checked_upstream_moves[move.move_dest_id.id].append(move.id)
28 # Downstream move should only be triggered if this move is the last pending upstream move
29 other_upstream_move_ids = self.search(cr, uid, [('id','!=',move.id),('state','not in',['done','cancel']),
30 ('move_dest_id','=',move.move_dest_id.id)], context=context)
31- if not other_upstream_move_ids:
32+ if not other_upstream_move_ids or set(other_upstream_move_ids) <= set(checked_upstream_moves[move.move_dest_id.id]):
33 self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]})
34 if move.move_dest_id.state in ('waiting', 'confirmed'):
35 self.force_assign(cr, uid, [move.move_dest_id.id], context=context)