[IMP] stock: display translated selection value in message
authorMartin Trigaux <mat@openerp.com>
Fri, 19 Sep 2014 09:34:41 +0000 (11:34 +0200)
committerMartin Trigaux <mat@openerp.com>
Fri, 19 Sep 2014 09:34:47 +0000 (11:34 +0200)
When a user tried to delete a done or canceled picking, the error messages used to display the key of the selection field ('done' or 'cancel') which was surprising in other languages than English. This patch takes the string value of the selection field, keeping the context to get the translated value (opw 613068)

addons/stock/stock.py

index e3e7d53..14d60c2 100644 (file)
@@ -1204,7 +1204,9 @@ class stock_picking(osv.osv):
             context = {}
         for pick in self.browse(cr, uid, ids, context=context):
             if pick.state in ['done','cancel']:
-                raise osv.except_osv(_('Error!'), _('You cannot remove the picking which is in %s state!')%(pick.state,))
+                # retrieve the string value of field in user's language
+                state = dict(self.fields_get(cr, uid, context=context)['state']['selection']).get(pick.state, pick.state)
+                raise osv.except_osv(_('Error!'), _('You cannot remove the picking which is in %s state!')%(state,))
             else:
                 ids2 = [move.id for move in pick.move_lines]
                 ctx = context.copy()