[FIX]:Stock Inventory with date past

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

bzr revid: ksa@tinyerp.co.in-20101215115814-ybw9ra2rzo1zxgm2
This commit is contained in:
ksa (Open ERP)
2010-12-15 17:28:14 +05:30
parent f433391c59
commit 16f6a1eebc
2 changed files with 8 additions and 9 deletions
+5 -6
View File
@@ -1671,7 +1671,7 @@ class stock_move(osv.osv):
result['product_qty'] = product_uos_qty
return {'value': result}
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
loc_dest_id=False, address_id=False):
""" On change of product id, if finds UoM, UoS, quantity and UoS quantity.
@@ -2462,7 +2462,6 @@ class stock_inventory(osv.osv):
""" Finished the inventory
@return: True
"""
if context is None:
context = {}
move_obj = self.pool.get('stock.move')
@@ -2486,8 +2485,9 @@ 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)
product_context.update(uom=line.product_uom.id,date=inv.date)
amount = location_obj._product_get(cr, uid, line.location_id.id, [pid], product_context)[pid]
change = line.product_qty - amount
lot_id = line.prod_lot_id.id
if change:
@@ -2498,7 +2498,6 @@ class stock_inventory(osv.osv):
'product_uom': line.product_uom.id,
'prodlot_id': lot_id,
'date': inv.date,
'date': inv.date,
}
if change > 0:
value.update( {
@@ -2557,7 +2556,7 @@ class stock_inventory_line(osv.osv):
'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
}
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False):
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
""" Changes UoM and name if product_id changes.
@param location_id: Location id
@param product: Changed product_id
@@ -2569,7 +2568,7 @@ class stock_inventory_line(osv.osv):
if not uom:
prod = self.pool.get('product.product').browse(cr, uid, [product], {'uom': uom})[0]
uom = prod.uom_id.id
amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom})[product]
amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom, 'to_date': to_date})[product]
result = {'product_qty': amount, 'product_uom': uom}
return {'value': result}
+3 -3
View File
@@ -37,7 +37,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Stock Inventory Lines">
<field context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" select="1" domain="[('type','&lt;&gt;','service')]"/>
<field context="location=location_id,uom=product_uom,to_date=parent.date" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" select="1" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="prod_lot_id" groups="base.group_extended"/>
@@ -97,7 +97,7 @@
<field colspan="4" name="inventory_line_id" nolabel="1" widget="one2many_list">
<tree string="Products" editable="bottom">
<field colspan="4" domain="[('usage','=','internal')]" name="location_id"/>
<field context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" domain="[('type','&lt;&gt;','service')]"/>
<field context="location=location_id,uom=product_uom,to_date=parent.date" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="prod_lot_id" groups="base.group_extended"/>
@@ -109,7 +109,7 @@
<form string="Products ">
<field domain="[('usage','=','internal')]" name="location_id"/>
<newline/>
<field colspan="4" context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" domain="[('type','&lt;&gt;','service')]"/>
<field context="location=location_id,uom=product_uom,to_date=parent.date" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<group colspan="2" col="4">