From 516d89069f0a7f0767cd4ac9fdf9c89a61661d30 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 22 Dec 2010 14:22:18 +0530 Subject: [PATCH] [ADD] ADD Field Lot id in wizard to change Product Quantity from Product form View bzr revid: ron@tinyerp.com-20101222085218-dukwbse1bt5yu2z5 --- .../stock/wizard/stock_change_product_qty.py | 35 +++++++++++++------ .../wizard/stock_change_product_qty_view.xml | 4 +++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index 4e437eef815..1d97f9f2072 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -27,8 +27,10 @@ class stock_change_product_qty(osv.osv_memory): _name = "stock.change.product.qty" _description = "Change Product Quantity" _columns = { - 'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'), - 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", domain="[('usage', '=', 'internal')]"), + 'product_id' : fields.many2one('product.product', 'Product'), + 'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'), + 'prodlot_id': fields.many2one('stock.production.lot', 'Lot Number',domain="[('product_id','=',product_id)]"), + 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", domain="[('usage', '=', 'internal')]"), } def default_get(self, cr, uid, fields, context): @@ -40,10 +42,14 @@ class stock_change_product_qty(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ + product_id = context and context.get('active_id', False) or False + prod_obj =self.pool.get('product.product') res = super(stock_change_product_qty, self).default_get(cr, uid, fields, context=context) if 'new_quantity' in fields: res.update({'new_quantity': 1}) + if 'product_id' in fields: + res.update({'product_id': product_id}) return res def change_product_qty(self, cr, uid, ids, context=None): @@ -70,18 +76,27 @@ class stock_change_product_qty(osv.osv_memory): for data in self.browse(cr, uid, ids, context=context): inventory_id = inventry_obj.create(cr , uid, {'name': _('INV: ') + str(res_original.name)}, context=context) line_data ={ - 'inventory_id' : inventory_id, - 'product_qty' : data.new_quantity, - 'location_id' : data.location_id.id, - 'product_id' : rec_id, - 'product_uom' : res_original.uom_id.id, + 'inventory_id' : inventory_id, + 'product_qty' : data.new_quantity, + 'location_id' : data.location_id.id, + 'product_id' : rec_id, + 'product_uom' : res_original.uom_id.id, + 'prod_lot_id' : data.prodlot_id.id } line_id = inventry_line_obj.create(cr , uid, line_data, context=context) - + inventry_obj.action_confirm(cr, uid, [inventory_id], context=context) inventry_obj.action_done(cr, uid, [inventory_id], context=context) - - return {} + + return { + 'domain': "[('id','=',inventory_id])]", + 'name' : _('Physical Inventories'), + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'stock.inventory', + 'context': context, + 'type': 'ir.actions.act_window', + } stock_change_product_qty() diff --git a/addons/stock/wizard/stock_change_product_qty_view.xml b/addons/stock/wizard/stock_change_product_qty_view.xml index 927f3e91f80..01d46ff5780 100644 --- a/addons/stock/wizard/stock_change_product_qty_view.xml +++ b/addons/stock/wizard/stock_change_product_qty_view.xml @@ -10,6 +10,9 @@ + + +