[FIX]: stock: Fixed wrong qty in stock move(posted inventory) when confirming inventory for the products which have earlier moves with production lot and we use the same prodlot

lp bug: https://launchpad.net/bugs/747379 fixed

bzr revid: rpa@tinyerp.com-20110408133212-zh6k36mgfexh6j0i
This commit is contained in:
Rucha (Open ERP)
2011-04-08 19:02:12 +05:30
parent 71a31da4b5
commit f7ee4987fc
2 changed files with 11 additions and 8 deletions
+10 -7
View File
@@ -248,6 +248,7 @@ class product_product(osv.osv):
date_str = "date<=%s"
date_values = [to_date]
prodlot_id = context.get('prodlot_id', False)
# TODO: perhaps merge in one query.
if date_values:
@@ -257,10 +258,11 @@ class product_product(osv.osv):
cr.execute(
'select sum(product_qty), product_id, product_uom '\
'from stock_move '\
'where location_id NOT IN %s'\
'and location_dest_id IN %s'\
'and product_id IN %s'\
'and state IN %s' + (date_str and 'and '+date_str+' ' or '') +''\
'where location_id NOT IN %s '\
'and location_dest_id IN %s '\
'and product_id IN %s '\
'' + (prodlot_id and ('and prodlot_id = ' + str(prodlot_id)) or '') + ' '\
'and state IN %s ' + (date_str and 'and '+date_str+' ' or '') +' '\
'group by product_id,product_uom',tuple(where))
results = cr.fetchall()
if 'out' in what:
@@ -268,10 +270,11 @@ class product_product(osv.osv):
cr.execute(
'select sum(product_qty), product_id, product_uom '\
'from stock_move '\
'where location_id IN %s'\
'where location_id IN %s '\
'and location_dest_id NOT IN %s '\
'and product_id IN %s'\
'and state in %s' + (date_str and 'and '+date_str+' ' or '') + ''\
'and product_id IN %s '\
'' + (prodlot_id and ('and prodlot_id = ' + str(prodlot_id)) or '') + ' '\
'and state in %s ' + (date_str and 'and '+date_str+' ' or '') + ' '\
'group by product_id,product_uom',tuple(where))
results2 = cr.fetchall()
uom_obj = self.pool.get('product.uom')
+1 -1
View File
@@ -2556,7 +2556,7 @@ class stock_inventory(osv.osv):
move_ids = []
for line in inv.inventory_line_id:
pid = line.product_id.id
product_context.update(uom=line.product_uom.id,date=inv.date)
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]
change = line.product_qty - amount