mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add form / view to edit purchase order details
- Cannot edit the COMPANY if there are line items already
This commit is contained in:
parent
bcc08f982b
commit
96eb4086cf
@ -7,10 +7,35 @@ from __future__ import unicode_literals
|
||||
|
||||
from InvenTree.forms import HelperForm
|
||||
|
||||
from .models import PurchaseOrderLineItem
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem
|
||||
|
||||
|
||||
class IssuePurchaseOrderForm(HelperForm):
|
||||
|
||||
class Meta:
|
||||
model = PurchaseOrder
|
||||
fields = [
|
||||
'status',
|
||||
]
|
||||
|
||||
|
||||
class EditPurchaseOrderForm(HelperForm):
|
||||
""" Form for editing a PurchaseOrder object """
|
||||
|
||||
class Meta:
|
||||
model = PurchaseOrder
|
||||
fields = [
|
||||
'reference',
|
||||
'supplier',
|
||||
'description',
|
||||
'URL',
|
||||
'status',
|
||||
'notes'
|
||||
]
|
||||
|
||||
|
||||
class EditPurchaseOrderLineItemForm(HelperForm):
|
||||
""" Form for editing a PurchaseOrderLineItem object """
|
||||
|
||||
class Meta:
|
||||
model = PurchaseOrderLineItem
|
||||
|
1
InvenTree/order/templates/order/order_issue.html
Normal file
1
InvenTree/order/templates/order/order_issue.html
Normal file
@ -0,0 +1 @@
|
||||
{% extends "modal_form.html" %}
|
@ -1,13 +1,13 @@
|
||||
{% if order.status == OrderStatus.PENDING %}
|
||||
<span class='label label-info'>
|
||||
<span class='label label-large label-info'>
|
||||
{% elif order.status == OrderStatus.PLACED %}
|
||||
<span class='label label-primary'>
|
||||
<span class='label label-large label-primary'>
|
||||
{% elif order.status == OrderStatus.COMPLETE %}
|
||||
<span class='label label-success'>
|
||||
<span class='label label-large label-success'>
|
||||
{% elif order.status == OrderStatus.CANCELLED or order.status == OrderStatus.RETURNED %}
|
||||
<span class='label label-warning'>
|
||||
<span class='label label-large label-warning'>
|
||||
{% else %}
|
||||
<span class='label label-danger'>
|
||||
<span class='label label-large label-danger'>
|
||||
{% endif %}
|
||||
{{ order.get_status_display }}
|
||||
</span>
|
@ -55,6 +55,13 @@ InvenTree | {{ order }}
|
||||
|
||||
<hr>
|
||||
|
||||
<div class='btn-group' style='float: right;'>
|
||||
<button type='button' class='btn btn-primary' id='edit-order'>Edit Order</button>
|
||||
{% if order.status == OrderStatus.PENDING %}
|
||||
<button type='button' class='btn btn-primary' id='issue-order'>Issue Order</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h4>Order Items</h4>
|
||||
|
||||
<button type='button' class='btn btn-default' id='new-po-line'>Add Line Item</button>
|
||||
@ -96,6 +103,14 @@ InvenTree | {{ order }}
|
||||
|
||||
{% block js_ready %}
|
||||
|
||||
$("#edit-order").click(function() {
|
||||
launchModalForm("{% url 'purchase-order-edit' order.id %}",
|
||||
{
|
||||
reload: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$('#new-po-line').click(function() {
|
||||
launchModalForm("{% url 'po-line-item-create' %}",
|
||||
{
|
||||
|
@ -11,6 +11,9 @@ from . import views
|
||||
|
||||
purchase_order_detail_urls = [
|
||||
|
||||
url(r'^edit/?', views.PurchaseOrderEdit.as_view(), name='purchase-order-edit'),
|
||||
url(r'^issue/?', views.PurchaseOrderIssue.as_view(), name='purchase-order-issue'),
|
||||
|
||||
url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='purchase-order-detail'),
|
||||
]
|
||||
|
||||
|
@ -9,7 +9,8 @@ from django.views.generic import DetailView, ListView
|
||||
from django.forms import HiddenInput
|
||||
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem
|
||||
from .forms import EditPurchaseOrderLineItemForm
|
||||
|
||||
from . import forms as order_forms
|
||||
|
||||
from InvenTree.views import AjaxCreateView, AjaxUpdateView
|
||||
|
||||
@ -46,14 +47,41 @@ class PurchaseOrderDetail(DetailView):
|
||||
return ctx
|
||||
|
||||
|
||||
class PurchaseOrderEdit(AjaxUpdateView):
|
||||
""" View for editing a PurchaseOrder using a modal form """
|
||||
|
||||
model = PurchaseOrder
|
||||
ajax_form_title = 'Edit Purchase Order'
|
||||
form_class = order_forms.EditPurchaseOrderForm
|
||||
|
||||
def get_form(self):
|
||||
|
||||
form = super(AjaxUpdateView, self).get_form()
|
||||
|
||||
order = self.get_object()
|
||||
|
||||
if order.lines.count() > 0:
|
||||
form.fields['supplier'].widget = HiddenInput()
|
||||
|
||||
return form
|
||||
|
||||
|
||||
class PurchaseOrderIssue(AjaxUpdateView):
|
||||
""" View for changing a purchase order from 'PENDING' to 'ISSUED' """
|
||||
|
||||
model = PurchaseOrder
|
||||
ajax_form_title = 'Issue Order'
|
||||
ajax_template_name = "order/order_issue.html"
|
||||
form_class = order_forms.IssuePurchaseOrderForm
|
||||
|
||||
|
||||
class POLineItemCreate(AjaxCreateView):
|
||||
""" AJAX view for creating a new PurchaseOrderLineItem object
|
||||
"""
|
||||
|
||||
model = PurchaseOrderLineItem
|
||||
context_object_name = 'line'
|
||||
form_class = EditPurchaseOrderLineItemForm
|
||||
ajax_template_name = 'modal_form.html'
|
||||
form_class = order_forms.EditPurchaseOrderLineItemForm
|
||||
ajax_form_title = 'Add Line Item'
|
||||
|
||||
def get_form(self):
|
||||
@ -113,6 +141,6 @@ class POLineItemCreate(AjaxCreateView):
|
||||
class POLineItemEdit(AjaxUpdateView):
|
||||
|
||||
model = PurchaseOrderLineItem
|
||||
form_class = EditPurchaseOrderLineItemForm
|
||||
form_class = order_forms.EditPurchaseOrderLineItemForm
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_action = 'Edit Line Item'
|
||||
|
@ -38,7 +38,6 @@
|
||||
/* Extra label styles */
|
||||
|
||||
.label-large {
|
||||
padding: 5px;
|
||||
margin: 3px;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user