mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Form for creating a new SalesOrder
This commit is contained in:
parent
ebbcff3c7f
commit
ce1dd88129
@ -144,6 +144,11 @@ function loadPurchaseOrderTable(table, options) {
|
||||
return imageHoverIcon(row.supplier_detail.image) + renderLink(row.supplier_detail.name, `/company/${row.supplier}/purchase-orders/`);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'supplier_reference',
|
||||
title: 'Supplier Reference',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'description',
|
||||
@ -212,6 +217,11 @@ function loadSalesOrderTable(table, options) {
|
||||
return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/sales-orders/`);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'customer_reference',
|
||||
title: 'Customer Reference',
|
||||
sotrable: true,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'description',
|
||||
|
@ -15,6 +15,7 @@ from InvenTree.fields import RoundingDecimalFormField
|
||||
|
||||
from stock.models import StockLocation
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAttachment
|
||||
from .models import SalesOrder, SalesOrderLineItem
|
||||
|
||||
|
||||
class IssuePurchaseOrderForm(HelperForm):
|
||||
@ -75,6 +76,21 @@ class EditPurchaseOrderForm(HelperForm):
|
||||
]
|
||||
|
||||
|
||||
class EditSalesOrderForm(HelperForm):
|
||||
""" Form for editing a SalesOrder object """
|
||||
|
||||
class Meta:
|
||||
model = SalesOrder
|
||||
fields = [
|
||||
'reference',
|
||||
'customer',
|
||||
'customer_reference',
|
||||
'description',
|
||||
'link'
|
||||
]
|
||||
|
||||
|
||||
|
||||
class EditPurchaseOrderAttachmentForm(HelperForm):
|
||||
""" Form for editing a PurchaseOrderAttachment object """
|
||||
|
||||
|
@ -254,6 +254,9 @@ class SalesOrder(Order):
|
||||
customer_reference: Optional field for customer order reference code
|
||||
"""
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('so-detail', kwargs={'pk': self.id})
|
||||
|
||||
customer = models.ForeignKey(Company,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
|
@ -41,10 +41,12 @@ $("#so-lines-table").inventreeTable({
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'reference',
|
||||
title: 'Reference'
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'quantity',
|
||||
title: 'Quantity',
|
||||
formatter: function(value, row, index, field) {
|
||||
|
@ -33,4 +33,12 @@ loadSalesOrderTable("#sales-order-table", {
|
||||
url: "{% url 'api-so-list' %}",
|
||||
});
|
||||
|
||||
$("#so-create").click(function() {
|
||||
launchModalForm("{% url 'so-create' %}",
|
||||
{
|
||||
follow: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
{% endblock %}
|
@ -68,6 +68,8 @@ sales_order_detail_urls = [
|
||||
|
||||
sales_order_urls = [
|
||||
|
||||
url(r'^new/', views.SalesOrderCreate.as_view(), name='so-create'),
|
||||
|
||||
# Display detail view for a single SalesOrder
|
||||
url(r'^(?P<pk>\d+)/', include(sales_order_detail_urls)),
|
||||
|
||||
|
@ -216,6 +216,35 @@ class PurchaseOrderCreate(AjaxCreateView):
|
||||
self.object.save()
|
||||
|
||||
|
||||
class SalesOrderCreate(AjaxCreateView):
|
||||
""" View for creating a new SalesOrder object """
|
||||
|
||||
model = SalesOrder
|
||||
ajax_form_title = _("Create Sales Order")
|
||||
form_class = order_forms.EditSalesOrderForm
|
||||
|
||||
def get_initial(self):
|
||||
initials = super().get_initial().copy()
|
||||
|
||||
initials['status'] = OrderStatus.PENDING
|
||||
|
||||
customer_id = self.request.GET.get('customer', None)
|
||||
|
||||
if customer_id is not None:
|
||||
try:
|
||||
customer = Company.objects.get(id=customer_id)
|
||||
initials['customer'] = customer
|
||||
except (Company.DoesNotExist, ValueError):
|
||||
pass
|
||||
|
||||
return initials
|
||||
|
||||
def post_save(self, **kwargs):
|
||||
# Record the user who created this sales order
|
||||
self.object.created_by = self.request.user
|
||||
self.object.save()
|
||||
|
||||
|
||||
class PurchaseOrderEdit(AjaxUpdateView):
|
||||
""" View for editing a PurchaseOrder using a modal form """
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
<a class='dropdown-toggle' data-toggle='dropdown' href='#'><span class='fas fa-truck icon-header'></span>{% trans "Sell" %}</a>
|
||||
<ul class='dropdown-menu'>
|
||||
<li><a href="{% url 'customer-index' %}"><span class='fas fa-user-tie icon-header'></span>{% trans "Customers" %}</a>
|
||||
<li><a href="#"><span class='fas fa-list icon-header'></span>{% trans "Sales Orders" %}</a></li>
|
||||
<li><a href="{% url 'so-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Sales Orders" %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user