[MERGE] forward port of branch 7.0 up to 529e920
[odoo/odoo.git] / addons / mrp / stock.py
index d049aea..08a74b3 100644 (file)
@@ -21,7 +21,6 @@
 
 from openerp.osv import fields
 from openerp.osv import osv
-from openerp import netsvc
 
 
 class StockMove(osv.osv):
@@ -45,7 +44,6 @@ class StockMove(osv.osv):
         move_obj = self.pool.get('stock.move')
         procurement_obj = self.pool.get('procurement.order')
         product_obj = self.pool.get('product.product')
-        wf_service = netsvc.LocalService("workflow")
         processed_ids = [move.id]
         if move.product_id.supply_method == 'produce':
             bis = bom_obj.search(cr, uid, [
@@ -87,16 +85,17 @@ class StockMove(osv.osv):
                         'procure_method': prodobj.procure_method,
                         'move_id': mid,
                     })
-                    wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
+                    procurement_obj.signal_button_confirm(cr, uid, [proc_id])
+                    
                 move_obj.write(cr, uid, [move.id], {
                     'location_dest_id': move.location_id.id, # dummy move for the kit
                     'auto_validate': True,
                     'picking_id': False,
                     'state': 'confirmed'
                 })
-                for m in procurement_obj.search(cr, uid, [('move_id','=',move.id)], context):
-                    wf_service.trg_validate(uid, 'procurement.order', m, 'button_confirm', cr)
-                    wf_service.trg_validate(uid, 'procurement.order', m, 'button_wait_done', cr)
+                procurement_ids = procurement_obj.search(cr, uid, [('move_id','=',move.id)], context)
+                procurement_obj.signal_button_confirm(cr, uid, procurement_ids)
+                procurement_obj.signal_button_wait_done(cr, uid, procurement_ids)
         if processed_ids and move.state == 'assigned':
             # Set the state of resulting moves according to 'assigned' as the original move is assigned
             move_obj.write(cr, uid, list(set(processed_ids) - set([move.id])), {'state': 'assigned'}, context=context)
@@ -110,7 +109,6 @@ class StockMove(osv.osv):
         """       
         res = []
         production_obj = self.pool.get('mrp.production')
-        wf_service = netsvc.LocalService("workflow")
         for move in self.browse(cr, uid, ids):
             move.action_confirm(context)
             new_moves = super(StockMove, self).action_consume(cr, uid, [move.id], product_qty, location_id, context=context)
@@ -118,7 +116,7 @@ class StockMove(osv.osv):
             for prod in production_obj.browse(cr, uid, production_ids, context=context):
                 if prod.state == 'confirmed':
                     production_obj.force_production(cr, uid, [prod.id])
-                wf_service.trg_validate(uid, 'mrp.production', prod.id, 'button_produce', cr)
+            production_obj.signal_button_produce(cr, uid, production_ids)                
             for new_move in new_moves:
                 if new_move == move.id:
                     #This move is already there in move lines of production order
@@ -135,20 +133,18 @@ class StockMove(osv.osv):
         """  
         res = []
         production_obj = self.pool.get('mrp.production')
-        wf_service = netsvc.LocalService("workflow")
         for move in self.browse(cr, uid, ids, context=context):
             new_moves = super(StockMove, self).action_scrap(cr, uid, [move.id], product_qty, location_id, context=context)
             #If we are not scrapping our whole move, tracking and lot references must not be removed
             #self.write(cr, uid, [move.id], {'prodlot_id': False, 'tracking_id': False})
             production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
             for prod_id in production_ids:
-                wf_service.trg_validate(uid, 'mrp.production', prod_id, 'button_produce', cr)
+                production_obj.signal_button_produce(cr, uid, [prod_id])
             for new_move in new_moves:
                 production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
                 res.append(new_move)
         return res
 
-StockMove()
 
 
 class StockPicking(osv.osv):
@@ -167,7 +163,6 @@ class StockPicking(osv.osv):
             todo.extend(move.id for move in moves if move.state not in ['confirmed', 'assigned', 'done'])
         return list(set(todo))
 
-StockPicking()
 
 
 class split_in_production_lot(osv.osv_memory):
@@ -184,6 +179,5 @@ class split_in_production_lot(osv.osv_memory):
         production_obj.write(cr, uid, production_ids, {'move_lines': [(4, m) for m in new_moves]})
         return new_moves
 
-split_in_production_lot()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: