#NEWLINE# def save( self , force_insert = False , force_update = False , **kwargs ) : #NEWLINE# #INDENT# if ( self . code == '' ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# self . code = self . generate_code ( ) #NEWLINE# try : #NEWLINE# #INDENT# super ( ModelWithCode , self ) . save ( force_insert , force_update , ** kwargs ) #NEWLINE# #UNINDENT# except IntegrityError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# super ( ModelWithCode , self ) . save ( force_insert , force_update , ** kwargs )