mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Create a new attachment against a PurchaseOrder
This commit is contained in:
parent
56a6943438
commit
834f80698b
@ -13,7 +13,7 @@ from mptt.fields import TreeNodeChoiceField
|
|||||||
from InvenTree.forms import HelperForm
|
from InvenTree.forms import HelperForm
|
||||||
|
|
||||||
from stock.models import StockLocation
|
from stock.models import StockLocation
|
||||||
from .models import PurchaseOrder, PurchaseOrderLineItem
|
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAttachment
|
||||||
|
|
||||||
|
|
||||||
class IssuePurchaseOrderForm(HelperForm):
|
class IssuePurchaseOrderForm(HelperForm):
|
||||||
@ -74,6 +74,18 @@ class EditPurchaseOrderForm(HelperForm):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class EditPurchaseOrderAttachmentForm(HelperForm):
|
||||||
|
""" Form for editing a PurchaseOrderAttachment object """
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = PurchaseOrderAttachment
|
||||||
|
fields = [
|
||||||
|
'order',
|
||||||
|
'attachment',
|
||||||
|
'comment'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class EditPurchaseOrderLineItemForm(HelperForm):
|
class EditPurchaseOrderLineItemForm(HelperForm):
|
||||||
""" Form for editing a PurchaseOrderLineItem object """
|
""" Form for editing a PurchaseOrderLineItem object """
|
||||||
|
|
||||||
|
@ -52,7 +52,11 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
$("#new-attachment").click(function() {
|
$("#new-attachment").click(function() {
|
||||||
|
launchModalForm("{% url 'purchase-order-attachment-create' %}?order={{ order.id }}",
|
||||||
|
{
|
||||||
|
reload: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#attachment-table").on('click', '.attachment-edit-button', function() {
|
$("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||||
|
@ -9,6 +9,10 @@ from django.conf.urls import url, include
|
|||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
purchase_order_attachment_urls = [
|
||||||
|
url(r'^new/', views.PurchaseOrderAttachmentCreate.as_view(), name='purchase-order-attachment-create'),
|
||||||
|
]
|
||||||
|
|
||||||
purchase_order_detail_urls = [
|
purchase_order_detail_urls = [
|
||||||
|
|
||||||
url(r'^cancel/?', views.PurchaseOrderCancel.as_view(), name='purchase-order-cancel'),
|
url(r'^cancel/?', views.PurchaseOrderCancel.as_view(), name='purchase-order-cancel'),
|
||||||
@ -49,6 +53,8 @@ purchase_order_urls = [
|
|||||||
|
|
||||||
url(r'^line/', include(po_line_urls)),
|
url(r'^line/', include(po_line_urls)),
|
||||||
|
|
||||||
|
url(r'^attachments/', include(purchase_order_attachment_urls)),
|
||||||
|
|
||||||
# Display complete list of purchase orders
|
# Display complete list of purchase orders
|
||||||
url(r'^.*$', views.PurchaseOrderIndex.as_view(), name='purchase-order-index'),
|
url(r'^.*$', views.PurchaseOrderIndex.as_view(), name='purchase-order-index'),
|
||||||
]
|
]
|
||||||
|
@ -15,7 +15,7 @@ from django.forms import HiddenInput
|
|||||||
import logging
|
import logging
|
||||||
from decimal import Decimal, InvalidOperation
|
from decimal import Decimal, InvalidOperation
|
||||||
|
|
||||||
from .models import PurchaseOrder, PurchaseOrderLineItem
|
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAttachment
|
||||||
from .admin import POLineItemResource
|
from .admin import POLineItemResource
|
||||||
from build.models import Build
|
from build.models import Build
|
||||||
from company.models import Company, SupplierPart
|
from company.models import Company, SupplierPart
|
||||||
@ -70,6 +70,49 @@ class PurchaseOrderDetail(DetailView):
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
class PurchaseOrderAttachmentCreate(AjaxCreateView):
|
||||||
|
"""
|
||||||
|
View for creating a new PurchaseOrderAtt
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = PurchaseOrderAttachment
|
||||||
|
form_class = order_forms.EditPurchaseOrderAttachmentForm
|
||||||
|
ajax_form_title = _("Add Purchase Order Attachment")
|
||||||
|
ajax_template_name = "modal_form.html"
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return {
|
||||||
|
"success": _("Added attachment")
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_initial(self):
|
||||||
|
"""
|
||||||
|
Get initial data for creating a new PurchaseOrderAttachment object.
|
||||||
|
|
||||||
|
- Client must request this form with a parent PurchaseOrder in midn.
|
||||||
|
- e.g. ?order=<pk>
|
||||||
|
"""
|
||||||
|
|
||||||
|
initials = super(AjaxCreateView, self).get_initial()
|
||||||
|
|
||||||
|
initials["order"] = PurchaseOrder.objects.get(id=self.request.GET.get('order', -1))
|
||||||
|
|
||||||
|
return initials
|
||||||
|
|
||||||
|
def get_form(self):
|
||||||
|
"""
|
||||||
|
Create a form to upload a new PurchaseOrderAttachment
|
||||||
|
|
||||||
|
- Hide the 'order' field
|
||||||
|
"""
|
||||||
|
|
||||||
|
form = super(AjaxCreateView, self).get_form()
|
||||||
|
|
||||||
|
form.fields['order'].widget = HiddenInput()
|
||||||
|
|
||||||
|
return form
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrderNotes(UpdateView):
|
class PurchaseOrderNotes(UpdateView):
|
||||||
""" View for updating the 'notes' field of a PurchaseOrder """
|
""" View for updating the 'notes' field of a PurchaseOrder """
|
||||||
|
|
||||||
|
@ -13,20 +13,20 @@ from django.conf.urls import url, include
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
part_attachment_urls = [
|
part_attachment_urls = [
|
||||||
url('^new/?', views.PartAttachmentCreate.as_view(), name='part-attachment-create'),
|
url(r'^new/?', views.PartAttachmentCreate.as_view(), name='part-attachment-create'),
|
||||||
url(r'^(?P<pk>\d+)/edit/?', views.PartAttachmentEdit.as_view(), name='part-attachment-edit'),
|
url(r'^(?P<pk>\d+)/edit/?', views.PartAttachmentEdit.as_view(), name='part-attachment-edit'),
|
||||||
url(r'^(?P<pk>\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'),
|
url(r'^(?P<pk>\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'),
|
||||||
]
|
]
|
||||||
|
|
||||||
part_parameter_urls = [
|
part_parameter_urls = [
|
||||||
|
|
||||||
url('^template/new/', views.PartParameterTemplateCreate.as_view(), name='part-param-template-create'),
|
url(r'^template/new/', views.PartParameterTemplateCreate.as_view(), name='part-param-template-create'),
|
||||||
url('^template/(?P<pk>\d+)/edit/', views.PartParameterTemplateEdit.as_view(), name='part-param-template-edit'),
|
url(r'^template/(?P<pk>\d+)/edit/', views.PartParameterTemplateEdit.as_view(), name='part-param-template-edit'),
|
||||||
url('^template/(?P<pk>\d+)/delete/', views.PartParameterTemplateDelete.as_view(), name='part-param-template-edit'),
|
url(r'^template/(?P<pk>\d+)/delete/', views.PartParameterTemplateDelete.as_view(), name='part-param-template-edit'),
|
||||||
|
|
||||||
url('^new/', views.PartParameterCreate.as_view(), name='part-param-create'),
|
url(r'^new/', views.PartParameterCreate.as_view(), name='part-param-create'),
|
||||||
url('^(?P<pk>\d+)/edit/', views.PartParameterEdit.as_view(), name='part-param-edit'),
|
url(r'^(?P<pk>\d+)/edit/', views.PartParameterEdit.as_view(), name='part-param-edit'),
|
||||||
url('^(?P<pk>\d+)/delete/', views.PartParameterDelete.as_view(), name='part-param-delete'),
|
url(r'^(?P<pk>\d+)/delete/', views.PartParameterDelete.as_view(), name='part-param-delete'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user