mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Create a new purchase order from a company page
This commit is contained in:
parent
c132f275f5
commit
04a9b1a980
@ -6,11 +6,32 @@
|
||||
|
||||
<h4>Open Purchase Orders</h4>
|
||||
|
||||
<div class='container' style='float: right;'>
|
||||
<div class='btn-group'>
|
||||
<button class='btn btn-primary' type='button' id='po-create' title='Create new purchase order'>New Purchase Order</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "order/po_table.html" with orders=company.outstanding_purchase_orders.all %}
|
||||
|
||||
{% if company.closed_purchase_orders.count > 0 %}
|
||||
{% include "order/po_table_collapse.html" with title="Closed Orders" orders=company.closed_purchase_orders.all %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$("#po-create").click(function() {
|
||||
launchModalForm("{% url 'purchase-order-create' %}",
|
||||
{
|
||||
data: {
|
||||
supplier: {{ company.id }},
|
||||
},
|
||||
follow: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
{% endblock %}
|
@ -7,7 +7,7 @@ Order model definitions
|
||||
from django.db import models
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from datetime import datetime
|
||||
@ -98,6 +98,9 @@ class PurchaseOrder(Order):
|
||||
help_text=_('Company')
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('purchase-order-detail', kwargs={'pk': self.id})
|
||||
|
||||
|
||||
class OrderLineItem(models.Model):
|
||||
""" Abstract model for an order line item
|
||||
|
@ -7,7 +7,7 @@
|
||||
</tr>
|
||||
{% for order in orders %}
|
||||
<tr>
|
||||
<td>{% include "hover_image.html" with image=order.supplier.image hover=True %}<a href="{{ order.supplier.get_absolute_url }}">{{ order.supplier.name }}</a></td>
|
||||
<td>{% include "hover_image.html" with image=order.supplier.image hover=True %}<a href="{{ order.supplier.get_absolute_url }}purchase-orders/">{{ order.supplier.name }}</a></td>
|
||||
<td><a href="{% url 'purchase-order-detail' order.id %}">{{ order }}</a></td>
|
||||
<td>{{ order.description }}</td>
|
||||
<td>{% include "order/order_status.html" %}</td>
|
||||
|
@ -31,6 +31,10 @@ InvenTree | {{ order }}
|
||||
<div class='col-sm-6'>
|
||||
<h4>Purchase Order Details</h4>
|
||||
<table class='table'>
|
||||
<tr>
|
||||
<td>Supplier</td>
|
||||
<td><a href="{% url 'company-detail' order.supplier.id %}">{{ order.supplier }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td>{% include "order/order_status.html" %}</td>
|
||||
@ -57,7 +61,7 @@ InvenTree | {{ order }}
|
||||
|
||||
<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 %}
|
||||
{% if order.status == OrderStatus.PENDING and order.lines.count > 0 %}
|
||||
<button type='button' class='btn btn-primary' id='place-order'>Place Order</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@ from django.views.generic import DetailView, ListView
|
||||
from django.forms import HiddenInput
|
||||
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem
|
||||
from company.models import SupplierPart
|
||||
from company.models import Company, SupplierPart
|
||||
|
||||
from . import forms as order_forms
|
||||
|
||||
@ -70,6 +70,15 @@ class PurchaseOrderCreate(AjaxCreateView):
|
||||
|
||||
initials['status'] = OrderStatus.PENDING
|
||||
|
||||
supplier_id = self.request.GET.get('supplier', None)
|
||||
|
||||
if supplier_id:
|
||||
try:
|
||||
supplier = Company.objects.get(id=supplier_id)
|
||||
initials['supplier'] = supplier
|
||||
except Company.DoesNotExist:
|
||||
pass
|
||||
|
||||
return initials
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user