mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add StockItemAttachment model
This commit is contained in:
parent
e83a0610af
commit
64f6238351
@ -8,7 +8,7 @@ from import_export.resources import ModelResource
|
||||
from import_export.fields import Field
|
||||
import import_export.widgets as widgets
|
||||
|
||||
from .models import StockLocation, StockItem
|
||||
from .models import StockLocation, StockItem, StockItemAttachment
|
||||
from .models import StockItemTracking
|
||||
|
||||
from build.models import Build
|
||||
@ -108,6 +108,12 @@ class StockItemAdmin(ImportExportModelAdmin):
|
||||
list_display = ('part', 'quantity', 'location', 'status', 'updated')
|
||||
|
||||
|
||||
class StockAttachmentAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('stock_item', 'attachment', 'comment')
|
||||
|
||||
|
||||
|
||||
class StockTrackingAdmin(ImportExportModelAdmin):
|
||||
list_display = ('item', 'date', 'title')
|
||||
|
||||
@ -115,3 +121,4 @@ class StockTrackingAdmin(ImportExportModelAdmin):
|
||||
admin.site.register(StockLocation, LocationAdmin)
|
||||
admin.site.register(StockItem, StockItemAdmin)
|
||||
admin.site.register(StockItemTracking, StockTrackingAdmin)
|
||||
admin.site.register(StockItemAttachment, StockAttachmentAdmin)
|
||||
|
27
InvenTree/stock/migrations/0036_stockitemattachment.py
Normal file
27
InvenTree/stock/migrations/0036_stockitemattachment.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-06 23:36
|
||||
|
||||
import InvenTree.models
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0035_auto_20200502_2308'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='StockItemAttachment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('attachment', models.FileField(help_text='Select file to attach', upload_to=InvenTree.models.rename_attachment)),
|
||||
('comment', models.CharField(help_text='File comment', max_length=100)),
|
||||
('stock_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='stock.StockItem')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
@ -27,7 +27,7 @@ from datetime import datetime
|
||||
from InvenTree import helpers
|
||||
|
||||
from InvenTree.status_codes import StockStatus
|
||||
from InvenTree.models import InvenTreeTree
|
||||
from InvenTree.models import InvenTreeTree, InvenTreeAttachment
|
||||
from InvenTree.fields import InvenTreeURLField
|
||||
|
||||
from part import models as PartModels
|
||||
@ -935,6 +935,21 @@ def before_delete_stock_item(sender, instance, using, **kwargs):
|
||||
StockItem.objects.rebuild()
|
||||
|
||||
|
||||
class StockItemAttachment(InvenTreeAttachment):
|
||||
"""
|
||||
Model for storing file attachments against a StockItem object.
|
||||
"""
|
||||
|
||||
def getSubdir(self):
|
||||
return os.path.join("stock_files", str(self.stock_item.id))
|
||||
|
||||
stock_item = models.ForeignKey(
|
||||
StockItem,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='attachments'
|
||||
)
|
||||
|
||||
|
||||
class StockItemTracking(models.Model):
|
||||
""" Stock tracking entry - breacrumb for keeping track of automated stock transactions
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user