← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/6.0-opw-4972-ach into lp:openobject-addons/6.0

 

Anup(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/6.0-opw-4972-ach into lp:openobject-addons/6.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)
Related bugs:
  Bug #747341 in OpenERP Addons: "[6.0 - trunk] MO : missing production lot during partial consumption"
  https://bugs.launchpad.net/openobject-addons/+bug/747341

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-4972-ach/+merge/59021

Hello,

   This fixes the issue with production lot when partially consuming in the manufacturing Orders.

Thanks.


-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-4972-ach/+merge/59021
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/6.0-opw-4972-ach.
=== modified file 'stock/stock.py'
--- stock/stock.py	2011-04-18 05:13:22 +0000
+++ stock/stock.py	2011-04-26 06:34:30 +0000
@@ -2356,7 +2356,8 @@
                 }
                 if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
                     # IF product has checked track for production lot, move lines will be split by 1
-                    res += self.action_split(cr, uid, [move.id], quantity, split_by_qty=1, context=context)
+                    split_by_qty = context.get('product_qty') or 1
+                    res += self.action_split(cr, uid, [move.id], quantity, split_by_qty=split_by_qty, context=context)
                 else:
                     current_move = self.copy(cr, uid, move.id, default_val)
                     res += [current_move]
@@ -2369,7 +2370,8 @@
                 quantity_rest = quantity
                 uos_qty_rest =  uos_qty
                 if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
-                    res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
+                    split_by_qty = context.get('product_qty') or 1
+                    res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=split_by_qty, context=context)
                 else:
                     res += [move.id]
                     update_val = {

=== modified file 'stock/wizard/stock_move.py'
--- stock/wizard/stock_move.py	2011-04-01 05:25:48 +0000
+++ stock/wizard/stock_move.py	2011-04-26 06:34:30 +0000
@@ -23,6 +23,8 @@
 
 import decimal_precision as dp
 
+from tools.translate import _
+
 class stock_move_track(osv.osv_memory):
     _name = "stock.move.track"
     _description = "Track moves"
@@ -60,7 +62,8 @@
         'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
         'product_qty': fields.float('Quantity', required=True),
         'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
-        'location_id': fields.many2one('stock.location', 'Location', required=True)
+        'location_id': fields.many2one('stock.location', 'Location', required=True),
+        'prod_lot_id': fields.many2one('stock.production.lot','Production Lot')
     }
 
     def default_get(self, cr, uid, fields, context=None):
@@ -84,6 +87,8 @@
             res.update({'product_qty': move.product_qty})
         if 'location_id' in fields:
             res.update({'location_id': move.location_id.id})
+        if 'prod_lot_id' in fields:
+            res.update({'prod_lot_id': move.prodlot_id.id})
 
         return res
 
@@ -100,10 +105,25 @@
             context = {}
         move_obj = self.pool.get('stock.move')
         move_ids = context['active_ids']
-        for data in self.read(cr, uid, ids):
-            move_obj.action_consume(cr, uid, move_ids,
-                             data['product_qty'], data['location_id'],
+        stock_moves = move_obj.browse(cr,uid,move_ids)
+        data = self.browse(cr, uid, ids[0])
+        for stock_move in stock_moves:
+            
+            if stock_move.product_qty<data.product_qty:
+                raise osv.except_osv(_('User Error!'),_('Can not consume more quantity of products than available!'))
+            
+            if data.product_id.track_production:
+                if not data.prod_lot_id:
+                    raise osv.except_osv(_('User Error!'),_('Select a Production Lot to Track!'))
+                context.update({'product_qty':data.product_qty})
+            
+            if stock_move.prodlot_id != data.prod_lot_id:
+                move_obj.write(cr, uid, [stock_move.id], {'prodlot_id':data.prod_lot_id.id}, context=context)
+                            
+            move_obj.action_consume(cr, uid, [stock_move.id],
+                             data.product_qty, data.location_id.id,
                              context=context)
+            
         return {'type': 'ir.actions.act_window_close'}
 
 stock_move_consume()

=== modified file 'stock/wizard/stock_move_view.xml'
--- stock/wizard/stock_move_view.xml	2011-01-14 00:11:01 +0000
+++ stock/wizard/stock_move_view.xml	2011-04-26 06:34:30 +0000
@@ -43,6 +43,7 @@
                     <field name="location_id" colspan="4" />
                     <field name="product_qty" colspan="2"/>
                     <field name="product_uom" nolabel="1" readonly="1"/>
+                    <field name="prod_lot_id" attrs="{'required':[('product_id.track_production','=',True)]}" domain="[('product_id','=',product_id)]"/>
                     <newline/>
                     <separator string="" colspan="4" />
                     <label string="" colspan="2" />


Follow ups