From fa57fef4cb2e10d7468bf98a64ca16a004afdc29 Mon Sep 17 00:00:00 2001 From: Mathieu Vatel Date: Tue, 20 Mar 2012 19:24:57 +0100 Subject: [PATCH] Starting from the sale order go to the picking allowing to create automatically the picking from there --- stock_move_packaging/wizard/move_pack.py | 33 ++++++++++++----------- stock_tracking_extended/stock_tracking.py | 1 + 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/stock_move_packaging/wizard/move_pack.py b/stock_move_packaging/wizard/move_pack.py index 3a89ec875..c59aa82f4 100644 --- a/stock_move_packaging/wizard/move_pack.py +++ b/stock_move_packaging/wizard/move_pack.py @@ -66,33 +66,34 @@ class stock_move_packaging(osv.osv_memory): pick_type = 'in' elif type == 'customer': pick_type = 'out' - + date = time.strftime('%Y-%m-%d %H:%M:%S'), pick_id = picking_obj.create(cr, uid, { - 'type': pick_type, - 'auto_picking': 'draft', - 'company_id': self.pool.get('res.company')._company_default_get(cr, uid, 'stock.company', context=context), - 'address_id': obj.location_dest_id.address_id and obj.location_dest_id.address_id.id or False, - 'invoice_state': 'none', - 'date': time.strftime('%Y-%m-%d %H:%M:%S'), - 'state': 'done', - }) + 'type': pick_type, + 'auto_picking': 'draft', + 'company_id': self.pool.get('res.company')._company_default_get(cr, uid, 'stock.company', context=context), + 'address_id': obj.location_dest_id.address_id and obj.location_dest_id.address_id.id or False, + 'invoice_state': 'none', + 'date': date, + 'state': 'done', + }) child_packs = tracking_obj.hierarchy_ids(pack) for child_pack in child_packs: hist_id = history_obj.create(cr, uid, { - 'tracking_id': child_pack.id, - 'type': 'move', - 'location_id': child_pack.location_id.id, - 'location_dest_id': obj.location_dest_id.id, - }) - - + 'tracking_id': child_pack.id, + 'type': 'move', + 'location_id': child_pack.location_id.id, + 'location_dest_id': obj.location_dest_id.id, + }) for move in child_pack.current_move_ids: defaults = { 'location_id': move.location_dest_id.id, 'location_dest_id': obj.location_dest_id.id, 'picking_id': pick_id, + 'state': 'done', + 'date': date, + 'date_expected': date, } new_id = move_obj.copy(cr, uid, move.id, default=defaults, context=context) move_obj.write(cr, uid, [move.id], {'pack_history_id': hist_id, 'move_dest_id': new_id}) diff --git a/stock_tracking_extended/stock_tracking.py b/stock_tracking_extended/stock_tracking.py index 3639fa04c..e9ba9f33c 100644 --- a/stock_tracking_extended/stock_tracking.py +++ b/stock_tracking_extended/stock_tracking.py @@ -298,6 +298,7 @@ class stock_move(osv.osv): return super(stock_move,self).create(cr, uid, vals, context) stock_move() + class split_in_production_lot(osv.osv_memory): _inherit = "stock.move.split" _columns = {