[FIX] stock: prevents multiple source/destination locations for the moves of the same picking
opw-640414
This commit is contained in:
parent
716fec913a
commit
9fe2e04c0d
|
@ -28,6 +28,7 @@ from openerp.osv import fields, osv
|
||||||
from openerp.tools.float_utils import float_compare, float_round
|
from openerp.tools.float_utils import float_compare, float_round
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
|
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
|
||||||
|
from openerp.exceptions import Warning
|
||||||
from openerp import SUPERUSER_ID, api
|
from openerp import SUPERUSER_ID, api
|
||||||
import openerp.addons.decimal_precision as dp
|
import openerp.addons.decimal_precision as dp
|
||||||
from openerp.addons.procurement import procurement
|
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.
|
# 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
|
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')]:
|
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):
|
if not product_uom.get(move.product_id.id):
|
||||||
product_uom[move.product_id.id] = move.product_id.uom_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:
|
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
|
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")
|
pack_obj = self.pool.get("stock.quant.package")
|
||||||
quant_obj = self.pool.get("stock.quant")
|
quant_obj = self.pool.get("stock.quant")
|
||||||
|
|
Loading…
Reference in New Issue