<s> from sellmo . core . loading import load <EOL> NO_MUTATION = object ( ) <EOL> import sellmo . apps . checkout as _checkout <EOL> @ load ( before = '<STR_LIT>' ) <EOL> def load_model ( ) : <EOL> class Order ( _checkout . models . Order ) : <EOL> _mutated_payment = NO_MUTATION <EOL> def invalidate ( self ) : <EOL> super ( Order , self ) . invalidate ( ) <EOL> self . payment_method = None <EOL> @ property <EOL> def payment ( self ) : <EOL> if self . _mutated_payment is not NO_MUTATION : <EOL> return self . _mutated_payment <EOL> return getattr ( self , '<STR_LIT>' , None ) <EOL> def get_payment_method ( self ) : <EOL> if self . payment is not None : <EOL> from . method import PaymentMethod <EOL> return PaymentMethod . from_payment ( self . payment ) <EOL> def set_payment_method ( self , value ) : <EOL> payment = None <EOL> if value is not None : <EOL> payment = value . make_payment ( self ) <EOL> self . _mutated_payment = payment <EOL> payment_method = property ( get_payment_method , set_payment_method ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> super ( Order , self ) . save ( * args , ** kwargs ) <EOL> if self . _mutated_payment is not NO_MUTATION : <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> self . order_payment . delete ( ) <EOL> self . order_payment . order = None <EOL> if self . _mutated_payment is not None : <EOL> self . _mutated_payment . order = self <EOL> self . _mutated_payment . save ( ) <EOL> self . _mutated_payment = NO_MUTATION <EOL> class Meta ( _checkout . models . Order . Meta ) : <EOL> abstract = True <EOL> _checkout . models . Order = Order </s>
