Merge lp:~camptocamp/openobject-addons/7.0-fix_1267495-afe into lp:openobject-addons/7.0

Proposed by Alexandre Fayolle - camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/7.0-fix_1267495-afe
Merge into: lp:openobject-addons/7.0
Diff against target: 29 lines (+3/-3)
1 file modified
stock/stock.py (+3/-3)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/7.0-fix_1267495-afe
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+201024@code.launchpad.net

Description of the change

reduce the number of unnecessary calls to trg_write in cancel_assign

when calling stock_picking.cancel_assign, the original code would call trg_write nb_move+1 times. This version only performs one call per stock.picking affected

To post a comment you must log in.

Unmerged revisions

9747. By Alexandre Fayolle - camptocamp

[FIX] reduce the number of unnecessary calls to trg_write in cancel_assign

when calling stock_picking.cancel_assign, the original code would call trg_write nb_move+1 times. This version only performs one call

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 2013-11-28 14:50:59 +0000
3+++ stock/stock.py 2014-01-09 15:10:15 +0000
4@@ -822,11 +822,9 @@
5 """ Cancels picking and moves.
6 @return: True
7 """
8- wf_service = netsvc.LocalService("workflow")
9 for pick in self.browse(cr, uid, ids):
10 move_ids = [x.id for x in pick.move_lines]
11 self.pool.get('stock.move').cancel_assign(cr, uid, move_ids)
12- wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
13 return True
14
15 def action_assign_wkf(self, cr, uid, ids, context=None):
16@@ -2161,10 +2159,12 @@
17 # fix for bug lp:707031
18 # called write of related picking because changing move availability does
19 # not trigger workflow of picking in order to change the state of picking
20+ seen = set()
21 wf_service = netsvc.LocalService('workflow')
22 for move in self.browse(cr, uid, ids, context):
23- if move.picking_id:
24+ if move.picking_id and move.picking_id.id not in seen:
25 wf_service.trg_write(uid, 'stock.picking', move.picking_id.id, cr)
26+ seen.add(move.picking_id.id)
27 return True
28
29 #