[MERGE] merge lp:~openerp-dev/openobject-addons/trunk-stock_cancel_button_fix-cha
authorAjay Chauhan (OpenERP) <cha@tinyerp.com>
Fri, 21 Sep 2012 06:30:25 +0000 (12:00 +0530)
committerAjay Chauhan (OpenERP) <cha@tinyerp.com>
Fri, 21 Sep 2012 06:30:25 +0000 (12:00 +0530)
bzr revid: cha@tinyerp.com-20120921063025-q1z0lj1ida0ew975

1  2 
addons/stock/stock.py

diff --combined addons/stock/stock.py
@@@ -761,6 -761,15 +761,15 @@@ class stock_picking(osv.osv)
              self.pool.get('stock.move').force_assign(cr, uid, move_ids)
              wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
          return True
+     
+     def button_cancel(self, cr, uid, ids, *args):
+         """ Changes state of picking to cancel.
+         @return: True
+         """
+         wf_service = netsvc.LocalService("workflow")
+         for pick in self.browse(cr, uid, ids):
+             wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr)
+         return True
  
      def draft_force_assign(self, cr, uid, ids, *args):
          """ Confirms picking directly from draft state.
              for move in pick.move_lines:
                  if move.state not in ('cancel','done'):
                      return False
-                 if move.state=='done':
+                 if move.state=='done' and not move.scrapped:
                      ok = True
          return ok
  
              if not pick.move_lines:
                  return True
              for move in pick.move_lines:
-                 if move.state == 'done':
+                 if move.state == 'done' and not move.scrapped:
                      raise osv.except_osv(_('Error!'), _('You cannot cancel picking because stock move is in done state!'))
          return True
      def unlink(self, cr, uid, ids, context=None):
@@@ -1492,7 -1501,7 +1501,7 @@@ class stock_production_lot(osv.osv)
          'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type', '<>', 'service')]),
          'date': fields.datetime('Creation Date', required=True),
          'stock_available': fields.function(_get_stock, fnct_search=_stock_search, type="float", string="Available", select=True,
 -            help="Current quantity of products with this Production Lot Number available in company warehouses",
 +            help="Current quantity of products with this Serial Number available in company warehouses",
              digits_compute=dp.get_precision('Product Unit of Measure')),
          'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'),
          'company_id': fields.many2one('res.company', 'Company', select=True),
@@@ -1827,8 -1836,8 +1836,8 @@@ class stock_move(osv.osv)
          warning = {}
          if (location.usage == 'internal') and (product_qty > (amount_actual or 0.0)):
              warning = {
 -                'title': _('Insufficient Stock in Lot !'),
 -                'message': _('You are moving %.2f %s products but only %.2f %s available in this lot.') % (product_qty, uom.name, amount_actual, uom.name)
 +                'title': _('Insufficient Stock in Serial Number !'),
 +                'message': _('You are moving %.2f %s products but only %.2f %s available in this serial number.') % (product_qty, uom.name, amount_actual, uom.name)
              }
          return {'warning': warning}