← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/ocb-addons/ocb-7.0-fix_1267495-afe into lp:ocb-addons

 

Alexandre Fayolle - camptocamp has proposed merging lp:~camptocamp/ocb-addons/ocb-7.0-fix_1267495-afe into lp:ocb-addons.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1267495 in OpenERP Community Backports (Addons): "[7.0] stock: call to stock.picking cancel_assign causes many unnecessary calls to workflow trg_write"
  https://bugs.launchpad.net/ocb-addons/+bug/1267495

For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-7.0-fix_1267495-afe/+merge/201023

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
-- 
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-7.0-fix_1267495-afe/+merge/201023
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-addons/ocb-7.0-fix_1267495-afe into lp:ocb-addons.
=== modified file 'stock/stock.py'
--- stock/stock.py	2013-11-28 14:50:59 +0000
+++ stock/stock.py	2014-01-09 15:10:13 +0000
@@ -822,11 +822,9 @@
         """ Cancels picking and moves.
         @return: True
         """
-        wf_service = netsvc.LocalService("workflow")
         for pick in self.browse(cr, uid, ids):
             move_ids = [x.id for x in pick.move_lines]
             self.pool.get('stock.move').cancel_assign(cr, uid, move_ids)
-            wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
         return True
 
     def action_assign_wkf(self, cr, uid, ids, context=None):
@@ -2175,10 +2173,12 @@
         # fix for bug lp:707031
         # called write of related picking because changing move availability does
         # not trigger workflow of picking in order to change the state of picking
+        seen = set()
         wf_service = netsvc.LocalService('workflow')
         for move in self.browse(cr, uid, ids, context):
-            if move.picking_id:
+            if move.picking_id and move.picking_id.id not in seen:
                 wf_service.trg_write(uid, 'stock.picking', move.picking_id.id, cr)
+                seen.add(move.picking_id.id)
         return True
 
     #


Follow ups