To check product quantity in openerp
You have to write this function in .py file to check product quantity in product module and relate his to
the inventory management. See code given below
def check_product_quantity(self, cr, uid, product, quantity):
"""
This method is not called from a constraint. It checks if there is enough quantity of this product,
and return a 'warning usable' dictionary, or an empty one.
"""
warning = {}
if product.type != 'product':
return warning
if product.qty_available < quantity: # We use the real quantity, not the virtual one for renting !
warning = {
'title' : _("Not enought quantity !"),
'message' : _("You don't have enought quantity of this product. You asked %d, but there are "
"%d available. You can continue, but you are warned.") % (quantity, product.qty_available)
}
return warning
0 Comment(s)