Somesh Khare(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-bug-778428-skh into
lp:openobject-addons/6.0.
Requested reviews:
Priyesh (OpenERP) (pso-openerp)
Jay Vora (OpenERP) (jvo-openerp)
Related bugs:
Bug #778428 in OpenERP Addons: "inventory - qty should take care of the
production_lot"
https://bugs.launchpad.net/openobject-addons/+bug/778428
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bug-778428-skh/+merge/65965
Hello Sir,
[Fix]: Inventory - qty should take care of the production_lot.
Here in the fix the order of Physical Inventory's "General Information" tab is
according to the bug description ,
Change column order to : Location, Product, Production Lot, qty, uom
and the functionality also implemented according to the description of the bug.
Thanks,
SKH
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bug-778428-skh/+merge/65965
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-bug-778428-skh.
=== modified file 'stock/stock.py'
--- stock/stock.py 2011-06-24 10:57:25 +0000
+++ stock/stock.py 2011-06-27 11:30:15 +0000
@@ -2646,6 +2646,22 @@
'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
}
+ def _get_product_qty(self, cr, uid, location_id, product_id, uom=False, to_date=False):
+
+ amount = self.pool.get('stock.location')._product_get(cr, uid,\
+ location_id, [product_id], {'uom': uom, 'to_date': to_date})[product_id]
+
+ return amount
+ def _get_loc_qty(self, cr,uid,location_id, product_id, prod_lot_id, uom=False, to_date=False):
+ qty=0
+ lot_obj = self.pool.get('stock.production.lot')
+ lot_record = lot_obj.browse(cr, uid, prod_lot_id, context=None)
+
+ if product_id == lot_record.product_id.id:
+ qty = lot_record.stock_available
+
+ return qty
+
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
@@ -2657,10 +2673,34 @@
return {'value': {'product_qty': 0.0, 'product_uom': False}}
obj_product = self.pool.get('product.product').browse(cr, uid, product)
uom = uom or obj_product.uom_id.id
- amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom, 'to_date': to_date})[product]
+ amount = self._get_product_qty(cr, uid, location_id, product, uom=uom, to_date=to_date)
+
result = {'product_qty': amount, 'product_uom': uom}
return {'value': result}
+ def on_change_prod_lot(self, cr, uid, ids, location_id, product_id, prod_lot_id=False, context=None):
+ result = {}
+ qty = 0
+ lot_obj = self.pool.get('stock.production.lot')
+ if prod_lot_id:
+ lot_record = lot_obj.browse(cr, uid, prod_lot_id, context=context)
+ if product_id == lot_record.product_id.id:
+ qty = lot_record.stock_available
+ elif location_id and product_id:
+ qty = self._get_product_qty(cr, uid, location_id, product_id)
+
+ return {'value': {'product_qty': qty}}
+
+ def on_change_location(self, cr, uid, ids, location_id, product_id, prod_lot_id=False, context=None):
+ result = {}
+ qty = 0
+ if location_id and product_id and not prod_lot_id:
+ qty = self._get_product_qty(cr, uid, location_id, product_id)
+ elif location_id and product_id and prod_lot_id:
+ qty= self._get_loc_qty(cr,uid,location_id, product_id, prod_lot_id)
+ return {'value': {'product_qty': qty}}
+
+
stock_inventory_line()
#----------------------------------------------------------
=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml 2011-06-09 12:44:28 +0000
+++ stock/stock_view.xml 2011-06-27 11:30:15 +0000
@@ -116,11 +116,11 @@
<page string="General Informations">
<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 colspan="4" domain="[('usage','=','internal')]" name="location_id" on_change="on_change_location(location_id,product_id,prod_lot_id)"/>
<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','<>','service')]"/>
+ <field name="prod_lot_id" on_change="on_change_prod_lot(location_id,product_id,prod_lot_id)" groups="base.group_extended"/>
<field name="product_qty"/>
<field name="product_uom"/>
- <field name="prod_lot_id" groups="base.group_extended"/>
<button name="%(stock.action_view_stock_inventory_line_split)d"
string="Split inventory lines" groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize" states="draft,confirm"/>
_______________________________________________
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