8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Add autocomplete on cotisations

This commit is contained in:
chirac 2020-12-28 18:57:08 +01:00 committed by Gabriel Detraz
parent 4ff555e41f
commit 5f46ce1db5
4 changed files with 64 additions and 4 deletions

View file

@ -45,7 +45,7 @@ from django.utils.translation import ugettext_lazy as _
from django.shortcuts import get_object_or_404
from re2o.field_permissions import FieldPermissionFormMixin
from re2o.mixins import FormRevMixin
from re2o.mixins import FormRevMixin, AutocompleteModelMixin, AutocompleteMultipleModelMixin
from .models import (
Article,
Paiement,
@ -79,6 +79,14 @@ class FactureForm(FieldPermissionFormMixin, FormRevMixin, ModelForm):
class Meta:
model = Facture
fields = "__all__"
widgets = {
"user": AutocompleteModelMixin(
url="/users/user-autocomplete",
),
"banque": AutocompleteModelMixin(
url="/cotisations/banque-autocomplete",
),
}
def clean(self):
cleaned_data = super(FactureForm, self).clean()

View file

@ -25,13 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load staticfiles%}
{% load massive_bootstrap_form %}
{% load i18n %}
{% block title %}{% trans "Creation and editing of invoices" %}{% endblock %}
{% block content %}
{% bootstrap_form_errors factureform %}
{{ factureform.media }}
<form class="form" method="post">
{% csrf_token %}
@ -40,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% else %}
<h3>{% trans "Edit invoice" %}</h3>
{% endif %}
{% massive_bootstrap_form factureform 'user' %}
{% bootstrap_form factureform %}
{{ venteform.management_form }}
<h3>{% trans "Articles" %}</h3>
<table class="table table-striped">

View file

@ -27,7 +27,7 @@ from __future__ import unicode_literals
from django.conf.urls import url
from . import views
from . import views, views_autocomplete
from . import payment_methods
urlpatterns = [
@ -104,4 +104,6 @@ urlpatterns = [
url(r"^index_paiement/$", views.index_paiement, name="index-paiement"),
url(r"^control/$", views.control, name="control"),
url(r"^$", views.index, name="index"),
### Autocomplete Views
url(r'^banque-autocomplete/$', views_autocomplete.BanqueAutocomplete.as_view(), name='banque-autocomplete',),
] + payment_methods.urls.urlpatterns

View file

@ -0,0 +1,50 @@
# -*- mode: python; coding: utf-8 -*-
# Re2o est un logiciel d'administration développé initiallement au Rézo Metz. Il
# se veut agnostique au réseau considéré, de manière à être installable en
# quelques clics.
#
# Copyright © 2017-2020 Gabriel Détraz
# Copyright © 2017-2020 Jean-Romain Garnier
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# App de gestion des users pour re2o
# Lara Kermarec, Gabriel Détraz, Lemesle Augustin
# Gplv2
"""
Django views autocomplete view
Here are defined the autocomplete class based view.
"""
from __future__ import unicode_literals
from django.db.models import Q, Value, CharField
from .models import (
Banque
)
from re2o.mixins import AutocompleteViewMixin
from re2o.acl import (
can_view_all,
)
class BanqueAutocomplete(AutocompleteViewMixin):
obj_type = Banque