diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 215dc25267c..33adf192dca 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -28,6 +28,7 @@ from openerp.osv import fields, osv from openerp.tools.float_utils import float_compare, float_round from openerp.tools.translate import _ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT +from openerp.exceptions import Warning from openerp import SUPERUSER_ID, api import openerp.addons.decimal_precision as dp from openerp.addons.procurement import procurement @@ -1047,11 +1048,20 @@ class stock_picking(osv.osv): # If we encounter an UoM that is smaller than the default UoM or the one already chosen, use the new one instead. product_uom = {} # Determines UoM used in pack operations + location_dest_id = None + location_id = None for move in [x for x in picking.move_lines if x.state not in ('done', 'cancel')]: if not product_uom.get(move.product_id.id): product_uom[move.product_id.id] = move.product_id.uom_id if move.product_uom.id != move.product_id.uom_id.id and move.product_uom.factor > product_uom[move.product_id.id].factor: product_uom[move.product_id.id] = move.product_uom + if not move.scrapped: + if location_dest_id and move.location_dest_id.id != location_dest_id: + raise Warning(_('The destination location must be the same for all the moves of the picking.')) + location_dest_id = move.location_dest_id.id + if location_id and move.location_id.id != location_id: + raise Warning(_('The source location must be the same for all the moves of the picking.')) + location_id = move.location_id.id pack_obj = self.pool.get("stock.quant.package") quant_obj = self.pool.get("stock.quant")