[FIX] mrp/stock

bzr revid: fp@tinyerp.com-20101231141242-c0wnddie6fsoav9p
This commit is contained in:
Fabien Pinckaers 2010-12-31 15:12:42 +01:00
parent db3ecb0649
commit 9b33bc24cc
4 changed files with 19 additions and 33 deletions

View File

@ -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:

View File

@ -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()

View File

@ -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":

View File

@ -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