[FIX] MRP/STOCK : Completed movies should not be re-considered while completing produ...
authorJay (OpenERP) <jvo@tinyerp.com>
Wed, 24 Nov 2010 18:09:24 +0000 (23:39 +0530)
committerJay (OpenERP) <jvo@tinyerp.com>
Wed, 24 Nov 2010 18:09:24 +0000 (23:39 +0530)
lp bug: https://launchpad.net/bugs/677437 fixed

bzr revid: jvo@tinyerp.com-20101124180924-2c9157wv4tn1fd97

addons/mrp/mrp.py
addons/stock/stock.py

index f500d4f..21b6d28 100644 (file)
@@ -513,7 +513,7 @@ class mrp_production(osv.osv):
                             (res.id, move.id))
 #                move_ids.append(res.id)
             vals= {'state':'confirmed'}
-            new_moves = [x.id for x in production.move_created_ids]
+            new_moves = [x.id for x in production.move_created_ids if x.state not in ['done','cancel']]
             self.pool.get('stock.move').write(cr, uid, new_moves, vals)
             if not production.date_finnished:
                 self.write(cr, uid, [production.id],
index 64d9467..db83331 100644 (file)
@@ -1342,6 +1342,7 @@ class stock_move(osv.osv):
 
     def action_done(self, cr, uid, ids, context=None):
         track_flag = False
+        move_ids = []
         for move in self.browse(cr, uid, ids):
             if move.move_dest_id.id and (move.state != 'done'):
                 cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
@@ -1359,6 +1360,9 @@ class stock_move(osv.osv):
             #
             # Accounting Entries
             #
+            if move.state in ['done','cancel']:
+                continue
+            move_ids.append(move.id)
             acc_src = None
             acc_dest = None
             if move.location_id.account_id:
@@ -1440,10 +1444,11 @@ class stock_move(osv.osv):
                         'line_id': lines,
                         'ref': ref,
                     })
-        self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
-        wf_service = netsvc.LocalService("workflow")
-        for id in ids:
-            wf_service.trg_trigger(uid, 'stock.move', id, cr)
+        if move_ids:
+            self.write(cr, uid, move_ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
+            wf_service = netsvc.LocalService("workflow")
+            for id in move_ids:
+                wf_service.trg_trigger(uid, 'stock.move', id, cr)
         return True
 
     def unlink(self, cr, uid, ids, context=None):