[merge
authorFabien Pinckaers <fp@tinyerp.com>
Sat, 17 Sep 2011 12:35:05 +0000 (14:35 +0200)
committerFabien Pinckaers <fp@tinyerp.com>
Sat, 17 Sep 2011 12:35:05 +0000 (14:35 +0200)
bzr revid: fp@tinyerp.com-20110917123505-y1vkq04bad7ja10s

1  2 
addons/stock/wizard/stock_move.py

@@@ -306,6 -306,25 +306,25 @@@ class stock_move_split_lines_exist(osv.
      _defaults = {
          'quantity': 1.0,
      }
+     
+     def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_id=False, 
+                         product_qty=False, uom_id=False, context=None):
+         if not prodlot_id or not product_id:
+             return {}
+         prodlot_obj = self.pool.get('stock.production.lot')
+         product_obj = self.pool.get('product.product')
+         uom_obj = self.pool.get('product.uom')
+         uom = uom_obj.browse(cr, uid, uom_id, context=context)
+         product_uom = product_obj.browse(cr, uid, product_id, context=context).uom_id
+         warning = {}
+         lot_avail_qty = prodlot_obj.browse(cr, uid, prodlot_id, context=context)
+         quantity = uom_obj._compute_qty_obj(cr, uid, product_uom, lot_avail_qty.stock_available, uom, context=context)
+         if product_qty > quantity:
+             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, quantity, uom.name)
 -                        }
++                'title': _('Wrong lot number !'),
++                'message': _('You are moving %.2f %s products but only %.2f %s are available in this lot.') % (product_qty, uom.name, quantity, uom.name)
++            }
+         return {'warning': warning}
  
  stock_move_split_lines_exist()