diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 3724835621..550884608f 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -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; diff --git a/InvenTree/order/migrations/0024_salesorderlineitemstockassociation.py b/InvenTree/order/migrations/0024_salesorderlineitemstockassociation.py deleted file mode 100644 index bad3914a74..0000000000 --- a/InvenTree/order/migrations/0024_salesorderlineitemstockassociation.py +++ /dev/null @@ -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')), - ], - ), - ] diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 7a694fbc8d..9c6d5dcbb8 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -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') diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index 907effebc7..64b75358da 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -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 ` +
+
+
${row.allocated} / ${row.quantity}
+
+ `; } }, { diff --git a/InvenTree/stock/migrations/0027_stockitem_sales_order.py b/InvenTree/stock/migrations/0027_stockitem_sales_order.py new file mode 100644 index 0000000000..048609ae5f --- /dev/null +++ b/InvenTree/stock/migrations/0027_stockitem_sales_order.py @@ -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'), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 51b61ff3fd..f009f09791 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -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)