From 9b33bc24cc799c3ffa604dc2eea94791f8cb61aa Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Fri, 31 Dec 2010 15:12:42 +0100 Subject: [PATCH] [FIX] mrp/stock bzr revid: fp@tinyerp.com-20101231141242-c0wnddie6fsoav9p --- addons/mrp/mrp.py | 8 ++++- addons/mrp/stock.py | 7 ----- addons/mrp_operations/test/mrp_operations.yml | 6 ++-- addons/stock/stock.py | 31 ++++++------------- 4 files changed, 19 insertions(+), 33 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 3850ab33822..a57b76bf2ce 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -664,6 +664,8 @@ class mrp_production(osv.osv): """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id, context=context) + + final_product_todo = [] produced_qty = 0 if production_mode == 'consume_produce': @@ -704,7 +706,11 @@ class mrp_production(osv.osv): stock_mov_obj.action_consume(cr, uid, [raw_product.id], consumed_qty, production.location_src_id.id, context=context) if production_mode == 'consume_produce': - + # To produce remaining qty of final product + vals = {'state':'confirmed'} + final_product_todo = [x.id for x in production.move_created_ids] + #stock_mov_obj.write(cr, uid, final_product_todo, vals) + stock_mov_obj.action_confirm(cr, uid, final_product_todo, context) produced_products = {} for produced_product in production.move_created_ids2: if produced_product.scrapped: diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index f8fad71fc58..8758bc09cd5 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -140,13 +140,6 @@ class StockMove(osv.osv): res.append(new_move) return {} - def trigger_move_state(self, cr, uid, move, state, context=None): - new_moves = super(StockMove, self).trigger_move_state(cr, uid, move, state, context=context) - if state == 'confirm': - new_moves =[x.id for x in new_moves] - self.write(cr, uid, new_moves, {'production_id': False}, context=context) - return new_moves - StockMove() diff --git a/addons/mrp_operations/test/mrp_operations.yml b/addons/mrp_operations/test/mrp_operations.yml index 299269cbb44..afa3fa55d74 100644 --- a/addons/mrp_operations/test/mrp_operations.yml +++ b/addons/mrp_operations/test/mrp_operations.yml @@ -13,10 +13,10 @@ product_id: product.product_product_pc1 product_qty: 5.0 product_uom: product.product_uom_unit - product_uos_qty: 0.0 -- + product_uos_qty: 5.0 +- I am computing the data. -- +- !python {model: mrp.production}: | self.action_compute(cr, uid, [ref("mrp_production_mo0")], {"lang": "en_US", "tz": False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids": diff --git a/addons/stock/stock.py b/addons/stock/stock.py index fd041989d93..97d5f9a0270 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1787,7 +1787,6 @@ class stock_move(osv.osv): 'date': picking.date, }) return pick_id - def action_confirm(self, cr, uid, ids, context=None): """ Confirms stock move. @return: List of ids. @@ -1837,10 +1836,9 @@ class stock_move(osv.osv): if pickid: wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr) if new_moves: - new_moves += create_chained_picking(self, cr, uid, new_moves, context) - return new_moves - all_moves = create_chained_picking(self, cr, uid, moves, context) - return all_moves + create_chained_picking(self, cr, uid, new_moves, context) + create_chained_picking(self, cr, uid, moves, context) + return [] def action_assign(self, cr, uid, ids, *args): """ Changes state to confirmed or waiting. @@ -2080,6 +2078,7 @@ class stock_move(osv.osv): todo = [] for move in self.browse(cr, uid, ids, context=context): + #print 'DONE MOVE', move.id, move.product_id.name, move.move_dest_id.id, move.state, move.move_dest_id and move.move_dest_id.state if move.state=="draft": todo.append(move.id) if todo: @@ -2093,9 +2092,10 @@ class stock_move(osv.osv): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): - self.write(cr, uid, [move.id], {'stock_move_history_ids': [(4, move.move_dest_id.id)]}, context=context) + self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]}) + #cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): - self.action_assign(cr, uid, [move.move_dest_id.id]) + self.force_assign(cr, uid, [move.move_dest_id.id], context=context) if move.move_dest_id.picking_id: wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) if move.move_dest_id.auto_validate: @@ -2281,18 +2281,7 @@ class stock_move(osv.osv): self.write(cr, uid, [current_move], update_val) return res - def trigger_move_state(self, cr, uid, move, state, context=None): - if isinstance(move, (int, long)): - move = [move] - res = [] - if state == 'confirm': - res = self.action_confirm(cr, uid, move, context=context) - if state == 'assigned': - self.check_assign(cr, uid, move, context=context) - self.force_assign(cr, uid, move, context=context) - return res - - def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): + def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @@ -2320,12 +2309,12 @@ class stock_move(osv.osv): quantity = move.product_qty uos_qty = quantity / move_qty * move.product_uos_qty - state = (move.state in ('confirm', 'assign') and move.state) or 'confirm' if quantity_rest > 0: default_val = { 'product_qty': quantity, 'product_uos_qty': uos_qty, + 'state': move.state, 'location_id': location_id or move.location_id.id, } if (not move.prodlot_id.id) and (move.product_id.track_production and location_id): @@ -2358,8 +2347,6 @@ class stock_move(osv.osv): for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]): message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(new_move.product_qty) + "' "+ _("quantity.") self.log(cr, uid, new_move.id, message) - - self.trigger_move_state(cr, uid, res, state, context=context) self.action_done(cr, uid, res) return res