[REF] stock: refactoring made during code review
bzr revid: qdp-launchpad@openerp.com-20140224112112-go4uj37htcv3zo4k
This commit is contained in:
+1
-15
@@ -3489,7 +3489,6 @@ class stock_pack_operation(osv.osv):
|
||||
self.recompute_rem_qty_from_operation(cr, uid, [res_id], context=context)
|
||||
return res_id
|
||||
|
||||
|
||||
def recompute_rem_qty_from_operation(self, cr, uid, op_ids, context=None):
|
||||
def _create_link_for_product(product_id, qty):
|
||||
qty_to_assign = qty
|
||||
@@ -3502,19 +3501,6 @@ class stock_pack_operation(osv.osv):
|
||||
if qty_to_assign <= 0:
|
||||
break
|
||||
|
||||
def _check_package_child_of(quant_pack, ops_pack):
|
||||
if not quant_pack and not ops_pack:
|
||||
return True
|
||||
if not quant_pack or not ops_pack:
|
||||
return False
|
||||
check = False
|
||||
check_pack = quant_pack
|
||||
while not check and check_pack:
|
||||
if check_pack.id == ops_pack.id:
|
||||
check = True
|
||||
check_pack = quant_pack.parent_id
|
||||
return check
|
||||
|
||||
def _check_quants_reserved(ops):
|
||||
if ops.package_id and not ops.product_id:
|
||||
for quant in quant_obj.browse(cr, uid, package_obj.get_content(cr, uid, [ops.package_id.id]), context=context):
|
||||
@@ -3530,7 +3516,7 @@ class stock_pack_operation(osv.osv):
|
||||
for quant in move.reserved_quant_ids:
|
||||
if not qty > 0:
|
||||
break
|
||||
bool = _check_package_child_of(quant.package_id, ops.package_id)
|
||||
bool = bool(pack_obj.search(cr, uid, [('id', 'child_of', [ops.package_id.id]), ('id', '=', quants.package_id.id)], context=context)
|
||||
bool = bool and ((ops.lot_id and ops.lot_id.id == quant.lot_id.id) or not ops.lot_id)
|
||||
bool = bool and (ops.owner_id.id == quant.owner_id.id)
|
||||
if bool:
|
||||
|
||||
@@ -139,6 +139,12 @@
|
||||
backorder_ids = self.search(cr, uid, [('backorder_id', '=', ref('delivery_order1'))], context=context)
|
||||
assert backorder_ids, "Backorder should have been created"
|
||||
self.do_prepare_partial(cr, uid, backorder_ids, context=context)
|
||||
picking = self.browse(cr, uid backorder_ids[0])
|
||||
assert len(picking.pack_operation_ids) == 2, "Wrong number of pack operation"
|
||||
assert picking.pack_operation_ids[0].produc_qty == 100, "Wrong quantity in pack operation"
|
||||
assert picking.pack_operation_ids[0].package_id.name == 'Pallet 2', "Wrong pallet in pack operation"
|
||||
assert picking.pack_operation_ids[1].produc_qty == 50, "Wrong quantity in pack operation"
|
||||
assert picking.pack_operation_ids[1].package_id.name == 'Pallet 3', "Wrong pallet in pack operation"
|
||||
self.action_assign(cr, uid, backorder_ids, context=context)
|
||||
self.do_transfer(cr, uid, backorder_ids, context=context)
|
||||
-
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
elif rec.lot_id.name == 'Lot neg' and rec.location_id.id == ref('stock_location_customers'):
|
||||
assert ((rec.qty == 20 or rec.qty == 120) and not rec.package_id), "Should have 140 pieces (120+20) in customer location from pallet 2 and lot A"
|
||||
elif rec.package_id.name == 'Palneg 3' and rec.location_id.id == ref('stock_location_stock'):
|
||||
assert rec.qty == 50 or rec.qty == 20 or rec.qty == 30, "Should have 30 and 20 pieces in stock on pallet 3"
|
||||
assert rec.qty == 50, "Should have 50 pieces in stock on pallet 3"
|
||||
elif not rec.package_id and not rec.lot_id and rec.location_id.id == ref('stock_location_customers'):
|
||||
assert rec.qty == 10, "Should have 10 pieces in customer location from pallet 3"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user