Beispiel #1
0
def get_list_schema(is_global=False, excludes=()):
    """
    Return the estimation list schema

    :param bool is_global: Should we include global search fields (CAE wide)
    :param tuple excludes: List of field to exclude
    :returns: The list schema
    :rtype: colander.SchemaNode
    """
    schema = forms.lists.BaseListsSchema().clone()

    del schema['search']

    if 'customer' not in excludes:
        schema.insert(
            0,
            customer_filter_node_factory(
                is_admin=is_global,
                name='customer_id',
                with_estimation=True,
            ))

    if "company_id" not in excludes:
        schema.insert(0, company_filter_node_factory(name='company_id'))

    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,
        ))

    if "status" not in excludes:
        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]),
                default='all',
                missing='all'))

    if "signed_status" not in excludes:
        schema.insert(
            0,
            colander.SchemaNode(colander.String(),
                                name='signed_status',
                                widget=deform.widget.SelectWidget(
                                    values=SIGNED_STATUS_OPTIONS),
                                validator=colander.OneOf(
                                    [s[0] for s in SIGNED_STATUS_OPTIONS]),
                                default='all',
                                missing='all'))

    if "year" not in excludes:
        node = forms.year_select_node(
            name='year',
            query_func=get_invoice_years,
        )
        schema.insert(0, node)

    return schema
Beispiel #2
0
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
Beispiel #3
0
def get_list_schema(is_global=False, excludes=()):
    """
    Return a schema for invoice listing

    is_global

        If True, customer select is only related to the current company
    """
    schema = forms.lists.BaseListsSchema().clone()

    if 'paid_status' not in excludes:
        schema.insert(
            0,
            colander.SchemaNode(
                colander.String(),
                name='paid_status',
                widget=deform.widget.SelectWidget(values=PAID_STATUS_OPTIONS),
                validator=colander.OneOf([s[0] for s in PAID_STATUS_OPTIONS]),
                missing='all',
                default='all',
            ))

    if 'status' not in excludes:
        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',
                default='all',
            ))

    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',
        ))

    if 'customer' not in excludes:
        schema.insert(
            0,
            customer_filter_node_factory(
                is_admin=is_global,
                name='customer_id',
            ))

    if 'company_id' not in excludes:
        schema.insert(0, company_filter_node_factory(name='company_id'))

    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,
        ))

    if 'year' not in excludes:

        def get_year_options(kw):
            values = invoice.get_invoice_years(kw)
            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
Beispiel #4
0
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=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,
        ))

    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]),
            default='all',
            missing='all'))
    node = forms.year_select_node(
        name='year',
        query_func=get_invoice_years,
    )
    schema.insert(0, node)

    return schema