Stock Location Product query - OpenERP v7



I'm trying to modify the stock.product.location wizard query from module stock on OpenERP v7.


What I'm trying to achieve, is to show only products with some quantities on the treeview, not just every product on the system.


By default, the system shows every product item registered on it, regardless if I have or not quantities on specific warehouse location.


So, I made a little modification to the class, being 'product_qty' > 0 on the class, this is my code:



class stock_location_product(osv.osv_memory):
_name = "stock.location.product"
_description = "Products by Location"
_columns = {
'from_date': fields.datetime('From'),
'to_date': fields.datetime('To'),
'type': fields.selection([('inventory','Analyze current inventory'),
('period','Analyze period')], 'Analysis Type', required=True),
}

def action_open_window(self, cr, uid, ids, context=None):
""" To open location wise product information specific to given duration
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: An ID or list of IDs (but only the first ID will be processed)
@param context: A standard dictionary
@return: Invoice type
"""
if context is None:
context = {}
location_products = self.read(cr, uid, ids, ['from_date', 'to_date'], context=context)
if location_products:
return {
'name': _('Current Inventory'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'product.product',
'type': 'ir.actions.act_window',
#'estadodp' : fields.selection([('',''),
#('sin_fallas','Sin fallas'),
#('con_fallas', 'Con fallas'),], 'Estado del Producto'),
'context': {'location': context['active_id'],
'from_date': location_products[0]['from_date'],
'product_qty' > 0,
'to_date': location_products[0]['to_date']},
'domain': [('type', '<>', 'service')],
}

stock_location_product()


But it doesn't works, I'm pretty sure it should be a simple change on the query, but I'm kind of confused, any ideas about it?


You can access this wizard on OpenERP v7 by surfing: Stock->Inventory control->Location Structure->Select Location->Analyze current inventory


Thanks in advance!


No comments:

Post a Comment