[ADD] ADD Field Lot id in wizard to change Product Quantity from Product form View

bzr revid: ron@tinyerp.com-20101222085218-dukwbse1bt5yu2z5
This commit is contained in:
ron@tinyerp.com 2010-12-22 14:22:18 +05:30
parent 0bc496ed1e
commit 516d89069f
2 changed files with 29 additions and 10 deletions

View File

@ -27,8 +27,10 @@ class stock_change_product_qty(osv.osv_memory):
_name = "stock.change.product.qty" _name = "stock.change.product.qty"
_description = "Change Product Quantity" _description = "Change Product Quantity"
_columns = { _columns = {
'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'), 'product_id' : fields.many2one('product.product', 'Product'),
'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", domain="[('usage', '=', 'internal')]"), '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): 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 @param context: A standard dictionary
@return: A dictionary which of fields with values. @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) res = super(stock_change_product_qty, self).default_get(cr, uid, fields, context=context)
if 'new_quantity' in fields: if 'new_quantity' in fields:
res.update({'new_quantity': 1}) res.update({'new_quantity': 1})
if 'product_id' in fields:
res.update({'product_id': product_id})
return res return res
def change_product_qty(self, cr, uid, ids, context=None): 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): 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) inventory_id = inventry_obj.create(cr , uid, {'name': _('INV: ') + str(res_original.name)}, context=context)
line_data ={ line_data ={
'inventory_id' : inventory_id, 'inventory_id' : inventory_id,
'product_qty' : data.new_quantity, 'product_qty' : data.new_quantity,
'location_id' : data.location_id.id, 'location_id' : data.location_id.id,
'product_id' : rec_id, 'product_id' : rec_id,
'product_uom' : res_original.uom_id.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) 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_confirm(cr, uid, [inventory_id], context=context)
inventry_obj.action_done(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() stock_change_product_qty()

View File

@ -10,6 +10,9 @@
<separator string="Select Quantity" colspan="4"/> <separator string="Select Quantity" colspan="4"/>
<newline/> <newline/>
<field name="new_quantity" /> <field name="new_quantity" />
<newline/>
<field name="prodlot_id" />
<field name="product_id" invisible="1"/>
<field name="location_id" /> <field name="location_id" />
<separator string="" colspan="4" /> <separator string="" colspan="4" />
<label string="" colspan="2"/> <label string="" colspan="2"/>
@ -27,6 +30,7 @@
<field name="res_model">stock.change.product.qty</field> <field name="res_model">stock.change.product.qty</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="context">{'default_product_id': active_id}</field>
<field name="view_id" ref="view_change_product_quantity"/> <field name="view_id" ref="view_change_product_quantity"/>
<field name="target">new</field> <field name="target">new</field>
</record> </record>