[IMP] change split signature and take into account for action_consume

bzr revid: jco@openerp.com-20140128154125-3j1rpc4w6maywcmt
This commit is contained in:
Josse Colpaert
2014-01-28 16:41:25 +01:00
parent 8ec0968f8d
commit 34b923a19e
3 changed files with 12 additions and 14 deletions
+2 -4
View File
@@ -920,14 +920,12 @@ class mrp_production(osv.osv):
if corresponding_move:
corresponding_move = corresponding_move[0]
default_values = {}
if main_production_move:
default_values = {'consumed_for': main_production_move}
if corresponding_move.product_qty > consume['product_qty']:
stock_mov_obj.action_consume(cr, uid, [corresponding_move.id], consume['product_qty'], corresponding_move.location_id.id,
restrict_lot_id = consume['lot_id'], default_values = default_values, context=context)
restrict_lot_id = consume['lot_id'], consumed_for = main_production_move, context=context)
else:
stock_mov_obj.action_consume(cr, uid, [corresponding_move.id], corresponding_move.product_qty, corresponding_move.location_id.id,
restrict_lot_id = consume['lot_id'], default_values = default_values, context=context)
restrict_lot_id = consume['lot_id'], consumed_for = main_production_move, context=context)
self.message_post(cr, uid, production_id, body=_("%s produced") % self._description, context=context)
self.signal_button_produce_done(cr, uid, [production_id])
+4 -3
View File
@@ -130,9 +130,10 @@ class StockMove(osv.osv):
ctx = context.copy()
if location_id:
ctx['source_location_id'] = location_id
res.append(self.split(cr, uid, move, move_qty - quantity_rest, restrict_lot_id=restrict_lot_id,
restrict_partner_id=restrict_partner_id, context=ctx))
#TODO need to add consumed_for here
new_mov = self.split(cr, uid, move, move_qty - quantity_rest, restrict_lot_id=restrict_lot_id,
restrict_partner_id=restrict_partner_id, context=ctx)
self.write(cr, uid, new_mov, {'consumed_for': consumed_for},context=context)
res.append(new_mov)
else:
res.append(move.id)
if location_id:
+6 -7
View File
@@ -1900,14 +1900,12 @@ class stock_move(osv.osv):
return res
def split(self, cr, uid, move, qty, restrict_lot_id=False, default_values = None, context=None):
def split(self, cr, uid, move, qty, restrict_lot_id=False, restrict_partner_id=False, context=None):
""" Splits qty from move move into a new move
:param move: browse record
:param qty: float. quantity to split (given in product UoM)
:param context: dictionay. can contains the special key 'source_location_id' in order to force the source location when copying the move
"""
if default_values is None:
default_values = {}
if move.product_qty <= qty or qty == 0:
return move.id
@@ -1920,9 +1918,7 @@ class stock_move(osv.osv):
if move.state in ('done', 'cancel'):
raise osv.except_osv(_('Error'), _('You cannot split a move done'))
defaults = default_values.copy()
defaults.update({
defaults = {
'product_uom_qty': uom_qty,
'product_uos_qty': uos_qty,
'state': move.state,
@@ -1930,7 +1926,8 @@ class stock_move(osv.osv):
'move_dest_id': False,
'reserved_quant_ids': [],
'restrict_lot_id': restrict_lot_id,
})
'restrict_partner_id': restrict_partner_id
}
if context.get('source_location_id'):
defaults['location_id'] = context['source_location_id']
new_move = self.copy(cr, uid, move.id, defaults)
@@ -1950,6 +1947,8 @@ class stock_move(osv.osv):
self.action_confirm(cr, uid, [new_move], context=context)
return new_move
class stock_inventory(osv.osv):
_name = "stock.inventory"
_description = "Inventory"