#NEWLINE# def decrease_inventory_on_sale( sender , order = None , **kwargs ) : #NEWLINE# #INDENT# 'Track inventory and total sold.' #NEWLINE# for item in order . orderitem_set . all ( ) : #NEWLINE# #INDENT# product = item . product #NEWLINE# product . total_sold += item . quantity #NEWLINE# if config_value ( 'PRODUCT' , 'TRACK_INVENTORY' ) : #NEWLINE# #INDENT# product . items_in_stock -= product . quantity #NEWLINE# #UNINDENT# product . save ( )