diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 4a1b5583e7e..100a1168505 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -719,6 +719,15 @@ class purchase_order(osv.osv): alldoneorcancel = False return cancel and alldoneorcancel + + def move_lines_get(self, cr, uid, ids, *args): + res = [] + for order in self.browse(cr, uid, ids, context={}): + for line in order.order_line: + res += [x.id for x in line.move_ids] + return res + + def action_picking_create(self, cr, uid, ids, context=None): picking_ids = [] for order in self.browse(cr, uid, ids): diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml index bc9ef988fd1..f55f2cf29fd 100644 --- a/addons/purchase/purchase_workflow.xml +++ b/addons/purchase/purchase_workflow.xml @@ -76,12 +76,14 @@ function action_picking_create() + + + picking_done picking_done() function - subflow.delivery_done @@ -171,6 +173,8 @@ + stock.move + move_lines_get() test_moves_except() @@ -181,7 +185,10 @@ + stock.move + move_lines_get() test_moves_done() + diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index bff0c59f399..b5faf909e3f 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -31,20 +31,6 @@ class stock_move(osv.osv): - def action_done(self, cr, uid, ids, context=None): - ''' - THIS SHOULD BE REPLACED BY SOMETHING THAT WILL TRIGGER AUTOMATICALLY - DOES NOT WORK ANYWAYS - ''' - res = super(stock_move, self).action_done(cr, uid, ids, context=context) - wf_service = netsvc.LocalService("workflow") - for move in self.browse(cr, uid, ids, context=context): - if move.purchase_line_id: - wf_service.trg_trigger(uid, 'purchase.order', move.purchase_line_id.order_id.id, cr) - return res - - - # # Inherit of picking to add the link to the PO # diff --git a/addons/stock/stock.py b/addons/stock/stock.py index c3d36c9dfa3..c0fd277cb69 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1328,24 +1328,9 @@ class stock_move(osv.osv): raise osv.except_osv(_('Operation Forbidden!'), _('Quantities, Units of Measure, Products and Locations cannot be modified on stock moves that have already been processed (except by the Administrator).')) result = super(stock_move, self).write(cr, uid, ids, vals, context=context) - self._update_picking(cr, uid, ids, vals, context=context) return result - # update picking as the move changed - def _update_picking(self, cr, uid, ids, vals, context=None): - # FP Note: test if this would do the trick - #for id in ids: - # wf_service.trg_trigger(uid, 'stock.move', id, cr) - if ('state' in vals) or ('picking_id' in vals): - wf_service = netsvc.LocalService('workflow') - done = {} - for move in self.browse(cr, uid, ids, context): - if move.picking_id and (move.picking_id.id not in done): - wf_service.trg_write(uid, 'stock.picking', move.picking_id.id, cr) - done[move.picking_id.id] = True - for id in ids: - wf_service.trg_trigger(uid, 'stock.move', id, cr) - return True + def _auto_init(self, cursor, context=None): res = super(stock_move, self)._auto_init(cursor, context=context) @@ -1678,11 +1663,6 @@ class stock_move(osv.osv): self.action_assign(cr, uid, [move.move_dest_id.id], context=context) self.write(cr, uid, ids, {'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}, context=context) - if move.picking_id: - move.picking_id.refresh() - if all([m.state in ('done', 'cancel') for m in move.picking_id.move_lines]): - #finish the picking if it was the last move (we exclude the move we just set to done because we know the value and the browse record cache isn't up to date - picking_obj.action_done(cr, uid, [move.picking_id.id], context=context) return True def unlink(self, cr, uid, ids, context=None):