diff --git a/addons/mrp/wizard/wizard_track_line.py b/addons/mrp/wizard/wizard_track_line.py index 26236c55e13..0866212549a 100644 --- a/addons/mrp/wizard/wizard_track_line.py +++ b/addons/mrp/wizard/wizard_track_line.py @@ -48,6 +48,13 @@ fields = { } } +def _check_picking(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + move_obj = pool.get('stock.move').browse(cr, uid, data['id']) + if not move_obj.picking_id: + raise wizard.except_wizard(_('Caution!'), _('Before splitting the production lots,make sure this move has a Picking attached !\nYou must save the move before performing this operation.')) + return data['form'] + def _track_lines(self, cr, uid, data, context): move_id = data['id'] @@ -115,7 +122,7 @@ def _track_lines(self, cr, uid, data, context): class wizard_track_move(wizard.interface): states = { 'init': { - 'actions': [], + 'actions': [_check_picking], 'result': {'type': 'form', 'arch': track_form, 'fields': fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('track', 'Ok', 'gtk-ok')]}, }, 'track': { diff --git a/addons/stock/wizard/wizard_track_line.py b/addons/stock/wizard/wizard_track_line.py index 79c105b962b..9576a9cb2f0 100644 --- a/addons/stock/wizard/wizard_track_line.py +++ b/addons/stock/wizard/wizard_track_line.py @@ -48,6 +48,13 @@ fields = { } } +def _check_picking(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + move_obj = pool.get('stock.move').browse(cr, uid, data['id']) + if not move_obj.picking_id: + raise wizard.except_wizard(_('Caution!'), _('Before splitting the production lots,make sure this move has a Picking attached !\nYou must save the move before performing this operation.')) + return data['form'] + def _track_lines(self, cr, uid, data, context): move_id = data['id'] @@ -116,7 +123,7 @@ def _track_lines(self, cr, uid, data, context): class wizard_track_move(wizard.interface): states = { 'init': { - 'actions': [], + 'actions': [_check_picking], 'result': {'type': 'form', 'arch': track_form, 'fields': fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('track', 'Ok', 'gtk-ok')]}, }, 'track': {