mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
SourceItem only for SupplierPart, added logic to templates
This commit is contained in:
parent
e6dfb7da52
commit
50adb2ac61
@ -128,6 +128,8 @@ class EditSupplierPartForm(HelperForm):
|
||||
'part',
|
||||
'supplier',
|
||||
'SKU',
|
||||
'manufacturer',
|
||||
'MPN',
|
||||
'description',
|
||||
'link',
|
||||
'note',
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Generated by Django 3.0.7 on 2021-03-24 14:18
|
||||
# Generated by Django 3.0.7 on 2021-03-29 18:53
|
||||
|
||||
import InvenTree.fields
|
||||
from django.db import migrations, models
|
||||
@ -9,10 +9,24 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('part', '0063_bomitem_inherited'),
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('company', '0031_auto_20210103_2215'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SourceItem',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('part_id', models.PositiveIntegerField()),
|
||||
('part_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='supplierpart',
|
||||
name='source_item',
|
||||
field=models.ForeignKey(blank=True, help_text='Select part', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='supplier_parts', to='company.SourceItem', verbose_name='Part'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ManufacturerPart',
|
||||
fields=[
|
||||
|
@ -1,33 +0,0 @@
|
||||
# Generated by Django 3.0.7 on 2021-03-29 17:00
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('company', '0032_manufacturerpart'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SourceItem',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('part_id', models.PositiveIntegerField()),
|
||||
('part_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='manufacturerpart',
|
||||
name='source_item',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='manufacturer_parts', to='company.SourceItem', verbose_name='Sourcing Item'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='supplierpart',
|
||||
name='source_item',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='supplier_parts', to='company.SourceItem', verbose_name='Sourcing Item'),
|
||||
),
|
||||
]
|
@ -302,7 +302,6 @@ class ManufacturerPart(models.Model):
|
||||
|
||||
Attributes:
|
||||
part: Link to the master Part
|
||||
source_item: The sourcing item linked to this ManufacturerPart instance
|
||||
manufacturer: Company that manufactures the ManufacturerPart
|
||||
MPN: Manufacture part number
|
||||
link: Link to external website for this manufacturer part
|
||||
@ -321,12 +320,6 @@ class ManufacturerPart(models.Model):
|
||||
help_text=_('Select part'),
|
||||
)
|
||||
|
||||
source_item = models.ForeignKey(SourceItem, on_delete=models.CASCADE,
|
||||
blank=True, null=True,
|
||||
related_name='manufacturer_parts',
|
||||
verbose_name=_('Sourcing Item'),
|
||||
)
|
||||
|
||||
manufacturer = models.ForeignKey(
|
||||
Company,
|
||||
on_delete=models.CASCADE,
|
||||
@ -364,7 +357,7 @@ class SupplierPart(models.Model):
|
||||
A Part may be available from multiple suppliers
|
||||
|
||||
Attributes:
|
||||
part: Link to the master Part
|
||||
part: Link to the master Part (Obsolete)
|
||||
source_item: The sourcing item linked to this SupplierPart instance
|
||||
supplier: Company that supplies this SupplierPart object
|
||||
SKU: Stock keeping unit (supplier part number)
|
||||
@ -398,7 +391,8 @@ class SupplierPart(models.Model):
|
||||
source_item = models.ForeignKey(SourceItem, on_delete=models.CASCADE,
|
||||
blank=True, null=True,
|
||||
related_name='supplier_parts',
|
||||
verbose_name=_('Sourcing Item'),
|
||||
verbose_name=_('Part'),
|
||||
help_text=_('Select part'),
|
||||
)
|
||||
|
||||
supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
|
||||
|
@ -4,31 +4,26 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block menubar %}
|
||||
{% include 'company/navbar.html' with tab='parts' %}
|
||||
{% include 'company/navbar.html' with tab='manufacturer_parts' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block heading %}
|
||||
{% trans "Supplier Parts" %}
|
||||
{% trans "Manufacturer Parts" %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block details %}
|
||||
{% setting_object 'PART_ENABLE_MANUFACTURER_PARTS' as manufacturer_parts %}
|
||||
|
||||
{% if manufacturer_parts.value == "True" %}
|
||||
{% if roles.purchase_order.change %}
|
||||
<div id='button-toolbar'>
|
||||
<div class='button-toolbar container-fluid'>
|
||||
<div class='btn-group role='group'>
|
||||
{% if roles.purchase_order.add %}
|
||||
{% if manufacturer_parts.value == "True" and company.is_manufacturer %}
|
||||
<button class="btn btn-success" id='manufacturer-part-create' title='{% trans "Create new manufacturer part" %}'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "New Manufacturer Part" %}
|
||||
</button>
|
||||
{% else %}
|
||||
<button class="btn btn-success" id='supplier-part-create' title='{% trans "Create new supplier part" %}'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div class='btn-group'>
|
||||
<div class="dropdown" style="float: right;">
|
||||
@ -52,10 +47,15 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='part-table' data-toolbar='#button-toolbar'>
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
<div class='alert alert-block alert-warning'>
|
||||
{% trans "Manufactured parts are disabled. Admin users can enable them in the global settings." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
@ -86,32 +86,6 @@
|
||||
});
|
||||
});
|
||||
|
||||
$("#supplier-part-create").click(function () {
|
||||
launchModalForm(
|
||||
"{% url 'supplier-part-create' %}",
|
||||
{
|
||||
data: {
|
||||
supplier: {{ company.id }},
|
||||
},
|
||||
reload: true,
|
||||
secondary: [
|
||||
{
|
||||
field: 'part',
|
||||
label: '{% trans "New Part" %}',
|
||||
title: '{% trans "Create new Part" %}',
|
||||
url: "{% url 'part-create' %}"
|
||||
},
|
||||
{
|
||||
field: 'supplier',
|
||||
label: "{% trans 'New Supplier' %}",
|
||||
title: "{% trans 'Create new Supplier' %}",
|
||||
url: "{% url 'supplier-create' %}",
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
{% if manufacturer_parts.value == "True" and company.is_manufacturer %}
|
||||
loadManufacturerPartTable(
|
||||
"#part-table",
|
||||
"{% url 'api-manufacturer-part-list' %}",
|
||||
@ -123,20 +97,6 @@
|
||||
},
|
||||
}
|
||||
);
|
||||
{% else %}
|
||||
loadSupplierPartTable(
|
||||
"#part-table",
|
||||
"{% url 'api-supplier-part-list' %}",
|
||||
{
|
||||
params: {
|
||||
part_detail: true,
|
||||
supplier_detail: true,
|
||||
manufacturer_detail: true,
|
||||
company: {{ company.id }},
|
||||
},
|
||||
}
|
||||
);
|
||||
{% endif %}
|
||||
|
||||
$("#multi-part-delete").click(function() {
|
||||
var selections = $("#part-table").bootstrapTable("getSelections");
|
||||
@ -147,12 +107,7 @@
|
||||
parts.push(item.pk);
|
||||
});
|
||||
|
||||
{% if company.is_manufacturer %}
|
||||
var url = "{% url 'manufacturer-part-delete' %}"
|
||||
{% endif %}
|
||||
{% if company.is_supplier %}
|
||||
var url = "{% url 'supplier-part-delete' %}"
|
||||
{% endif %}
|
||||
|
||||
launchModalForm(url, {
|
||||
data: {
|
128
InvenTree/company/templates/company/detail_supplier_part.html
Normal file
128
InvenTree/company/templates/company/detail_supplier_part.html
Normal file
@ -0,0 +1,128 @@
|
||||
{% extends "company/company_base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block menubar %}
|
||||
{% include 'company/navbar.html' with tab='supplier_parts' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block heading %}
|
||||
{% trans "Supplier Parts" %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block details %}
|
||||
{% if roles.purchase_order.change %}
|
||||
<div id='button-toolbar'>
|
||||
<div class='button-toolbar container-fluid'>
|
||||
<div class='btn-group role='group'>
|
||||
{% if roles.purchase_order.add %}
|
||||
<button class="btn btn-success" id='supplier-part-create' title='{% trans "Create new supplier part" %}'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
<div class='btn-group'>
|
||||
<div class="dropdown" style="float: right;">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% if roles.purchase_order.add %}
|
||||
<li><a href='#' id='multi-part-order' title='{% trans "Order parts" %}'>{% trans "Order Parts" %}</a></li>
|
||||
{% endif %}
|
||||
{% if roles.purchase_order.delete %}
|
||||
<li><a href='#' id='multi-part-delete' title='{% trans "Delete parts" %}'>{% trans "Delete Parts" %}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='filter-list' id='filter-list-supplier-part'>
|
||||
<!-- Empty div (will be filled out with available BOM filters) -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='part-table' data-toolbar='#button-toolbar'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$("#supplier-part-create").click(function () {
|
||||
launchModalForm(
|
||||
"{% url 'supplier-part-create' %}",
|
||||
{
|
||||
data: {
|
||||
supplier: {{ company.id }},
|
||||
},
|
||||
reload: true,
|
||||
secondary: [
|
||||
{
|
||||
field: 'part',
|
||||
label: '{% trans "New Part" %}',
|
||||
title: '{% trans "Create new Part" %}',
|
||||
url: "{% url 'part-create' %}"
|
||||
},
|
||||
{
|
||||
field: 'supplier',
|
||||
label: "{% trans 'New Supplier' %}",
|
||||
title: "{% trans 'Create new Supplier' %}",
|
||||
url: "{% url 'supplier-create' %}",
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
loadSupplierPartTable(
|
||||
"#part-table",
|
||||
"{% url 'api-supplier-part-list' %}",
|
||||
{
|
||||
params: {
|
||||
part_detail: true,
|
||||
supplier_detail: true,
|
||||
manufacturer_detail: true,
|
||||
company: {{ company.id }},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
$("#multi-part-delete").click(function() {
|
||||
var selections = $("#part-table").bootstrapTable("getSelections");
|
||||
|
||||
var parts = [];
|
||||
|
||||
selections.forEach(function(item) {
|
||||
parts.push(item.pk);
|
||||
});
|
||||
|
||||
var url = "{% url 'supplier-part-delete' %}"
|
||||
|
||||
launchModalForm(url, {
|
||||
data: {
|
||||
parts: parts,
|
||||
},
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
||||
$("#multi-part-order").click(function() {
|
||||
var selections = $("#part-table").bootstrapTable("getSelections");
|
||||
|
||||
var parts = [];
|
||||
|
||||
selections.forEach(function(item) {
|
||||
parts.push(item.part);
|
||||
});
|
||||
|
||||
launchModalForm("/order/purchase-order/order-parts/", {
|
||||
data: {
|
||||
parts: parts,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
{% endblock %}
|
@ -83,7 +83,7 @@ src="{% static 'img/blank_image.png' %}"
|
||||
<tr>
|
||||
<td><span class='fas fa-industry'></span></td>
|
||||
<td>{% trans "Manufacturer" %}</td>
|
||||
<td><a href="{% url 'company-detail-parts' part.manufacturer.id %}">{{ part.manufacturer.name }}</a></td></tr>
|
||||
<td><a href="{% url 'company-detail-manufacturer-parts' part.manufacturer.id %}">{{ part.manufacturer.name }}</a></td></tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-hashtag'></span></td>
|
||||
<td>{% trans "MPN" %}</td>
|
||||
@ -125,7 +125,7 @@ $('#delete-part').click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'manufacturer-part-delete' %}?part={{ part.id }}",
|
||||
{
|
||||
redirect: "{% url 'company-detail-parts' part.manufacturer.id %}"
|
||||
redirect: "{% url 'company-detail-manufacturer-parts' part.manufacturer.id %}"
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -22,7 +22,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>{% trans "Manufacturer" %}</td><td><a href="{% url 'company-detail-parts' part.manufacturer.id %}">{{ part.manufacturer.name }}</a></td></tr>
|
||||
<tr><td>{% trans "Manufacturer" %}</td><td><a href="{% url 'company-detail-manufacturer-parts' part.manufacturer.id %}">{{ part.manufacturer.name }}</a></td></tr>
|
||||
<tr><td>{% trans "MPN" %}</td><td>{{ part.MPN }}</tr></tr>
|
||||
{% if part.link %}
|
||||
<tr><td>{% trans "External Link" %}</td><td><a href="{{ part.link }}">{{ part.link }}</a></td></tr>
|
||||
|
@ -19,17 +19,18 @@
|
||||
</li>
|
||||
|
||||
{% if manufacturer_parts.value == "True" and company.is_manufacturer %}
|
||||
<li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Manufactured Parts" %}'>
|
||||
<a href='{% url "company-detail-parts" company.id %}'>
|
||||
<span class='fas fa-shapes'></span>
|
||||
{% trans "Parts" %}
|
||||
<li class='list-group-item {% if tab == "manufacturer_parts" %}active{% endif %}' title='{% trans "Manufactured Parts" %}'>
|
||||
<a href='{% url "company-detail-manufacturer-parts" company.id %}'>
|
||||
<span class='fas fa-building'></span>
|
||||
{% trans "Manufactured Parts" %}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Supplied Parts" %}'>
|
||||
<a href='{% url "company-detail-parts" company.id %}'>
|
||||
<span class='fas fa-shapes'></span>
|
||||
{% trans "Parts" %}
|
||||
{% endif %}
|
||||
{% if company.is_supplier or company.is_manufacturer %}
|
||||
<li class='list-group-item {% if tab == "supplier_parts" %}active{% endif %}' title='{% trans "Supplied Parts" %}'>
|
||||
<a href='{% url "company-detail-supplier-parts" company.id %}'>
|
||||
<span class='fas fa-warehouse'></span>
|
||||
{% trans "Supplied Parts" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@ -81,7 +81,7 @@ src="{% static 'img/blank_image.png' %}"
|
||||
<tr>
|
||||
<td><span class='fas fa-building'></span></td>
|
||||
<td>{% trans "Supplier" %}</td>
|
||||
<td><a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<td><a href="{% url 'company-detail-supplier-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-hashtag'></span></td>
|
||||
<td>{% trans "SKU" %}</td>
|
||||
@ -91,7 +91,7 @@ src="{% static 'img/blank_image.png' %}"
|
||||
<tr>
|
||||
<td><span class='fas fa-industry'></span></td>
|
||||
<td>{% trans "Manufacturer" %}</td>
|
||||
<td><a href="{% url 'company-detail-parts' part.manufacturer.id %}">{{ part.manufacturer.name }}</a></td></tr>
|
||||
<td><a href="{% url 'company-detail-manufacturer-parts' part.manufacturer.id %}">{{ part.manufacturer.name }}</a></td></tr>
|
||||
{% endif %}
|
||||
{% if part.MPN %}
|
||||
<tr>
|
||||
@ -150,7 +150,7 @@ $('#delete-part').click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'supplier-part-delete' %}?part={{ part.id }}",
|
||||
{
|
||||
redirect: "{% url 'company-detail-parts' part.supplier.id %}"
|
||||
redirect: "{% url 'company-detail-supplier-parts' part.supplier.id %}"
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -22,7 +22,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>{% trans "Supplier" %}</td><td><a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr><td>{% trans "Supplier" %}</td><td><a href="{% url 'company-detail-supplier-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr><td>{% trans "SKU" %}</td><td>{{ part.SKU }}</tr></tr>
|
||||
{% if part.link %}
|
||||
<tr><td>{% trans "External Link" %}</td><td><a href="{{ part.link }}">{{ part.link }}</a></td></tr>
|
||||
|
@ -13,7 +13,8 @@ company_detail_urls = [
|
||||
|
||||
# url(r'orders/?', views.CompanyDetail.as_view(template_name='company/orders.html'), name='company-detail-orders'),
|
||||
|
||||
url(r'^parts/', views.CompanyDetail.as_view(template_name='company/detail_part.html'), name='company-detail-parts'),
|
||||
url(r'^supplier-parts/', views.CompanyDetail.as_view(template_name='company/detail_supplier_part.html'), name='company-detail-supplier-parts'),
|
||||
url(r'^manufacturer-parts/', views.CompanyDetail.as_view(template_name='company/detail_manufacturer_part.html'), name='company-detail-manufacturer-parts'),
|
||||
url(r'^stock/', views.CompanyDetail.as_view(template_name='company/detail_stock.html'), name='company-detail-stock'),
|
||||
url(r'^purchase-orders/', views.CompanyDetail.as_view(template_name='company/purchase_orders.html'), name='company-detail-purchase-orders'),
|
||||
url(r'^assigned-stock/', views.CompanyDetail.as_view(template_name='company/assigned_stock.html'), name='company-detail-assigned-stock'),
|
||||
|
@ -1,6 +1,7 @@
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block menubar %}
|
||||
{% include 'part/navbar.html' with tab='manufacturers' %}
|
||||
@ -11,6 +12,9 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block details %}
|
||||
{% setting_object 'PART_ENABLE_MANUFACTURER_PARTS' as manufacturer_parts %}
|
||||
|
||||
{% if manufacturer_parts.value == "True" %}
|
||||
<div id='button-toolbar'>
|
||||
<div class='btn-group'>
|
||||
<button class="btn btn-success" id='manufacturer-create'>
|
||||
@ -27,6 +31,11 @@
|
||||
|
||||
<table class="table table-striped table-condensed" id='manufacturer-table' data-toolbar='#button-toolbar'>
|
||||
</table>
|
||||
{% else %}
|
||||
<div class='alert alert-block alert-warning'>
|
||||
{% trans "Manufactured parts are disabled. Admin users can enable them in the global settings." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
@ -70,6 +70,7 @@ class RuleSet(models.Model):
|
||||
'part_partstar',
|
||||
'company_supplierpart',
|
||||
'company_manufacturerpart',
|
||||
'company_sourceitem',
|
||||
],
|
||||
'stock_location': [
|
||||
'stock_stocklocation',
|
||||
|
Loading…
Reference in New Issue
Block a user