[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:
parent
0bc496ed1e
commit
516d89069f
|
@ -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()
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
<separator string="Select Quantity" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="new_quantity" />
|
||||
<newline/>
|
||||
<field name="prodlot_id" />
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="location_id" />
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2"/>
|
||||
|
@ -27,6 +30,7 @@
|
|||
<field name="res_model">stock.change.product.qty</field>
|
||||
<field name="view_type">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="target">new</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue