Merge remote-tracking branch 'inventree/master' into partial-shipment

This commit is contained in:
Oliver 2021-11-17 20:53:26 +11:00
commit 5e04f2acf3
6 changed files with 24 additions and 18 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -1,13 +1,29 @@
# Generated by Django 2.2 on 2019-05-20 12:04 # Generated by Django 2.2 on 2019-05-20 12:04
import InvenTree.validators import os
from django.conf import settings
import django.core.validators
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings
import django.core.validators
import InvenTree.validators
import part.models import part.models
def attach_file(instance, filename):
"""
Generate a filename for the uploaded attachment.
2021-11-17 - This was moved here from part.models.py,
as the function itself is no longer used,
but is still required for migration
"""
# Construct a path to store a file attachment
return os.path.join('part_files', str(instance.part.id), filename)
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True initial = True
@ -61,7 +77,7 @@ class Migration(migrations.Migration):
name='PartAttachment', name='PartAttachment',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('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=part.models.attach_file)), ('attachment', models.FileField(help_text='Select file to attach', upload_to=attach_file)),
('comment', models.CharField(help_text='File comment', max_length=100)), ('comment', models.CharField(help_text='File comment', max_length=100)),
], ],
), ),

View File

@ -2135,20 +2135,6 @@ def after_save_part(sender, instance: Part, created, **kwargs):
InvenTree.tasks.offload_task('part.tasks.notify_low_stock_if_required', instance) InvenTree.tasks.offload_task('part.tasks.notify_low_stock_if_required', instance)
def attach_file(instance, filename):
""" Function for storing a file for a PartAttachment
Args:
instance: Instance of a PartAttachment object
filename: name of uploaded file
Returns:
path to store file, format: 'part_file_<pk>_filename'
"""
# Construct a path to store a file attachment
return os.path.join('part_files', str(instance.part.id), filename)
class PartAttachment(InvenTreeAttachment): class PartAttachment(InvenTreeAttachment):
""" """
Model for storing file attachments against a Part object Model for storing file attachments against a Part object

View File

@ -27,6 +27,9 @@ function {{ label }}StatusDisplay(key, options={}) {
label = {{ label }}Codes[key].label; label = {{ label }}Codes[key].label;
} }
// Fallback option for label
label = label || 'bg-dark';
if (value == null || value.length == 0) { if (value == null || value.length == 0) {
value = key; value = key;
label = ''; label = '';

View File

@ -28,6 +28,7 @@ djangorestframework==3.12.4 # DRF framework
flake8==3.8.3 # PEP checking flake8==3.8.3 # PEP checking
gunicorn>=20.1.0 # Gunicorn web server gunicorn>=20.1.0 # Gunicorn web server
inventree # Install the latest version of the InvenTree API python library inventree # Install the latest version of the InvenTree API python library
markdown==3.3.4 # Force particular version of markdown
pep8-naming==0.11.1 # PEP naming convention extension pep8-naming==0.11.1 # PEP naming convention extension
pillow==8.3.2 # Image manipulation pillow==8.3.2 # Image manipulation
py-moneyed==0.8.0 # Specific version requirement for py-moneyed py-moneyed==0.8.0 # Specific version requirement for py-moneyed