diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index b75b83e8fd9..db2a98b956b 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -90,7 +90,6 @@ Dashboard / Reports for Warehouse Management will include: 'views/report_stockinventory.xml', ], 'test': [ - 'test/wiseoperator.yml', 'test/inventory.yml', 'test/move.yml', 'test/procrule.yml', @@ -99,6 +98,7 @@ Dashboard / Reports for Warehouse Management will include: 'test/shipment.yml', 'test/packing.yml', 'test/packingneg.yml', + 'test/wiseoperator.yml', ], 'installable': True, 'application': True, diff --git a/addons/stock/stock.py b/addons/stock/stock.py index ab315b8163a..47a5d253969 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -3525,8 +3525,13 @@ class stock_package(osv.osv): parent = parent.parent_id quant_ids = self.get_content(cr, uid, [parent.id], context=context) quants = quant_obj.browse(cr, uid, quant_ids, context=context) - location_id = quants and quants[0].location_id.id or False - if not all([quant.location_id.id == location_id for quant in quants if quant.qty > 0]): + normal_quants = [x for x in quants if not x.propagated_from_id if x.qty > 0] + propagated_quants = [x for x in quants if x.propagated_from_id if x.qty > 0] + location_id = normal_quants and normal_quants[0].location_id.id or False + prop_loc_id = propagated_quants and propagated_quants[0].location_id.id or False + all_normal = all([quant.location_id.id == location_id for quant in normal_quants]) + all_propagated = all([quant.location_id.id == prop_loc_id for quant in propagated_quants]) + if not all_normal or not all_propagated: raise osv.except_osv(_('Error'), _('Everything inside a package should be in the same location')) return True diff --git a/addons/stock/test/wiseoperator.yml b/addons/stock/test/wiseoperator.yml index 7e0aa78a799..7b188ba7d67 100644 --- a/addons/stock/test/wiseoperator.yml +++ b/addons/stock/test/wiseoperator.yml @@ -49,7 +49,7 @@ - Make a delivery order of 5 pieces to the customer - - !record {model: stock.picking, id: delivery_order1}: + !record {model: stock.picking, id: delivery_order_wise1}: name: outgoing picking partner_id: base.res_partner_4 picking_type_id: stock.picking_type_out @@ -62,13 +62,13 @@ Assign and confirm - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('delivery_order1')], context=context) - self.action_assign(cr, uid, [ref('delivery_order1')]) - self.do_prepare_partial(cr, uid, [ref('delivery_order1')]) + self.action_confirm(cr, uid, [ref('delivery_order_wise1')], context=context) + self.action_assign(cr, uid, [ref('delivery_order_wise1')]) + self.do_prepare_partial(cr, uid, [ref('delivery_order_wise1')]) - Make a delivery order of 5 pieces to the customer - - !record {model: stock.picking, id: delivery_order2}: + !record {model: stock.picking, id: delivery_order_wise2}: name: outgoing picking partner_id: base.res_partner_4 picking_type_id: stock.picking_type_out @@ -81,16 +81,16 @@ Assign and confirm - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('delivery_order2')], context=context) - self.action_assign(cr, uid, [ref('delivery_order2')]) - self.do_prepare_partial(cr, uid, [ref('delivery_order2')]) + self.action_confirm(cr, uid, [ref('delivery_order_wise2')], context=context) + self.action_assign(cr, uid, [ref('delivery_order_wise2')]) + self.do_prepare_partial(cr, uid, [ref('delivery_order_wise2')]) - The operator is a wise guy and decides to do the opposite as OpenERP proposes. He uses the products reserved on picking 1 on picking 2 and vice versa - !python {model: stock.picking}: | stock_pack = self.pool.get('stock.pack.operation') - picking1 = self.browse(cr, uid, ref('delivery_order1')) - picking2 = self.browse(cr, uid, ref('delivery_order2')) + picking1 = self.browse(cr, uid, ref('delivery_order_wise1')) + picking2 = self.browse(cr, uid, ref('delivery_order_wise2')) pack_ids1 = [x.id for x in picking1.pack_operation_ids] pack_ids2 = [x.id for x in picking2.pack_operation_ids] stock_pack.write(cr, uid, pack_ids1, {'picking_id': picking2.id}) @@ -100,7 +100,7 @@ Process this picking - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('delivery_order1')], context=context) + self.do_transfer(cr, uid, [ref('delivery_order_wise1')], context=context) - Check a negative quant was created by this picking - @@ -111,7 +111,7 @@ Process the second picking - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('delivery_order2')], context=context) + self.do_transfer(cr, uid, [ref('delivery_order_wise2')], context=context) - Check all quants are in Customers and there are no negative quants anymore -