Esempio n. 1
0
def get_training_list_schema(is_admin):
    """
    Build the Training list filter schema
    """
    schema = BaseListsSchema().clone()
    schema['search'].description = u"Numéro de facture"
    if is_admin:
        schema.add_before(
            "items_per_page",
            company_filter_node_factory(name='company_id')
        )
    schema.add_before(
        "items_per_page",
        customer_filter_node_factory(name='customer_id', is_admin=is_admin)
    )
    schema.add_before(
        "items_per_page",
        colander.SchemaNode(
            colander.Boolean(),
            name="include_closed",
            label=u"Inclure les affaires clôturées",
            missing=False
        )
    )
    return schema
Esempio n. 2
0
def get_training_list_schema(is_admin):
    """
    Build the Training list filter schema
    """
    schema = BaseListsSchema().clone()
    schema['search'].description = u"Numéro de facture"
    schema.add_before("items_per_page",
                      company_filter_node_factory(name='company_id'))
    schema.add_before(
        "items_per_page",
        customer_filter_node_factory(name='customer_id', is_admin=is_admin))
    schema.add_before(
        "items_per_page",
        colander.SchemaNode(colander.Boolean(),
                            name="include_closed",
                            label=u"Inclure les affaires clôturées",
                            missing=False))
    return schema
Esempio n. 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',
            with_invoice=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 '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
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
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