#NEWLINE# def veto_out_of_stock( sender , cartitem = None , added_quantity = 0 , **kwargs ) : #NEWLINE# #INDENT# 'Listener which vetoes adding products to the cart which are out of stock.' #NEWLINE# if ( config_value ( 'PRODUCT' , 'NO_STOCK_CHECKOUT' ) == False ) : #NEWLINE# #INDENT# product = cartitem . product #NEWLINE# need_qty = ( cartitem . quantity + added_quantity ) #NEWLINE# if ( product . items_in_stock < need_qty ) : #NEWLINE# #INDENT# log . debug ( 'out of stock on %s' , product . slug ) #NEWLINE# raise OutOfStockError ( product , product . items_in_stock , need_qty )