<s> """<STR_LIT>""" <EOL> from django . shortcuts import get_object_or_404 <EOL> from django import forms <EOL> from treeio . identities . models import Contact <EOL> from treeio . finance . models import Transaction , Liability , Category , Account , Asset , Equity , Currency , Tax <EOL> from treeio . sales . models import SaleOrder <EOL> from treeio . core . models import Object , ModuleSetting <EOL> from django . core . urlresolvers import reverse <EOL> from treeio . core . decorators import preprocess_form <EOL> from django . utils . translation import ugettext as _ <EOL> from treeio . sales . forms import standard_currencies <EOL> preprocess_form ( ) <EOL> class MassActionForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> category = forms . ModelChoiceField ( queryset = [ ] , required = False ) <EOL> delete = forms . ChoiceField ( label = _ ( "<STR_LIT>" ) , choices = ( ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) ) , required = False ) <EOL> instance = None <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> if '<STR_LIT>' in kwargs : <EOL> self . instance = kwargs [ '<STR_LIT>' ] <EOL> del kwargs [ '<STR_LIT>' ] <EOL> super ( MassActionForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] = forms . ChoiceField ( label = _ ( "<STR_LIT>" ) , choices = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , _ ( <EOL> '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) ) , <EOL> required = False ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Category . objects , mode = '<STR_LIT:x>' ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> if self . instance : <EOL> if self . is_valid ( ) : <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> self . instance . category = self . cleaned_data [ '<STR_LIT>' ] <EOL> self . instance . save ( ) <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> if self . cleaned_data [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> self . instance . delete ( ) <EOL> if self . cleaned_data [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> self . instance . trash = True <EOL> self . instance . save ( ) <EOL> class CategoryForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( CategoryForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:name>' ] . label = _ ( "<STR_LIT:Name>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Category <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> class AccountForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( AccountForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:name>' ] . label = _ ( "<STR_LIT:Name>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> try : <EOL> self . fields [ '<STR_LIT>' ] . initial = Currency . objects . get ( <EOL> is_default = True ) <EOL> except : <EOL> pass <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Account <EOL> fields = ( <EOL> '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class AccountFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( AccountFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Account <EOL> fields = [ '<STR_LIT>' ] <EOL> class AssetForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( AssetForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:name>' ] . label = _ ( "<STR_LIT:Name>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Asset <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class AssetFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( AssetFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( label = "<STR_LIT>" , <EOL> required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( <EOL> label = "<STR_LIT>" , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Asset <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class EquityForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( EquityForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT>' ] . initial = long ( conf . value ) <EOL> except Exception : <EOL> pass <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Equity <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class EquityFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( EquityFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( label = "<STR_LIT>" , <EOL> required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( <EOL> label = "<STR_LIT>" , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Equity <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ReceivableForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( ReceivableForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:name>' ] . label = _ ( "<STR_LIT:Name>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:target>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . initial = Currency . objects . get ( <EOL> is_default = True ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:source>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT:source>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Account . objects ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT>' ] . initial = long ( conf . value ) <EOL> except Exception : <EOL> pass <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> del self . fields [ '<STR_LIT:target>' ] <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Liability <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT:target>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class TransactionForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , liability_id = None , order_id = None , * args , ** kwargs ) : <EOL> super ( TransactionForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:name>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:target>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . initial = Currency . objects . get ( <EOL> is_default = True ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:target>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:source>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT:target>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT:source>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT:target>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Account . objects ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT>' ] . initial = long ( conf . value ) <EOL> except Exception : <EOL> pass <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Liability . objects ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if order_id : <EOL> order = get_object_or_404 ( SaleOrder , pk = order_id ) <EOL> self . fields [ '<STR_LIT:name>' ] . initial = order . reference <EOL> if order . client : <EOL> self . fields [ '<STR_LIT:source>' ] . initial = order . client <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT:target>' ] . initial = Contact . objects . get ( <EOL> pk = long ( conf . value ) ) <EOL> except Exception : <EOL> pass <EOL> self . fields [ '<STR_LIT>' ] . initial = order . details <EOL> self . fields [ '<STR_LIT>' ] . initial = order . balance_due ( ) <EOL> self . fields [ '<STR_LIT>' ] . initial = order . currency <EOL> if liability_id : <EOL> self . fields [ '<STR_LIT>' ] . initial = liability_id <EOL> liability = get_object_or_404 ( Liability , pk = liability_id ) <EOL> self . fields [ '<STR_LIT:name>' ] . initial = liability . name <EOL> self . fields [ '<STR_LIT:source>' ] . initial = liability . source <EOL> self . fields [ '<STR_LIT:target>' ] . initial = liability . target <EOL> self . fields [ '<STR_LIT>' ] . initial = liability . details <EOL> self . fields [ '<STR_LIT>' ] . initial = liability . category <EOL> self . fields [ '<STR_LIT>' ] . initial = liability . account <EOL> self . fields [ '<STR_LIT>' ] . initial = liability . value_display <EOL> self . fields [ '<STR_LIT>' ] . initial = liability . value_currency <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Transaction <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT:target>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class TransactionFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( TransactionFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( <EOL> label = _ ( "<STR_LIT>" ) , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( <EOL> label = _ ( "<STR_LIT>" ) , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Category . objects ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> if '<STR_LIT:source>' in skip : <EOL> del self . fields [ '<STR_LIT:source>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT:source>' ] . required = False <EOL> self . fields [ '<STR_LIT:source>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> if '<STR_LIT:target>' in skip : <EOL> del self . fields [ '<STR_LIT:target>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT:target>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:target>' ] . required = False <EOL> self . fields [ '<STR_LIT:target>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:target>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT:target>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Transaction <EOL> fields = ( '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT:target>' ) <EOL> class LiabilityForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( LiabilityForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:name>' ] . label = _ ( "<STR_LIT:Name>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:target>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . initial = Currency . objects . get ( <EOL> is_default = True ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:target>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:target>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT:target>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Account . objects ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT>' ] . initial = long ( conf . value ) <EOL> except Exception : <EOL> pass <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> del self . fields [ '<STR_LIT:source>' ] <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Liability <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT:target>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class LiabilityFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( LiabilityFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( <EOL> label = _ ( "<STR_LIT>" ) , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] = forms . DateField ( <EOL> label = _ ( "<STR_LIT>" ) , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Category . objects ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> if '<STR_LIT:source>' in skip : <EOL> del self . fields [ '<STR_LIT:source>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT:source>' ] . required = False <EOL> self . fields [ '<STR_LIT:source>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> if '<STR_LIT:target>' in skip : <EOL> del self . fields [ '<STR_LIT:target>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT:target>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT:target>' ] . required = False <EOL> self . fields [ '<STR_LIT:target>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:target>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT:target>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> if '<STR_LIT>' in skip : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Account . objects ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Liability <EOL> fields = ( '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT:target>' , '<STR_LIT>' ) <EOL> class SettingsForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> default_currency = forms . ModelChoiceField ( <EOL> label = '<STR_LIT>' , queryset = [ ] ) <EOL> my_company = forms . ModelChoiceField ( label = '<STR_LIT>' , queryset = [ ] ) <EOL> default_account = forms . ModelChoiceField ( <EOL> label = '<STR_LIT>' , queryset = [ ] ) <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> super ( SettingsForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Account . objects ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( '<STR_LIT>' ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( '<STR_LIT>' ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( '<STR_LIT>' ) <EOL> try : <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Currency . objects . all ( ) <EOL> self . fields [ '<STR_LIT>' ] . initial = Currency . objects . get ( <EOL> is_default = True ) <EOL> except Exception : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> my_company = Contact . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ '<STR_LIT>' ] . initial = my_company . id <EOL> except Exception : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_account = Account . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ '<STR_LIT>' ] . initial = default_account . id <EOL> except Exception : <EOL> pass <EOL> def clean_my_company ( self , * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> my_company = self . cleaned_data [ '<STR_LIT>' ] <EOL> if not my_company . account_set . count ( ) : <EOL> raise forms . ValidationError ( <EOL> _ ( "<STR_LIT>" ) ) <EOL> return my_company <EOL> def clean_default_account ( self ) : <EOL> "<STR_LIT>" <EOL> account = self . cleaned_data [ '<STR_LIT>' ] <EOL> try : <EOL> company = self . cleaned_data [ '<STR_LIT>' ] <EOL> if not account . owner_id == company . id : <EOL> raise forms . ValidationError ( <EOL> _ ( "<STR_LIT>" ) ) <EOL> except KeyError : <EOL> pass <EOL> return account <EOL> def save ( self ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> ModuleSetting . set_for_module ( '<STR_LIT>' , <EOL> self . cleaned_data [ '<STR_LIT>' ] . id , <EOL> '<STR_LIT>' ) <EOL> ModuleSetting . set_for_module ( '<STR_LIT>' , <EOL> self . cleaned_data [ <EOL> '<STR_LIT>' ] . id , <EOL> '<STR_LIT>' ) <EOL> currency = Currency . objects . get ( <EOL> pk = self . cleaned_data [ '<STR_LIT>' ] ) <EOL> currency . is_default = True <EOL> currency . save ( ) <EOL> return True <EOL> except Exception : <EOL> return False <EOL> class CurrencyForm ( forms . ModelForm ) : <EOL> "<STR_LIT>" <EOL> code = forms . ChoiceField ( <EOL> label = _ ( "<STR_LIT>" ) , choices = standard_currencies ) <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( CurrencyForm , self ) . __init__ ( * args , ** kwargs ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Currency <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT:code>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class TaxForm ( forms . ModelForm ) : <EOL> "<STR_LIT>" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( TaxForm , self ) . __init__ ( * args , ** kwargs ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Tax <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ) </s>
