From 6b1ec21cb617c1716d2e5297342df2ec3f369448 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 15 Jan 2014 14:37:19 +0100 Subject: [PATCH 01/40] [IMP] Make sure the quant has lot when we restrict lot in pickingless move bzr revid: jco@openerp.com-20140115133719-ivn71uatgd7gtin6 --- addons/mrp/stock.py | 5 +++-- addons/stock/stock.py | 6 +++--- addons/stock/wizard/stock_move_view.xml | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 94a0913ca29..37929d500a1 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -124,7 +124,7 @@ class StockMove(osv.osv): res.append(new_move) return res - def action_scrap(self, cr, uid, ids, product_qty, location_id, context=None): + def action_scrap(self, cr, uid, ids, product_qty, location_id, restrict_lot_id = False, context=None): """ Move the scrap/damaged product into scrap location @param product_qty: Scraped product quantity @param location_id: Scrap location @@ -133,7 +133,8 @@ class StockMove(osv.osv): res = [] production_obj = self.pool.get('mrp.production') 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) + new_moves = super(StockMove, self).action_scrap(cr, uid, [move.id], product_qty, location_id, + restrict_lot_id = restrict_lot_id, context=context) #If we are not scrapping our whole move, tracking and lot references must not be removed production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])]) for prod_id in production_ids: diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7c64cdab2d7..c94c7bbcfb6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -818,11 +818,11 @@ class stock_picking(osv.osv): return True def cancel_assign(self, cr, uid, ids, context=None): - """ Cancels picking and moves. + """ Cancels picking for the moves that are in the assigned state @return: True """ for pick in self.browse(cr, uid, ids, context=context): - move_ids = [x.id for x in pick.move_lines] + move_ids = [x.id for x in pick.move_lines if x not in ['done', 'cancel']] self.pool.get('stock.move').cancel_assign(cr, uid, move_ids, context=context) return True @@ -1812,7 +1812,7 @@ class stock_move(osv.osv): if qty > 0: self.check_tracking(cr, uid, move, move.restrict_lot_id.id, context=context) quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, qty, domain=main_domain, prefered_domain=prefered_domain, fallback_domain=fallback_domain, restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context) - quant_obj.quants_move(cr, uid, quants, move, context=context) + quant_obj.quants_move(cr, uid, quants, move, lot_id = move.restrict_lot_id.id, owner_id = move.restrict_partner_id.id, context=context) #unreserve the quants and make them available for other operations/moves quant_obj.quants_unreserve(cr, uid, move, context=context) diff --git a/addons/stock/wizard/stock_move_view.xml b/addons/stock/wizard/stock_move_view.xml index f8121a89ee9..0a567be651e 100644 --- a/addons/stock/wizard/stock_move_view.xml +++ b/addons/stock/wizard/stock_move_view.xml @@ -15,7 +15,8 @@ - +