[MERGE] stock: constraint on package's location adapted to suit negative quants + yaml test wiseoperator.yml now use its own xml ids

bzr revid: qdp-launchpad@openerp.com-20140417151101-uvrq3k9bu50ickc3
This commit is contained in:
Quentin (OpenERP) 2014-04-17 17:11:01 +02:00
commit 58d6fd3c3e
3 changed files with 20 additions and 15 deletions

View File

@ -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,

View File

@ -3530,8 +3530,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

View File

@ -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
-