From f2ad1117713ed78cbd11ed586333c739573d881f Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Tue, 28 Jan 2014 17:02:43 +0100 Subject: [PATCH 1/2] [FIX]should not check for a lot_id on a package but should check when putting things in a package lp bug: https://launchpad.net/bugs/1269516 fixed bzr revid: csn@openerp.com-20140128160243-fchi86wqgkjjdkdv --- addons/stock/stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 899d253e70c..d01bfbd0bcd 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1112,9 +1112,13 @@ class stock_picking(osv.osv): Used in the barcode scanner UI and the normal interface as well. """ stock_operation_obj = self.pool.get('stock.pack.operation') package_obj = self.pool.get('stock.quant.package') + stock_move_obj = self.pool.get('stock.move') for picking_id in picking_ids: operation_ids = stock_operation_obj.search(cr, uid, [('picking_id', '=', picking_id), ('result_package_id', '=', False)], context=context) if operation_ids: + for operation in stock_operation_obj.browse(cr, uid, operation_ids, context=context): + for move in operation.linked_move_operation_ids: + stock_move_obj.check_tracking(cr, uid, move.move_id, operation.package_id.id if operation.package_id else operation.lot_id.id, context=None) package_id = package_obj.create(cr, uid, {}, context=context) stock_operation_obj.write(cr, uid, operation_ids, {'result_package_id': package_id}, context=context) return True @@ -1835,7 +1839,7 @@ class stock_move(osv.osv): fallback_domain = [('reservation_id', '=', False)] #first, process the move per linked operation first because it may imply some specific domains to consider for record in move.linked_move_operation_ids: - self.check_tracking(cr, uid, move, record.operation_id.lot_id.id, context=context) + self.check_tracking(cr, uid, move, record.operation_id.package_id.id if record.operation_id.package_id else record.operation_id.lot_id.id, context=context) dom = main_domain + self.pool.get('stock.move.operation.link').get_specific_domain(cr, uid, record, context=context) quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, record.qty, domain=dom, prefered_domain=prefered_domain, fallback_domain=fallback_domain, restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context) package_id = False From 05091a07310b23ea2380f75397adec0da87d8a8e Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 30 Jan 2014 11:07:19 +0100 Subject: [PATCH 2/2] [FIX] stock: context=None + some refactoring to shorten the code bzr revid: qdp-launchpad@openerp.com-20140130100719-tx7ujnoizcspcncv --- addons/stock/stock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index bb49732c557..dc20bf6eb5e 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1117,8 +1117,8 @@ class stock_picking(osv.osv): operation_ids = stock_operation_obj.search(cr, uid, [('picking_id', '=', picking_id), ('result_package_id', '=', False)], context=context) if operation_ids: for operation in stock_operation_obj.browse(cr, uid, operation_ids, context=context): - for move in operation.linked_move_operation_ids: - stock_move_obj.check_tracking(cr, uid, move.move_id, operation.package_id.id if operation.package_id else operation.lot_id.id, context=None) + for record in operation.linked_move_operation_ids: + stock_move_obj.check_tracking(cr, uid, record.move_id, operation.package_id.id or operation.lot_id.id, context=context) package_id = package_obj.create(cr, uid, {}, context=context) stock_operation_obj.write(cr, uid, operation_ids, {'result_package_id': package_id}, context=context) return True @@ -1852,7 +1852,7 @@ class stock_move(osv.osv): fallback_domain = [('reservation_id', '=', False)] #first, process the move per linked operation first because it may imply some specific domains to consider for record in move.linked_move_operation_ids: - self.check_tracking(cr, uid, move, record.operation_id.package_id.id if record.operation_id.package_id else record.operation_id.lot_id.id, context=context) + self.check_tracking(cr, uid, move, record.operation_id.package_id.id or record.operation_id.lot_id.id, context=context) dom = main_domain + self.pool.get('stock.move.operation.link').get_specific_domain(cr, uid, record, context=context) quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, record.qty, domain=dom, prefered_domain=prefered_domain, fallback_domain=fallback_domain, restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context) package_id = False