Rohan Nayani(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-751222-ron into 
lp:openobject-addons.

Requested reviews:
  Rohan Nayani(Open ERP) (ron-tinyerp)
  qdp (OpenERP) (qdp)
  Rucha (Open ERP) (rpa-openerp)
Related bugs:
  Bug #751222 in OpenERP Addons: "[6.0 - trunk] partial stock move wizard bugs 
: uom, new lines, production lot attrs"
  https://bugs.launchpad.net/openobject-addons/+bug/751222

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-751222-ron/+merge/57112

https://bugs.launchpad.net/openobject-addons/+bug/751222
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-751222-ron/+merge/57112
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-751222-ron.
=== modified file 'stock/stock.py'
--- stock/stock.py	2011-10-11 14:03:35 +0000
+++ stock/stock.py	2011-11-10 07:02:27 +0000
@@ -1167,10 +1167,8 @@
         wf_service = netsvc.LocalService("workflow")
         for pick in self.browse(cr, uid, ids, context=context):
             new_picking = None
-            complete, too_many, too_few = [], [], []
-            move_product_qty = {}
-            prodlot_ids = {}
-            product_avail = {}
+            complete, too_few = [], []
+            move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {}, {}, {}, {}, {}
             for move in pick.move_lines:
                 if move.state in ('done', 'cancel'):
                     continue
@@ -1182,13 +1180,12 @@
                 product_currency = partial_data.get('product_currency',False)
                 prodlot_id = partial_data.get('prodlot_id')
                 prodlot_ids[move.id] = prodlot_id
-                if move.product_qty == product_qty:
+                product_uoms[move.id] = product_uom
+                partial_qty[move.id] = uom_obj._compute_qty(cr, uid, product_uoms[move.id], product_qty, move.product_uom.id)
+                if move.product_qty == partial_qty[move.id]:
                     complete.append(move)
-                elif move.product_qty > product_qty:
+                else:
                     too_few.append(move)
-                else:
-                    too_many.append(move)
-
                 # Average price computation
                 if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
                     product = product_obj.browse(cr, uid, move.product_id.id)
@@ -1225,7 +1222,6 @@
 
             for move in too_few:
                 product_qty = move_product_qty[move.id]
-
                 if not new_picking:
                     new_picking = self.copy(cr, uid, pick.id,
                             {
@@ -1241,37 +1237,26 @@
                             'state': 'assigned',
                             'move_dest_id': False,
                             'price_unit': move.price_unit,
+                            'product_uom': product_uoms[move.id]
                     }
                     prodlot_id = prodlot_ids[move.id]
                     if prodlot_id:
                         defaults.update(prodlot_id=prodlot_id)
                     move_obj.copy(cr, uid, move.id, defaults)
-
                 move_obj.write(cr, uid, [move.id],
                         {
-                            'product_qty' : move.product_qty - product_qty,
-                            'product_uos_qty':move.product_qty - product_qty, #TODO: put correct uos_qty
+                            'product_qty' : move.product_qty - partial_qty[move.id],
+                            'product_uos_qty': move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
                         })
 
             if new_picking:
                 move_obj.write(cr, uid, [c.id for c in complete], {'picking_id': new_picking})
             for move in complete:
-                if prodlot_ids.get(move.id):
-                    move_obj.write(cr, uid, [move.id], {'prodlot_id': prodlot_ids[move.id]})
-            for move in too_many:
-                product_qty = move_product_qty[move.id]
-                defaults = {
-                    'product_qty' : product_qty,
-                    'product_uos_qty': product_qty, #TODO: put correct uos_qty
-                }
-                prodlot_id = prodlot_ids.get(move.id)
-                if prodlot_ids.get(move.id):
-                    defaults.update(prodlot_id=prodlot_id)
-                if new_picking:
-                    defaults.update(picking_id=new_picking)
+                defaults = {'product_uom': product_uoms[move.id], 'product_qty': move_product_qty[move.id]}
+                if prodlot_ids.get(move.id):
+                    defaults.update({'prodlot_id': prodlot_ids[move.id]})
                 move_obj.write(cr, uid, [move.id], defaults)
 
-
             # At first we confirm the new picking (if necessary)
             if new_picking:
                 wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)

=== modified file 'stock/wizard/stock_partial_picking.py'
--- stock/wizard/stock_partial_picking.py	2011-11-09 16:23:50 +0000
+++ stock/wizard/stock_partial_picking.py	2011-11-10 07:02:27 +0000
@@ -22,12 +22,25 @@
 import time
 from osv import fields, osv
 from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
+from tools.translate import _
 
 class stock_partial_picking_line(osv.TransientModel):
+
+    def _tracking(self, cursor, user, ids, name, arg, context=None):
+        res = {}
+        for tracklot in self.browse(cursor, user, ids, context=context):
+            tracking = False
+            if (tracklot.move_id.picking_id.type == 'in' and tracklot.product_id.track_incoming == True) or \
+                (tracklot.move_id.picking_id.type == 'out' and tracklot.product_id.track_outgoing == True):
+                tracking = True
+            res[tracklot.id] = tracking
+        return res
+
+
     _name = "stock.partial.picking.line"
     _rec_name = 'product_id'
     _columns = {
-        'product_id' : fields.many2one('product.product', string="Product", required=True, ondelete='CASCADE'),
+        'product_id' : fields.many2one('product.product', string="Product", required=True, readonly=True, ondelete='CASCADE'),
         'quantity' : fields.float("Quantity", required=True),
         'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True, ondelete='CASCADE'),
         'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot', ondelete='CASCADE'),
@@ -38,6 +51,7 @@
         'update_cost': fields.boolean('Need cost update'),
         'cost' : fields.float("Cost", help="Unit Cost for this product line"),
         'currency' : fields.many2one('res.currency', string="Currency", help="Currency in which Unit cost is expressed", ondelete='CASCADE'),
+        'tracking': fields.function(_tracking, method=True, string='Tracking', type='boolean'), 
     }
 
 class stock_partial_picking(osv.osv_memory):
@@ -103,13 +117,29 @@
         assert len(ids) == 1, 'Partial picking processing may only be done one at a time'
         stock_picking = self.pool.get('stock.picking')
         stock_move = self.pool.get('stock.move')
+        uom_obj = self.pool.get('product.uom')
         partial = self.browse(cr, uid, ids[0], context=context)
         partial_data = {
             'delivery_date' : partial.date
         }
         picking_type = partial.picking_id.type
         for move in partial.move_ids:
+            move_uom = move.move_id.product_uom
+            process_uom = move.product_uom
             move_id = move.move_id.id
+
+            #Quantiny must be Positive
+            if move.quantity <= 0:
+                raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
+            #Pikcing move product UOM factor must be bigger with respective wizard move product uom factor
+            if move_uom.factor < process_uom.factor:
+                raise osv.except_osv(_('Warning'), _('You can not process in UOM "%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
+            #Compute the wizard Quantity for respective move. 
+            toprocess = uom_obj._compute_qty(cr, uid, process_uom.id, move.quantity, move_uom.id)
+            #Compare wizard Quantity with respective picking move quantity if wizard move quantity bigger then it's giving warning.
+            if toprocess > move.move_id.product_qty:
+                raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (move.quantity, process_uom.name, move.move_id.product_qty, move_uom.name))
+
             if not move_id:
                 seq_obj_name =  'stock.picking.' + picking_type
                 move_id = stock_move.create(cr,uid,{'name' : self.pool.get('ir.sequence').get(cr, uid, seq_obj_name),

=== modified file 'stock/wizard/stock_partial_picking_view.xml'
--- stock/wizard/stock_partial_picking_view.xml	2011-10-02 17:31:16 +0000
+++ stock/wizard/stock_partial_picking_view.xml	2011-11-10 07:02:27 +0000
@@ -38,7 +38,8 @@
                     <field name="product_uom" />
                     <field name="location_id" />
                     <field name="location_dest_id" />
-                    <field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
+                    <field name="tracking" invisible="1"/>
+                    <field name="prodlot_id" domain="[('product_id', '=', product_id)]" attrs="{'required':[('tracking','=',True)]}" groups="base.group_extended" />
                     <field name="update_cost" invisible="1"/>
                     <field name="cost" attrs="{'invisible': [('update_cost','=', False)]}"/>
                     <field name="currency" attrs="{'invisible': [('update_cost','=', False)]}"/>
@@ -56,7 +57,8 @@
                     <field name="product_uom" />
                     <field name="location_id" />
                     <field name="location_dest_id" />
-                    <field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
+                    <field name="tracking" invisible="1"/>
+                    <field name="prodlot_id" domain="[('product_id', '=', product_id)]" attrs="{'required':[('tracking','=',True)]}" groups="base.group_extended" />
                     <field name="update_cost" invisible="1"/>
                     <field name="cost" attrs="{'invisible': [('update_cost','=', False)]}"/>
                     <field name="currency" attrs="{'invisible': [('update_cost','=', False)]}"/>

_______________________________________________
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