mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Started implementation of multi-step form for purchase order file uplod
This commit is contained in:
parent
5d214fc869
commit
b847604f15
@ -263,6 +263,7 @@ INSTALLED_APPS = [
|
||||
'djmoney.contrib.exchange', # django-money exchange rates
|
||||
'error_report', # Error reporting in the admin interface
|
||||
'django_q',
|
||||
'formtools', # Form wizard tools
|
||||
]
|
||||
|
||||
MIDDLEWARE = CONFIG.get('middleware', [
|
||||
|
@ -5,6 +5,8 @@ Django forms for interacting with common objects
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
|
||||
from InvenTree.forms import HelperForm
|
||||
|
||||
from .models import InvenTreeSetting
|
||||
@ -21,3 +23,18 @@ class SettingEditForm(HelperForm):
|
||||
fields = [
|
||||
'value'
|
||||
]
|
||||
|
||||
|
||||
class UploadFile(forms.Form):
|
||||
''' Step 1 '''
|
||||
first_name = forms.CharField(max_length=100)
|
||||
|
||||
|
||||
class MatchField(forms.Form):
|
||||
''' Step 2 '''
|
||||
last_name = forms.CharField(max_length=100)
|
||||
|
||||
|
||||
class MatchPart(forms.Form):
|
||||
''' Step 3 '''
|
||||
age = forms.IntegerField()
|
||||
|
@ -8,6 +8,8 @@ from __future__ import unicode_literals
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.forms import CheckboxInput, Select
|
||||
|
||||
from formtools.wizard.views import SessionWizardView
|
||||
|
||||
from InvenTree.views import AjaxUpdateView
|
||||
from InvenTree.helpers import str2bool
|
||||
|
||||
@ -101,3 +103,12 @@ class SettingEdit(AjaxUpdateView):
|
||||
|
||||
if not str2bool(value, test=True) and not str2bool(value, test=False):
|
||||
form.add_error('value', _('Supplied value must be a boolean'))
|
||||
|
||||
|
||||
class FileUploadWizardView(SessionWizardView):
|
||||
# file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'file_uploads'))
|
||||
form_list = [
|
||||
forms.UploadFile,
|
||||
forms.MatchField,
|
||||
forms.MatchPart,
|
||||
]
|
||||
|
@ -14,6 +14,12 @@
|
||||
{% trans "Details" %}
|
||||
</a>
|
||||
</li>
|
||||
<li class='list-group-item {% if tab == "upload" %}active{% endif %}' title='{% trans "Upload File" %}'>
|
||||
<a href='{% url "po-upload" order.id %}'>
|
||||
<span class='fas fa-file-upload'></span>
|
||||
{% trans "Upload File" %}
|
||||
</a>
|
||||
</li>
|
||||
<li class='list-group-item {% if tab == "received" %}active{% endif %}' title='{% trans "Received Stock Items" %}'>
|
||||
<a href='{% url "po-received" order.id %}'>
|
||||
<span class='fas fa-sign-in-alt'></span>
|
||||
|
42
InvenTree/order/templates/order/po_upload.html
Normal file
42
InvenTree/order/templates/order/po_upload.html
Normal file
@ -0,0 +1,42 @@
|
||||
{% extends "order/order_base.html" %}
|
||||
|
||||
{% load inventree_extras %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% block menubar %}
|
||||
{% include 'order/po_navbar.html' with tab='upload' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block heading %}
|
||||
{{ wizard.form.media }}
|
||||
{% endblock %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<table>
|
||||
{{ wizard.management_form }}
|
||||
{% if wizard.form.forms %}
|
||||
{{ wizard.form.management_form }}
|
||||
{% for form in wizard.form.forms %}
|
||||
{{ form }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{{ wizard.form }}
|
||||
{% endif %}
|
||||
</table>
|
||||
{% if wizard.steps.prev %}
|
||||
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
|
||||
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
|
||||
{% endif %}
|
||||
<input type="submit" value="{% trans "submit" %}"/>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
{% endblock %}
|
@ -17,6 +17,7 @@ purchase_order_detail_urls = [
|
||||
url(r'^receive/', views.PurchaseOrderReceive.as_view(), name='po-receive'),
|
||||
url(r'^complete/', views.PurchaseOrderComplete.as_view(), name='po-complete'),
|
||||
|
||||
url(r'^upload/', views.PurchaseOrderUpload.as_view(), name='po-upload'),
|
||||
url(r'^export/', views.PurchaseOrderExport.as_view(), name='po-export'),
|
||||
|
||||
url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'),
|
||||
|
@ -9,6 +9,7 @@ from django.db import transaction
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic import DetailView, ListView, UpdateView
|
||||
from django.views.generic.edit import FormMixin
|
||||
@ -27,6 +28,7 @@ from stock.models import StockItem, StockLocation
|
||||
from part.models import Part
|
||||
|
||||
from common.models import InvenTreeSetting
|
||||
from common.views import FileUploadWizardView
|
||||
|
||||
from . import forms as order_forms
|
||||
|
||||
@ -564,6 +566,24 @@ class SalesOrderShip(AjaxUpdateView):
|
||||
return self.renderJsonResponse(request, form, data, context)
|
||||
|
||||
|
||||
class PurchaseOrderUpload(FileUploadWizardView):
|
||||
''' Upload File Wizard View '''
|
||||
|
||||
template_name = "order/po_upload.html"
|
||||
|
||||
def get_context_data(self, form, **kwargs):
|
||||
context = super().get_context_data(form=form, **kwargs)
|
||||
|
||||
order = get_object_or_404(PurchaseOrder, pk=self.kwargs['pk'])
|
||||
|
||||
context.update({'order': order})
|
||||
|
||||
return context
|
||||
|
||||
def done(self, form_list, **kwargs):
|
||||
return HttpResponseRedirect(reverse('po-detail', kwargs={'pk': self.kwargs['pk']}))
|
||||
|
||||
|
||||
class PurchaseOrderExport(AjaxView):
|
||||
""" File download for a purchase order
|
||||
|
||||
|
@ -32,5 +32,6 @@ python-barcode[images]==0.13.1 # Barcode generator
|
||||
qrcode[pil]==6.1 # QR code generator
|
||||
django-q==1.3.4 # Background task scheduling
|
||||
gunicorn>=20.0.4 # Gunicorn web server
|
||||
django-formtools==2.3 # Form wizard tools
|
||||
|
||||
inventree # Install the latest version of the InvenTree API python library
|
||||
|
Loading…
Reference in New Issue
Block a user