mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add a model to map multiple StockItem objects to a single SalesOrderLineItem
This commit is contained in:
parent
19cd0707a2
commit
7385099194
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.0.5 on 2020-04-21 00:14
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0026_stockitem_uid'),
|
||||
('order', '0023_auto_20200420_2309'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SalesOrderLineItemStockAssociation',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('line', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_items', to='order.SalesOrderLineItem')),
|
||||
('stock_item', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sales_order', to='stock.StockItem')),
|
||||
],
|
||||
),
|
||||
]
|
@ -291,7 +291,7 @@ class SalesOrderAttachment(InvenTreeAttachment):
|
||||
Model for storing file attachments against a SalesOrder object
|
||||
"""
|
||||
|
||||
def getSubDir(self):
|
||||
def getSubdir(self):
|
||||
return os.path.join("so_files", str(self.order.id))
|
||||
|
||||
order = models.ForeignKey(SalesOrder, on_delete=models.CASCADE, related_name='attachments')
|
||||
@ -372,3 +372,18 @@ class SalesOrderLineItem(OrderLineItem):
|
||||
|
||||
part = models.ForeignKey(Part, on_delete=models.SET_NULL, related_name='sales_order_line_items', null=True, help_text=_('Part'), limit_choices_to={'salable': True})
|
||||
|
||||
|
||||
class SalesOrderLineItemStockAssociation(models.Model):
|
||||
"""
|
||||
Associates StockItem objects with a SalesOrderLineItem.
|
||||
This model is used to match stock items with a sales order,
|
||||
for the purpose of sale / packing / shipping etc.
|
||||
|
||||
Attributes:
|
||||
line: ForeignKey link to a SalesOrderLineItem object -> A single SalesOrderLineItem can have multiple associated StockItem objects
|
||||
stock: OneToOne link to a StockItem object -> A StockItem object can only be mapped to a single SalesOrderLineItem
|
||||
"""
|
||||
|
||||
line = models.ForeignKey(SalesOrderLineItem, on_delete=models.CASCADE, related_name='stock_items')
|
||||
|
||||
stock_item = models.OneToOneField(StockItem, on_delete=models.CASCADE, related_name='sales_order')
|
||||
|
@ -51,10 +51,12 @@ $("#so-lines-table").inventreeTable({
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'line',
|
||||
title: 'Line',
|
||||
formatter: function(value, row, index, field) {
|
||||
return index + 1;
|
||||
},
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
|
@ -25,7 +25,7 @@
|
||||
<li{% ifequal tab 'bom' %} class="active"{% endifequal %}>
|
||||
<a href="{% url 'part-bom' part.id %}">{% trans "BOM" %}<span class="badge{% if part.is_bom_valid == False %} badge-alert{% endif %}">{{ part.bom_count }}</span></a></li>
|
||||
<li{% ifequal tab 'build' %} class="active"{% endifequal %}>
|
||||
<a href="{% url 'part-build' part.id %}">{% trans "Build" %}<span class='badge'>{{ part.builds|length }}</span></a></li>
|
||||
<a href="{% url 'part-build' part.id %}">{% trans "Build" %}<span class='badge'>{{ part.active_builds|length }}</span></a></li>
|
||||
{% endif %}
|
||||
{% if part.component or part.used_in_count > 0 %}
|
||||
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
|
||||
|
Loading…
Reference in New Issue
Block a user