From 9df9382f122f33cfe8af049389cc6a35a56e01ba Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 24 Feb 2014 12:21:12 +0100 Subject: [PATCH] [REF] stock: refactoring made during code review bzr revid: qdp-launchpad@openerp.com-20140224112112-go4uj37htcv3zo4k --- addons/stock/stock.py | 16 +--------------- addons/stock/test/packing.yml | 6 ++++++ addons/stock/test/packingneg.yml | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index c9e120db1df..2e6b2573290 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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: diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml index 23b072fbf92..7bd9a3870ac 100644 --- a/addons/stock/test/packing.yml +++ b/addons/stock/test/packing.yml @@ -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) - diff --git a/addons/stock/test/packingneg.yml b/addons/stock/test/packingneg.yml index 3f663394bbd..a36ba722527 100644 --- a/addons/stock/test/packingneg.yml +++ b/addons/stock/test/packingneg.yml @@ -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: