mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 00:22:25 +00:00
Fix le choix des articles pour les custom invoices
This commit is contained in:
parent
09538385bf
commit
afcf36b659
3 changed files with 7 additions and 6 deletions
|
@ -102,7 +102,7 @@ class SelectArticleForm(FormRevMixin, Form):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
user = kwargs.pop('user')
|
||||
target_user = kwargs.pop('target_user')
|
||||
target_user = kwargs.pop('target_user', None)
|
||||
super(SelectArticleForm, self).__init__(*args, **kwargs)
|
||||
self.fields['article'].queryset = Article.find_allowed_articles(user, target_user)
|
||||
|
||||
|
|
|
@ -610,7 +610,9 @@ class Article(RevMixin, AclMixin, models.Model):
|
|||
user: The user requesting articles.
|
||||
target_user: The user to sell articles
|
||||
"""
|
||||
if target_user.is_class_club:
|
||||
if target_user is None:
|
||||
objects_pool = cls.objects.filter(Q(type_user='All'))
|
||||
elif target_user.is_class_club:
|
||||
objects_pool = cls.objects.filter(
|
||||
Q(type_user='All') | Q(type_user='Club')
|
||||
)
|
||||
|
|
|
@ -191,9 +191,9 @@ def new_custom_invoice(request):
|
|||
# Building the invocie form and the article formset
|
||||
invoice_form = CustomInvoiceForm(request.POST or None)
|
||||
|
||||
article_formset = formset_factory(SelectArticleForm)(
|
||||
articles_formset = formset_factory(SelectArticleForm)(
|
||||
request.POST or None,
|
||||
form_kwargs={'user': request.user, 'target_user': user}
|
||||
form_kwargs={'user': request.user}
|
||||
)
|
||||
|
||||
if invoice_form.is_valid() and articles_formset.is_valid():
|
||||
|
@ -216,7 +216,6 @@ def new_custom_invoice(request):
|
|||
)
|
||||
return redirect(reverse('cotisations:index-custom-invoice'))
|
||||
|
||||
|
||||
return form({
|
||||
'factureform': invoice_form,
|
||||
'action_name': _("Create"),
|
||||
|
|
Loading…
Reference in a new issue