def get_list_schema(is_admin=False): """ Return a schema for invoice listing is_admin If True, we don't provide the company selection node and we reduce the customers to the current company's """ schema = forms.lists.BaseListsSchema().clone() schema.insert(0, colander.SchemaNode( colander.String(), name='status', widget=deform_widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='both', )) schema.insert(0, company.customer_node(is_admin)) if is_admin: schema.insert( 0, colander.SchemaNode( custom_types.AmountType(), name='ttc', missing=colander.drop, description=u"Montant TTC", ) ) schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')} ) ) node = forms.year_select_node( name='year', query_func=invoice.get_invoice_years, ) schema.insert(0, node) schema['search'].description = u"Identifiant du document" return schema
def get_list_schema(is_admin=False): """ Return a schema for invoice listing is_admin If True, we don't provide the company selection node and we reduce the customers to the current company's """ schema = forms.lists.BaseListsSchema().clone() schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform_widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='both', )) schema.insert(0, company.customer_node(is_admin)) if is_admin: schema.insert( 0, colander.SchemaNode( custom_types.AmountType(), name='ttc', missing=colander.drop, description=u"Montant TTC", )) schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')})) node = forms.year_select_node( name='year', query_func=invoice.get_invoice_years, ) schema.insert(0, node) schema['search'].description = u"Identifiant du document" return schema
class CompanySequence(colander.SequenceSchema): """ schema for the list of attached companies """ company_id = company.company_node(title=u"une entreprise")
def get_list_schema(is_admin=False): """ Return a schema for invoice listing is_admin If True, we don't provide the company selection node and we reduce the customers to the current company's """ schema = forms.lists.BaseListsSchema().clone() schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='both', ) ) schema.insert( 0, colander.SchemaNode( colander.String(), name='doctype', widget=deform.widget.SelectWidget(values=TYPE_OPTIONS), validator=colander.OneOf([s[0] for s in TYPE_OPTIONS]), missing='both', ) ) schema.insert(0, company.customer_node(is_admin)) if is_admin: schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')} ) ) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début" ), widget=deform.widget.MappingWidget( template=TEMPLATES_URL + 'clean_mapping.pt', ), missing=colander.drop, ) ) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin" ), widget=deform.widget.MappingWidget( template=TEMPLATES_URL + 'clean_mapping.pt', ), missing=colander.drop, ) ) node = forms.year_select_node( name='year', query_func=invoice.get_invoice_years, ) schema.insert(0, node) schema['search'].description = u"Identifiant du document" return schema
def get_list_schema(is_admin=False): """ Return a schema for invoice listing is_admin If True, we don't provide the company selection node and we reduce the customers to the current company's """ schema = forms.lists.BaseListsSchema().clone() schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='both', default='both', )) schema.insert( 0, colander.SchemaNode( colander.String(), name='doctype', widget=deform.widget.SelectWidget(values=TYPE_OPTIONS), validator=colander.OneOf([s[0] for s in TYPE_OPTIONS]), missing='both', default='both', )) schema.insert(0, company.customer_node(is_admin)) if is_admin: schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')}, )) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début"), widget=CleanMappingWidget(), missing=colander.drop, )) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin"), widget=CleanMappingWidget(), missing=colander.drop, )) def get_year_options(): values = invoice.get_invoice_years() values.insert(0, u'') return values node = forms.year_select_node(name='year', query_func=get_year_options, missing=-1, description=u"Année fiscale") schema.insert(0, node) schema['search'].description = u"Identifiant du document" return schema
def get_list_schema(is_global=False): """ Return the estimation list schema :param bool is_global: Should we include global search fields (CAE wide) :returns: The list schema :rtype: colander.SchemaNode """ schema = forms.lists.BaseListsSchema().clone() del schema['search'] schema.insert(0, company.customer_node(is_global)) if is_global: schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')})) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début"), widget=deform.widget.MappingWidget(template=TEMPLATES_URL + 'clean_mapping.pt', ), missing=colander.drop, )) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin"), widget=deform.widget.MappingWidget(template=TEMPLATES_URL + 'clean_mapping.pt', ), missing=colander.drop, )) schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='all')) node = forms.year_select_node( name='year', query_func=get_invoice_years, ) schema.insert(0, node) return schema
def get_list_schema(is_global=False): """ Return the estimation list schema :param bool is_global: Should we include global search fields (CAE wide) :returns: The list schema :rtype: colander.SchemaNode """ schema = forms.lists.BaseListsSchema().clone() del schema['search'] schema.insert(0, company.customer_node(is_global)) if is_global: schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')} ) ) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début" ), widget=deform.widget.MappingWidget( template=TEMPLATES_URL + 'clean_mapping.pt', ), missing=colander.drop, ) ) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin" ), widget=deform.widget.MappingWidget( template=TEMPLATES_URL + 'clean_mapping.pt', ), missing=colander.drop, ) ) schema.insert(0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='all' )) node = forms.year_select_node( name='year', query_func=get_invoice_years, ) schema.insert(0, node) return schema