Priyesh (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-10344-pso into 
lp:openobject-addons/6.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-10344-pso/+merge/66298

Hello,

Put restriction on quantity when processing quantity is greater than the move 
quantity on picking validation and splitting of move.

Thanks,
pso
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-10344-pso/+merge/66298
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-10344-pso.
=== modified file 'stock/stock.py'
--- stock/stock.py	2011-06-24 10:57:25 +0000
+++ stock/stock.py	2011-06-29 13:21:34 +0000
@@ -1184,6 +1184,10 @@
                 product_currency = partial_data.get('product_currency',False)
                 prodlot_id = partial_data.get('prodlot_id')
                 prodlot_ids[move.id] = prodlot_id
+                product_name = product_obj.browse(cr, uid, partial_data.get('product_id'), context=context).name
+                if product_qty > move.product_qty:
+                    raise osv.except_osv(_('Error'), _('Processing quantity %d for %s is larger than the available quantity %d!')\
+                                         %(product_qty, product_name, move.product_qty))
                 if move.product_qty == product_qty:
                     complete.append(move)
                 elif move.product_qty > product_qty:
@@ -2429,6 +2433,10 @@
             product_price = partial_data.get('product_price',0.0)
             product_currency = partial_data.get('product_currency',False)
             prodlot_ids[move.id] = partial_data.get('prodlot_id')
+            product_name = product_obj.browse(cr, uid, partial_data.get('product_id'), context=context).name
+            if product_qty > move.product_qty:
+                raise osv.except_osv(_('Error'), _('Processing quantity %d for %s is larger than the available quantity %d!')\
+                                     %(product_qty, product_name, move.product_qty))
             if move.product_qty == product_qty:
                 complete.append(move)
             elif move.product_qty > product_qty:

=== modified file 'stock/wizard/stock_move.py'
--- stock/wizard/stock_move.py	2011-06-17 06:37:36 +0000
+++ stock/wizard/stock_move.py	2011-06-29 13:21:34 +0000
@@ -20,6 +20,7 @@
 ##############################################################################
 
 from osv import fields, osv
+from tools.translate import _
 
 import decimal_precision as dp
 
@@ -251,8 +252,13 @@
                     lines = [l for l in data.line_exist_ids if l]
                 else:
                     lines = [l for l in data.line_ids if l]
+                total_move_qty = 0.0
                 for line in lines:
                     quantity = line.quantity
+                    total_move_qty += quantity
+                    if total_move_qty > move_qty:
+                        raise osv.except_osv(_('Error'), _('Processing quantity %d for %s is larger than the available quantity %d!')\
+                                     %(total_move_qty, move.product_id.name, move_qty))
                     if quantity <= 0 or move_qty == 0:
                         continue
                     quantity_rest -= quantity

=== modified file 'stock/wizard/stock_partial_move.py'
--- stock/wizard/stock_partial_move.py	2011-01-17 08:00:48 +0000
+++ stock/wizard/stock_partial_move.py	2011-06-29 13:21:34 +0000
@@ -202,7 +202,7 @@
             if not p_moves.get(move.id):
                 continue
             partial_datas['move%s' % (move.id)] = {
-                'product_id' : p_moves[move.id].id,
+                'product_id' : p_moves[move.id].product_id.id,
                 'product_qty' : p_moves[move.id].quantity,
                 'product_uom' :p_moves[move.id].product_uom.id,
                 'prodlot_id' : p_moves[move.id].prodlot_id.id,

=== modified file 'stock/wizard/stock_partial_picking.py'
--- stock/wizard/stock_partial_picking.py	2011-05-30 06:57:23 +0000
+++ stock/wizard/stock_partial_picking.py	2011-06-29 13:21:34 +0000
@@ -155,15 +155,15 @@
 
             for move in moves_list:
                 partial_datas['move%s' % (move.move_id.id)] = {
-                    'product_id': move.id, 
-                    'product_qty': move.quantity, 
-                    'product_uom': move.product_uom.id, 
-                    'prodlot_id': move.prodlot_id.id, 
+                    'product_id': move.product_id.id,
+                    'product_qty': move.quantity,
+                    'product_uom': move.product_uom.id,
+                    'prodlot_id': move.prodlot_id.id,
                 }
                 if (picking_type == 'in') and (move.product_id.cost_method == 'average'):
                     partial_datas['move%s' % (move.move_id.id)].update({
-                                                    'product_price' : move.cost, 
-                                                    'product_currency': move.currency.id, 
+                                                    'product_price' : move.cost,
+                                                    'product_currency': move.currency.id,
                                                     })
         pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
         return {'type': 'ir.actions.act_window_close'}

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to