mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
The 'StockItem' model now has a reference to a SalesOrderLineItem
This commit is contained in:
parent
8052a1989c
commit
a1376eeb9e
@ -29,6 +29,39 @@
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Progress bars */
|
||||
|
||||
.progress-bar {
|
||||
height: 25px;
|
||||
background: #eee;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #ddd;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.progress-bar-value {
|
||||
color: #000;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
left: 0px;
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
.progress-bar-inner {
|
||||
height: 23px;
|
||||
width: 20%;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
background: #3a3;
|
||||
opacity: 40%;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.qr-code {
|
||||
max-width: 400px;
|
||||
max-height: 400px;
|
||||
|
@ -1,23 +0,0 @@
|
||||
# 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')),
|
||||
],
|
||||
),
|
||||
]
|
@ -383,19 +383,3 @@ class SalesOrderLineItem(OrderLineItem):
|
||||
query = self.stock_items.aggregate(allocated=Coalesce(Sum('stock_item__quantity'), Decimal(0)))
|
||||
|
||||
return query['allocated']
|
||||
|
||||
|
||||
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')
|
||||
|
@ -50,14 +50,6 @@ $("#so-lines-table").inventreeTable({
|
||||
title: 'ID',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'line',
|
||||
title: 'Line',
|
||||
formatter: function(value, row, index, field) {
|
||||
return index + 1;
|
||||
},
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'part',
|
||||
@ -80,7 +72,12 @@ $("#so-lines-table").inventreeTable({
|
||||
field: 'quantity',
|
||||
title: 'Quantity',
|
||||
formatter: function(value, row, index, field) {
|
||||
return +parseFloat(value).toFixed(5);
|
||||
return `
|
||||
<div class='progress-bar'>
|
||||
<div class='progress-bar progress-bar-inner' style='width: 50%;'></div>
|
||||
<div class='progress-bar-value'>${row.allocated} / ${row.quantity}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
20
InvenTree/stock/migrations/0027_stockitem_sales_order.py
Normal file
20
InvenTree/stock/migrations/0027_stockitem_sales_order.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 3.0.5 on 2020-04-21 05:03
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('order', '0023_auto_20200420_2309'),
|
||||
('stock', '0026_stockitem_uid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='stockitem',
|
||||
name='sales_order',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_items', to='order.SalesOrderLineItem'),
|
||||
),
|
||||
]
|
@ -126,6 +126,7 @@ class StockItem(MPTTModel):
|
||||
build: Link to a Build (if this stock item was created from a build)
|
||||
purchase_order: Link to a PurchaseOrder (if this stock item was created from a PurchaseOrder)
|
||||
infinite: If True this StockItem can never be exhausted
|
||||
sales_order: Link to a SalesOrderLineItem (if this stockitem has been allocated to a sales order)
|
||||
"""
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
@ -353,6 +354,12 @@ class StockItem(MPTTModel):
|
||||
help_text=_('Purchase order for this stock item')
|
||||
)
|
||||
|
||||
sales_order = models.ForeignKey(
|
||||
'order.SalesOrderLineItem',
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='stock_items',
|
||||
null=True)
|
||||
|
||||
# last time the stock was checked / counted
|
||||
stocktake_date = models.DateField(blank=True, null=True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user