mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-12 10:05:39 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@ -237,6 +237,7 @@ class Build(models.Model):
|
||||
for serial in serial_numbers:
|
||||
item = StockItem.objects.create(
|
||||
part=self.part,
|
||||
build=self,
|
||||
location=location,
|
||||
quantity=1,
|
||||
serial=serial,
|
||||
@ -250,6 +251,7 @@ class Build(models.Model):
|
||||
# Add stock of the newly created item
|
||||
item = StockItem.objects.create(
|
||||
part=self.part,
|
||||
build=self,
|
||||
location=location,
|
||||
quantity=self.quantity,
|
||||
batch=str(self.batch) if self.batch else '',
|
||||
|
@ -13,8 +13,8 @@ database:
|
||||
# Example Configuration - MySQL
|
||||
#ENGINE: django.db.backends.mysql
|
||||
#NAME: inventree
|
||||
#USER: inventree
|
||||
#PASSWORD: password
|
||||
#USER: inventree_username
|
||||
#PASSWORD: inventree_password
|
||||
#HOST: ''
|
||||
#PORT: ''
|
||||
|
||||
@ -52,4 +52,5 @@ log_queries: False
|
||||
|
||||
# Backup options
|
||||
# Set the backup_dir parameter to store backup files in a specific location
|
||||
# If unspecified, the local user's temp directory will be used
|
||||
#backup_dir: '/home/inventree/backup/'
|
20
InvenTree/stock/migrations/0010_stockitem_build.py
Normal file
20
InvenTree/stock/migrations/0010_stockitem_build.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 2.2.4 on 2019-09-01 13:08
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('build', '0005_auto_20190604_2217'),
|
||||
('stock', '0009_auto_20190715_2351'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='stockitem',
|
||||
name='build',
|
||||
field=models.ForeignKey(blank=True, help_text='Build for this stock item', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='build_outputs', to='build.Build'),
|
||||
),
|
||||
]
|
@ -101,6 +101,7 @@ class StockItem(models.Model):
|
||||
delete_on_deplete: If True, StockItem will be deleted when the stock level gets to zero
|
||||
status: Status of this StockItem (ref: InvenTree.status_codes.StockStatus)
|
||||
notes: Extra notes field
|
||||
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
|
||||
"""
|
||||
@ -300,6 +301,13 @@ class StockItem(models.Model):
|
||||
|
||||
updated = models.DateField(auto_now=True, null=True)
|
||||
|
||||
build = models.ForeignKey(
|
||||
'build.Build', on_delete=models.SET_NULL,
|
||||
blank=True, null=True,
|
||||
help_text='Build for this stock item',
|
||||
related_name='build_outputs',
|
||||
)
|
||||
|
||||
purchase_order = models.ForeignKey(
|
||||
'order.PurchaseOrder',
|
||||
on_delete=models.SET_NULL,
|
||||
@ -484,20 +492,13 @@ class StockItem(models.Model):
|
||||
return
|
||||
|
||||
# Create a new StockItem object, duplicating relevant fields
|
||||
new_stock = StockItem.objects.create(
|
||||
part=self.part,
|
||||
quantity=quantity,
|
||||
supplier_part=self.supplier_part,
|
||||
location=self.location,
|
||||
notes=self.notes,
|
||||
URL=self.URL,
|
||||
batch=self.batch,
|
||||
delete_on_deplete=self.delete_on_deplete
|
||||
)
|
||||
|
||||
# Nullify the PK so a new record is created
|
||||
new_stock = StockItem.objects.get(pk=self.pk)
|
||||
new_stock.pk = None
|
||||
new_stock.quantity = quantity
|
||||
new_stock.save()
|
||||
|
||||
# Copy the transaction history
|
||||
# Copy the transaction history of this part into the new one
|
||||
new_stock.copyHistoryFrom(self)
|
||||
|
||||
# Add a new tracking item for the new stock item
|
||||
|
@ -90,6 +90,12 @@
|
||||
<td>{{ item.batch }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.build %}
|
||||
<tr>
|
||||
<td>Build</td>
|
||||
<td><a href="{% url 'build-detail' item.build.id %}">{{ item.build }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.purchase_order %}
|
||||
<tr>
|
||||
<td>Purchase Order</td>
|
||||
|
Reference in New Issue
Block a user