From d77621e770a700312b203925b21b640941b14acc Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 4 May 2011 18:49:35 +0530 Subject: [PATCH] [FIX]stock:Splitting moves doesnot warning if lot contains insufficient quantity of product lp bug: https://launchpad.net/bugs/771377 fixed bzr revid: ron@tinyerp.com-20110504131935-h2tq0rstselbiroc --- addons/stock/wizard/stock_move.py | 21 ++++++++++++++++++++- addons/stock/wizard/stock_move_view.xml | 8 ++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/addons/stock/wizard/stock_move.py b/addons/stock/wizard/stock_move.py index b075af80c7d..cb21803706f 100644 --- a/addons/stock/wizard/stock_move.py +++ b/addons/stock/wizard/stock_move.py @@ -20,6 +20,7 @@ ############################################################################## from osv import fields, osv +from tools.translate import _ import decimal_precision as dp @@ -280,7 +281,6 @@ class split_in_production_lot(osv.osv_memory): 'name': line.name, 'product_id': move.product_id.id}, context=context) - move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id, 'state':move.state}) update_val = {} @@ -306,6 +306,25 @@ class stock_move_split_lines_exist(osv.osv_memory): _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) + } + return {'warning': warning} stock_move_split_lines_exist() diff --git a/addons/stock/wizard/stock_move_view.xml b/addons/stock/wizard/stock_move_view.xml index baaa581b4f3..cfb562e2385 100644 --- a/addons/stock/wizard/stock_move_view.xml +++ b/addons/stock/wizard/stock_move_view.xml @@ -134,12 +134,12 @@ - - + +
- - + +