1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2013 credativ ltd (<http://www.credativ.co.uk>). All Rights Reserved
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
22
from osv import osv, fields
23
from tools.translate import _
25
class stock_picking(osv.osv):
26
_inherit = 'stock.picking'
28
def action_assign(self, cr, uid, ids, context=None):
31
res = super(stock_picking, self).action_assign(cr, uid, ids, context)
32
if len(ids) == 1: # Checks to make sure we should show the wizard
33
pick = self.browse(cr, uid, ids)[0]
34
move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed']
35
if move_ids: # Some are still confirmed, generate and show the wizard
36
if context.get('skip_stock_unassign_wizard', False):
38
mod_obj = self.pool.get('ir.model.data')
39
wiz_obj = self.pool.get('stock.unassign.wizard')
40
wiz_id = wiz_obj.create(cr, uid, {'picking_id': pick.id,}, context=context)
41
model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'view_stock_unassign_wizard')], context=context)
42
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
44
'name': _('Stock Unassign Wizard'),
48
'res_model': 'stock.unassign.wizard',
51
'views': [(resource_id, 'form')],
53
'type': 'ir.actions.act_window',
59
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: