<s> """<STR_LIT>""" <EOL> from django . shortcuts import get_object_or_404 <EOL> from django import forms <EOL> from django . db . models import Q <EOL> from treeio . sales . models import Product , SaleOrder , SaleSource , Lead , Opportunity , SaleStatus , OrderedProduct , Subscription , Currency <EOL> from treeio . identities . models import Contact <EOL> from treeio . core . models import Object , ModuleSetting , User , UpdateRecord <EOL> from django . core . urlresolvers import reverse <EOL> from treeio . core . decorators import preprocess_form <EOL> from django . utils . translation import ugettext as _ <EOL> preprocess_form ( ) <EOL> standard_currencies = ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ) <EOL> dict_currencies = dict ( standard_currencies ) <EOL> class SettingsForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> default_currency = forms . ModelChoiceField ( <EOL> label = _ ( '<STR_LIT>' ) , queryset = Currency . objects ) <EOL> default_lead_status = forms . ModelChoiceField ( <EOL> label = _ ( '<STR_LIT>' ) , queryset = [ ] ) <EOL> default_opportunity_status = forms . ModelChoiceField ( <EOL> label = _ ( '<STR_LIT>' ) , queryset = [ ] ) <EOL> default_order_status = forms . ModelChoiceField ( <EOL> label = _ ( '<STR_LIT>' ) , queryset = [ ] ) <EOL> default_order_source = forms . ModelChoiceField ( <EOL> label = _ ( '<STR_LIT>' ) , queryset = [ ] ) <EOL> default_order_product = forms . ModelChoiceField ( <EOL> label = _ ( '<STR_LIT>' ) , queryset = [ ] , required = False ) <EOL> order_fulfil_status = 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 ( user , <EOL> SaleStatus . objects . filter ( use_leads = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_opportunities = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_sales = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleSource . objects . all ( ) ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_sales = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> Product . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( '<STR_LIT>' ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( '<STR_LIT>' ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( <EOL> '<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> try : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Currency . objects <EOL> self . fields [ '<STR_LIT>' ] . initial = Currency . objects . get ( <EOL> is_default__exact = True ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> except : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_opportunity_status = SaleStatus . objects . get ( <EOL> pk = long ( conf . value ) ) <EOL> self . fields [ <EOL> '<STR_LIT>' ] . initial = default_opportunity_status . id <EOL> except : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_lead_status = SaleStatus . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ '<STR_LIT>' ] . initial = default_lead_status . id <EOL> except : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_order_status = SaleStatus . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ <EOL> '<STR_LIT>' ] . initial = default_order_status . id <EOL> except : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_order_source = SaleSource . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ <EOL> '<STR_LIT>' ] . initial = default_order_source . id <EOL> except : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_order_product = Product . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ <EOL> '<STR_LIT>' ] . initial = default_order_product . id <EOL> except : <EOL> pass <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> order_fulfil_status = SaleStatus . objects . get ( pk = long ( conf . value ) ) <EOL> self . fields [ '<STR_LIT>' ] . initial = order_fulfil_status . id <EOL> except : <EOL> pass <EOL> def save ( self ) : <EOL> "<STR_LIT>" <EOL> fields = self . fields <EOL> try : <EOL> for field in fields : <EOL> if self . cleaned_data [ field ] : <EOL> if field == '<STR_LIT>' : <EOL> ModuleSetting . set_for_module ( '<STR_LIT>' , <EOL> self . cleaned_data [ <EOL> '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> currency = Currency . objects . get ( <EOL> pk = self . cleaned_data [ '<STR_LIT>' ] ) <EOL> currency . is_default = True <EOL> currency . save ( ) <EOL> else : <EOL> ModuleSetting . set_for_module ( field , self . cleaned_data [ field ] . id , <EOL> '<STR_LIT>' ) <EOL> return True <EOL> except : <EOL> return False <EOL> class MassActionForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> status = forms . ModelChoiceField ( queryset = [ ] , required = False ) <EOL> assignedto = 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:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( <EOL> use_sales = True ) , <EOL> mode = '<STR_LIT:x>' ) <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <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>' ) ) ) , required = False ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = User . objects <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:status>' ] : <EOL> self . instance . status = self . cleaned_data [ '<STR_LIT:status>' ] <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> self . instance . assigned . add ( 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 LeadMassActionForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> status = forms . ModelChoiceField ( queryset = [ ] , required = False ) <EOL> assignedto = forms . ModelChoiceField ( queryset = [ ] , 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 ( LeadMassActionForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( <EOL> use_leads = True ) , <EOL> mode = '<STR_LIT:x>' ) <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = User . objects <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:status>' ] : <EOL> self . instance . status = self . cleaned_data [ '<STR_LIT:status>' ] <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> self . instance . assigned . add ( self . cleaned_data [ '<STR_LIT>' ] ) <EOL> self . instance . save ( ) <EOL> class OpportunityMassActionForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> status = forms . ModelChoiceField ( queryset = [ ] , required = False ) <EOL> assignedto = forms . ModelChoiceField ( queryset = [ ] , 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 ( OpportunityMassActionForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( <EOL> use_opportunities = True ) , <EOL> mode = '<STR_LIT:x>' ) <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = User . objects <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:status>' ] : <EOL> self . instance . status = self . cleaned_data [ '<STR_LIT:status>' ] <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> self . instance . assigned . add ( self . cleaned_data [ '<STR_LIT>' ] ) <EOL> self . instance . save ( ) <EOL> class ProductMassActionForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> active = 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 ( ProductMassActionForm , self ) . __init__ ( * args , ** kwargs ) <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>' ] == '<STR_LIT>' : <EOL> self . instance . active = True <EOL> if self . cleaned_data [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> self . instance . active = False <EOL> self . instance . save ( ) <EOL> class SaleStatusForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> name = forms . CharField ( widget = forms . TextInput ( attrs = { '<STR_LIT:size>' : '<STR_LIT>' } ) ) <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( SaleStatusForm , 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>' ] . initial = True <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = SaleStatus <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class SaleSourceForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> name = forms . CharField ( widget = forms . TextInput ( attrs = { '<STR_LIT:size>' : '<STR_LIT>' } ) ) <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( SaleSourceForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . initial = True <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> class Meta : <EOL> "<STR_LIT>" <EOL> model = SaleSource <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ProductForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> name = forms . CharField ( widget = forms . TextInput ( attrs = { '<STR_LIT:size>' : '<STR_LIT>' } ) ) <EOL> def __init__ ( self , user , parent = None , * args , ** kwargs ) : <EOL> super ( ProductForm , 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>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . initial = True <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> manager = Product . objects . filter ( active = True ) <EOL> if '<STR_LIT>' in kwargs : <EOL> instance = kwargs [ '<STR_LIT>' ] <EOL> manager = manager . exclude ( Q ( parent = instance ) & Q ( pk = instance . id ) ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , manager , mode = '<STR_LIT:x>' ) <EOL> if parent : <EOL> self . fields [ '<STR_LIT>' ] . initial = get_object_or_404 ( <EOL> Product , pk = parent ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:code>' ] . 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> class Meta : <EOL> "<STR_LIT>" <EOL> model = Product <EOL> fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:code>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ProductFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( ProductFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> Product . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <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>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . initial = True <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Product <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class UpdateRecordForm ( forms . ModelForm ) : <EOL> "<STR_LIT>" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( UpdateRecordForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:body>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:body>' ] . required = True <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = UpdateRecord <EOL> fields = [ '<STR_LIT:body>' ] <EOL> class OrderedProductForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , order , * args , ** kwargs ) : <EOL> super ( OrderedProductForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Subscription . 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>' ] . queryset = Object . filter_permitted ( <EOL> user , Product . objects . filter ( active = True ) ) <EOL> if user . is_admin ( '<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> 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 : <EOL> pass <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>' ] . initial = <NUM_LIT:1> <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT:%>" <EOL> def save ( self , * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> instance = super ( OrderedProductForm , self ) . save ( commit = False ) <EOL> if '<STR_LIT>' in self . cleaned_data and self . cleaned_data [ '<STR_LIT>' ] : <EOL> instance . rate = self . cleaned_data [ '<STR_LIT>' ] . sell_price <EOL> instance . rate_display = instance . rate <EOL> return instance <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = OrderedProduct <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:description>' ) <EOL> class SubscriptionForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( SubscriptionForm , self ) . __init__ ( * args , ** kwargs ) <EOL> del self . fields [ '<STR_LIT>' ] <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Product . objects ) <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:start>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT:start>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if '<STR_LIT>' in kwargs : <EOL> self . instance = kwargs [ '<STR_LIT>' ] <EOL> self . fields [ '<STR_LIT:start>' ] . widget . attrs [ '<STR_LIT>' ] = True <EOL> del kwargs [ '<STR_LIT>' ] <EOL> self . fields [ '<STR_LIT>' ] . initial = True <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> class Meta : <EOL> "<STR_LIT>" <EOL> model = Subscription <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:start>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class OrderForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , lead = None , opportunity = None , * args , ** kwargs ) : <EOL> super ( OrderForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> if hasattr ( self , '<STR_LIT>' ) and not self . instance . reference : <EOL> next_ref = self . instance . get_next_reference ( ) <EOL> if next_ref : <EOL> self . fields [ '<STR_LIT>' ] . initial = next_ref <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:source>' ] . queryset = Object . filter_permitted ( <EOL> user , SaleSource . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( '<STR_LIT>' ) <EOL> instance = getattr ( self , '<STR_LIT>' , None ) <EOL> if instance and instance . id : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> else : <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> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT:source>' ] . initial = long ( conf . value ) <EOL> except : <EOL> pass <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_sales = True ) ) <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT:status>' ] . initial = long ( conf . value ) <EOL> except : <EOL> pass <EOL> if opportunity : <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Opportunity . objects ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . initial = opportunity . id <EOL> self . fields [ '<STR_LIT>' ] . initial = opportunity . contact_id <EOL> self . fields [ '<STR_LIT:source>' ] . initial = opportunity . source_id <EOL> self . fields [ '<STR_LIT>' ] . initial = [ <EOL> i . id for i in opportunity . assigned . only ( '<STR_LIT:id>' ) ] <EOL> else : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> if lead : <EOL> self . fields [ '<STR_LIT>' ] . initial = lead . contact_id <EOL> self . fields [ '<STR_LIT:source>' ] . initial = lead . source_id <EOL> self . fields [ '<STR_LIT>' ] . initial = [ <EOL> i . id for i in lead . assigned . only ( '<STR_LIT:id>' ) ] <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <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:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = SaleOrder <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:source>' , <EOL> '<STR_LIT>' , '<STR_LIT:status>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class OrderFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> paid = forms . ChoiceField ( choices = ( <EOL> ( None , '<STR_LIT>' ) , ( '<STR_LIT>' , _ ( "<STR_LIT>" ) ) , ( '<STR_LIT>' , _ ( "<STR_LIT>" ) ) ) , required = False ) <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( OrderFilterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if '<STR_LIT:status>' in skip : <EOL> del self . fields [ '<STR_LIT:status>' ] <EOL> else : <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_sales = True ) ) <EOL> self . fields [ '<STR_LIT:status>' ] . required = False <EOL> self . fields [ '<STR_LIT:status>' ] . 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>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( <EOL> user , SaleSource . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT:source>' ] . required = False <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <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>' ] . help_text = "<STR_LIT>" <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = SaleOrder <EOL> fields = ( '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT>' , '<STR_LIT:status>' ) <EOL> class LeadForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , * args , ** kwargs ) : <EOL> super ( LeadForm , 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>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( <EOL> user , SaleSource . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Product . objects ) <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<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>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <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 : <EOL> pass <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( <EOL> user , SaleStatus . objects . filter ( use_leads = True ) ) <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . fields [ '<STR_LIT:status>' ] . initial = long ( conf . value ) <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 = Lead <EOL> fields = ( '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:status>' , '<STR_LIT>' ) <EOL> class LeadFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( LeadFilterForm , 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>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Product . objects ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleSource . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT:source>' ] . required = False <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_leads = True ) ) <EOL> self . fields [ '<STR_LIT:status>' ] . required = False <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Lead <EOL> fields = ( <EOL> '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:status>' ) <EOL> class OpportunityForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , lead , * args , ** kwargs ) : <EOL> super ( OpportunityForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Lead . objects ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( <EOL> user , Contact . objects ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } ) <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 , Product . objects ) <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 : <EOL> pass <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleSource . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_opportunities = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' , <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:status>' ] . initial = long ( conf . value ) <EOL> except : <EOL> pass <EOL> if lead : <EOL> self . fields [ '<STR_LIT>' ] . initial = lead . id <EOL> self . fields [ '<STR_LIT>' ] . initial = lead . contact_id <EOL> self . fields [ '<STR_LIT>' ] . initial = [ <EOL> i . id for i in lead . products_interested . only ( '<STR_LIT:id>' ) ] <EOL> self . fields [ '<STR_LIT:source>' ] . initial = lead . source_id <EOL> self . fields [ '<STR_LIT>' ] . initial = [ <EOL> i . id for i in lead . assigned . only ( '<STR_LIT:id>' ) ] <EOL> else : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( <EOL> { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . widget . attrs . update ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> self . fields [ '<STR_LIT>' ] . 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>' ] . 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>' : 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:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Opportunity <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:source>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:status>' , '<STR_LIT>' ) <EOL> class OpportunityFilterForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , user , skip = None , * args , ** kwargs ) : <EOL> if skip is None : <EOL> skip = [ ] <EOL> super ( OpportunityFilterForm , 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>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:source>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleSource . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT:source>' ] . required = False <EOL> self . fields [ '<STR_LIT:source>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = Object . filter_permitted ( user , <EOL> Product . objects . filter ( active = True ) ) <EOL> self . fields [ '<STR_LIT>' ] . required = False <EOL> self . fields [ '<STR_LIT>' ] . help_text = "<STR_LIT>" <EOL> self . fields [ '<STR_LIT>' ] . label = _ ( "<STR_LIT>" ) <EOL> self . fields [ '<STR_LIT:status>' ] . queryset = Object . filter_permitted ( user , <EOL> SaleStatus . objects . filter ( use_opportunities = True ) ) <EOL> self . fields [ '<STR_LIT:status>' ] . required = False <EOL> self . fields [ '<STR_LIT:status>' ] . label = _ ( "<STR_LIT>" ) <EOL> class Meta : <EOL> "<STR_LIT>" <EOL> model = Opportunity <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:source>' , '<STR_LIT:status>' ) </s>
