[MERGE] lp:739181

bzr revid: qdp-launchpad@openerp.com-20110325142831-oygh7tepywprlu29
This commit is contained in:
Quentin (OpenERP)
2011-03-25 15:28:31 +01:00
3 changed files with 24 additions and 5 deletions
-1
View File
@@ -137,7 +137,6 @@ class StockMove(osv.osv):
wf_service = netsvc.LocalService("workflow")
for move in self.browse(cr, uid, ids, context=context):
new_moves = super(StockMove, self).action_scrap(cr, uid, [move.id], product_qty, location_id, context=context)
self.write(cr, uid, [move.id], {'prodlot_id': False, 'tracking_id': False})
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
for prod_id in production_ids:
wf_service.trg_validate(uid, 'mrp.production', prod_id, 'button_produce', cr)
+22 -2
View File
@@ -2238,6 +2238,7 @@ class stock_move(osv.osv):
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide a positive quantity to scrap!'))
res = []
to_done = []
for move in self.browse(cr, uid, ids, context=context):
move_qty = move.product_qty
uos_qty = quantity / move_qty * move.product_uos_qty
@@ -2253,13 +2254,32 @@ class stock_move(osv.osv):
if move.location_id.usage <> 'internal':
default_val.update({'location_id': move.location_dest_id.id})
new_move = self.copy(cr, uid, move.id, default_val)
res.append(new_move)
to_done.append(new_move)
if move.prodlot_id:
# Create a new move with the qty of scrapped move without prodlot
default_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,
'tracking_id': move.tracking_id.id,
'prodlot_id': False
}
newmove = self.copy(cr, uid, move.id, default_val)
res.append(new_move)
# Reduce amount of original move by qty of scrapped move
if move.product_qty - quantity > 0:
move.write({
'product_qty': move.product_qty - quantity,
'product_uos_qty': move.product_uos_qty - uos_qty,
})
res += [new_move]
product_obj = self.pool.get('product.product')
for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]):
self.log(cr, uid, move.id, "%s x %s %s" % (move.product_qty, name, _("were scrapped")))
self.action_done(cr, uid, res)
self.action_done(cr, uid, to_done, context=context)
return res
def action_split(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None):
+2 -2
View File
@@ -161,9 +161,9 @@ class stock_move_scrap(osv.osv_memory):
context = {}
move_obj = self.pool.get('stock.move')
move_ids = context['active_ids']
for data in self.read(cr, uid, ids):
for data in self.browse(cr, uid, ids):
move_obj.action_scrap(cr, uid, move_ids,
data['product_qty'], data['location_id'],
data.product_qty, data.location_id.id,
context=context)
return {'type': 'ir.actions.act_window_close'}