_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()