From 4ebd8cd6b1ab1d61c34c9f7813b7e28fd7a57aae Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 22 Apr 2018 22:44:49 +1000 Subject: [PATCH] Added company details tab --- .../templates/company/company_base.html | 3 - .../company/templates/company/delete.html | 8 +-- .../company/templates/company/detail.html | 25 +++++++ InvenTree/company/templates/company/edit.html | 2 +- wip/order_models.py | 69 +++++++++++++++++++ 5 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 wip/order_models.py diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 07bc1e38fb..c7fffec1e0 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -19,9 +19,6 @@

{{ company.name }}

{{ company.description }}

-
- -
diff --git a/InvenTree/company/templates/company/delete.html b/InvenTree/company/templates/company/delete.html index d42b93f864..5660439747 100644 --- a/InvenTree/company/templates/company/delete.html +++ b/InvenTree/company/templates/company/delete.html @@ -1,15 +1,15 @@ {% extends "delete_obj.html" %} {% block del_title %} -Are you sure you want to delete supplier '{{ supplier.name }}'? +Are you sure you want to delete company '{{ company.name }}'? {% endblock %} {% block del_body %} -{% if supplier.part_count > 0 %} -

There are {{ supplier.part_count }} parts sourced from this supplier.
+{% if company.part_count > 0 %} +

There are {{ company.part_count }} parts sourced from this company.
If this supplier is deleted, these supplier part entries will also be deleted.

diff --git a/InvenTree/company/templates/company/detail.html b/InvenTree/company/templates/company/detail.html index 075af4a628..fdb46e4621 100644 --- a/InvenTree/company/templates/company/detail.html +++ b/InvenTree/company/templates/company/detail.html @@ -4,4 +4,29 @@ {% include 'company/tabs.html' with tab='details' %} +

Company Details

+ + + + + + + + + + +
Customer{% include 'yesnolabel.html' with value=company.is_customer %}
Supplier{% include 'yesnolabel.html' with value=company.is_supplier %}
+ +{% if company.notes %} +
+
Notes
+
{{ company.notes }}
+
+{% endif %} + + + {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/edit.html b/InvenTree/company/templates/company/edit.html index 3e07e93362..e043fdb211 100644 --- a/InvenTree/company/templates/company/edit.html +++ b/InvenTree/company/templates/company/edit.html @@ -1,5 +1,5 @@ {% extends "create_edit_obj.html" %} {% block obj_title %} -Edit details for supplier '{{ supplier.name }}' +Edit details for company '{{ company.name }}' {% endblock %} \ No newline at end of file diff --git a/wip/order_models.py b/wip/order_models.py new file mode 100644 index 0000000000..018dba21bc --- /dev/null +++ b/wip/order_models.py @@ -0,0 +1,69 @@ +class SupplierOrder(models.Model): + """ + An order of parts from a supplier, made up of multiple line items + """ + + def get_absolute_url(self): + return "/supplier/order/{id}/".format(id=self.id) + + # Interal reference for this order + internal_ref = models.CharField(max_length=25, unique=True) + + supplier = models.ForeignKey(Company, on_delete=models.CASCADE, + related_name='orders') + + created_date = models.DateField(auto_now_add=True, editable=False) + + issued_date = models.DateField(blank=True, null=True, help_text="Date the purchase order was issued") + + notes = models.TextField(blank=True, help_text="Order notes") + + def __str__(self): + return "PO {ref} ({status})".format(ref=self.internal_ref, + status=self.get_status_display) + + PENDING = 10 # Order is pending (not yet placed) + PLACED = 20 # Order has been placed + RECEIVED = 30 # Order has been received + CANCELLED = 40 # Order was cancelled + LOST = 50 # Order was lost + + ORDER_STATUS_CODES = {PENDING: _("Pending"), + PLACED: _("Placed"), + CANCELLED: _("Cancelled"), + RECEIVED: _("Received"), + LOST: _("Lost") + } + + status = models.PositiveIntegerField(default=PENDING, + choices=ORDER_STATUS_CODES.items()) + + delivery_date = models.DateField(blank=True, null=True) + + + +class SupplierOrderLineItem(models.Model): + """ + A line item in a supplier order, corresponding to some quantity of part + """ + + class Meta: + unique_together = [ + ('order', 'line_number'), + ('order', 'supplier_part'), + ('order', 'internal_part'), + ] + + order = models.ForeignKey(SupplierOrder, on_delete=models.CASCADE) + + line_number = models.PositiveIntegerField(default=1) + + internal_part = models.ForeignKey(Part, null=True, blank=True, on_delete=models.SET_NULL) + + supplier_part = models.ForeignKey(SupplierPart, null=True, blank=True, on_delete=models.SET_NULL) + + quantity = models.PositiveIntegerField(default=1) + + notes = models.TextField(blank=True) + + received = models.BooleanField(default=False)