Atik Agewan(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-797772-aag into
lp:openobject-addons.
Requested reviews:
Atik Agewan(OpenERP) (aag-openerp)
Rucha (Open ERP) (rpa-openerp)
Related bugs:
Bug #797772 in OpenERP Addons: "fill inventory wizard computes wrong
quantities"
https://bugs.launchpad.net/openobject-addons/+bug/797772
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-797772-aag/+merge/64959
Hello
stock:Fill inventory wizard computes True quantities of Related stock.
Thanks
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-797772-aag/+merge/64959
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-797772-aag.
=== modified file 'stock/stock.py'
--- stock/stock.py 2011-05-30 16:21:43 +0000
+++ stock/stock.py 2011-06-22 05:36:55 +0000
@@ -2555,15 +2555,26 @@
# to perform the correct inventory corrections we need analyze stock location by
# location, never recursively, so we use a special context
product_context = dict(context, compute_child=False)
-
+ move_obj = self.pool.get('stock.move')
location_obj = self.pool.get('stock.location')
for inv in self.browse(cr, uid, ids, context=context):
move_ids = []
for line in inv.inventory_line_id:
pid = line.product_id.id
+ lot = line.prod_lot_id.id
product_context.update(uom=line.product_uom.id, date=inv.date, prodlot_id=line.prod_lot_id.id)
amount = location_obj._product_get(cr, uid, line.location_id.id, [pid], product_context)[pid]
-
+ if lot == False:
+ qty2 = 0.0
+ qty1 = 0.0
+ move_consume_ids = move_obj.search(cr, uid, [('location_id','=',line.location_id.id),('state','=','done'),('prodlot_id','=',False)],)
+ move_dest_ids = move_obj.search(cr, uid, [('location_dest_id','=',line.location_id.id),('state','=','done'),('prodlot_id','=',False)],)
+ for move_dest in move_obj.browse(cr, uid, move_dest_ids):
+ qty1 += move_dest.product_qty
+ for move_consum in move_obj.browse(cr, uid, move_consume_ids):
+ qty2 += move_consum.product_qty
+ amount = qty1 - qty2
+
change = line.product_qty - amount
lot_id = line.prod_lot_id.id
if change:
=== modified file 'stock/wizard/stock_fill_inventory.py'
--- stock/wizard/stock_fill_inventory.py 2011-05-02 18:46:43 +0000
+++ stock/wizard/stock_fill_inventory.py 2011-06-22 05:36:55 +0000
@@ -89,20 +89,28 @@
flag = False
for location in location_ids:
+ consume_qty = 0.0
+ qty = 0.0
datas = {}
res[location] = {}
move_ids = move_obj.search(cr, uid, [('location_dest_id','=',location),('state','=','done')], context=context)
-
+ move_consume_ids = move_obj.search(cr, uid, [('location_id','=',location),('state','=','done')], context=context)
+ for move2 in move_obj.browse(cr, uid, move_consume_ids, context=context):
+ consume_qty += move2.product_qty
+ consume_lot_id = move2.prodlot_id.id
+ consume_prod_id = move2.product_id.id
for move in move_obj.browse(cr, uid, move_ids, context=context):
lot_id = move.prodlot_id.id
prod_id = move.product_id.id
- qty = move.product_qty
-
- if datas.get((prod_id, lot_id)):
- qty += datas[(prod_id, lot_id)]['product_qty']
-
+ uom = move.product_uom.id
+ qty += move.product_qty
+ context.update({'uom':uom, 'prodlot_id':lot_id})
+ if lot_id:
+ qty = location_obj._product_get(cr, uid, location, [prod_id], context=context)[prod_id]
+ if move_consume_ids:
+ if consume_qty and consume_lot_id == lot_id and prod_id == consume_prod_id :
+ qty = qty - consume_qty
datas[(prod_id, lot_id)] = {'product_id': prod_id, 'location_id': location, 'product_qty': qty, 'product_uom': move.product_id.uom_id.id, 'prod_lot_id': lot_id}
-
if datas:
flag = True
res[location] = datas
_______________________________________________
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