diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py index 0f8350f84f..4e7ed89e63 100644 --- a/InvenTree/InvenTree/models.py +++ b/InvenTree/InvenTree/models.py @@ -21,7 +21,8 @@ from django.dispatch import receiver from mptt.models import MPTTModel, TreeForeignKey from mptt.exceptions import InvalidMove -from .validators import validate_tree_name +from InvenTree.fields import InvenTreeURLField +from InvenTree.validators import validate_tree_name logger = logging.getLogger('inventree') @@ -89,6 +90,8 @@ class ReferenceIndexingMixin(models.Model): class InvenTreeAttachment(models.Model): """ Provides an abstracted class for managing file attachments. + An attachment can be either an uploaded file, or an external URL + Attributes: attachment: File comment: String descriptor for the attachment @@ -107,7 +110,15 @@ class InvenTreeAttachment(models.Model): return os.path.basename(self.attachment.name) attachment = models.FileField(upload_to=rename_attachment, verbose_name=_('Attachment'), - help_text=_('Select file to attach')) + help_text=_('Select file to attach'), + blank=True, null=True + ) + + link = InvenTreeURLField( + blank=True, null=True, + verbose_name=_('Link'), + help_text=_('Link to external URL') + ) comment = models.CharField(blank=True, max_length=100, verbose_name=_('Comment'), help_text=_('File comment')) diff --git a/InvenTree/build/migrations/0033_auto_20211128_0151.py b/InvenTree/build/migrations/0033_auto_20211128_0151.py new file mode 100644 index 0000000000..db8df848ce --- /dev/null +++ b/InvenTree/build/migrations/0033_auto_20211128_0151.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.5 on 2021-11-28 01:51 + +import InvenTree.fields +import InvenTree.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0032_auto_20211014_0632'), + ] + + operations = [ + migrations.AddField( + model_name='buildorderattachment', + name='link', + field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'), + ), + migrations.AlterField( + model_name='buildorderattachment', + name='attachment', + field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'), + ), + ] diff --git a/InvenTree/order/migrations/0053_auto_20211128_0151.py b/InvenTree/order/migrations/0053_auto_20211128_0151.py new file mode 100644 index 0000000000..bbe029b4af --- /dev/null +++ b/InvenTree/order/migrations/0053_auto_20211128_0151.py @@ -0,0 +1,35 @@ +# Generated by Django 3.2.5 on 2021-11-28 01:51 + +import InvenTree.fields +import InvenTree.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('order', '0052_auto_20211014_0631'), + ] + + operations = [ + migrations.AddField( + model_name='purchaseorderattachment', + name='link', + field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'), + ), + migrations.AddField( + model_name='salesorderattachment', + name='link', + field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'), + ), + migrations.AlterField( + model_name='purchaseorderattachment', + name='attachment', + field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'), + ), + migrations.AlterField( + model_name='salesorderattachment', + name='attachment', + field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'), + ), + ] diff --git a/InvenTree/part/migrations/0075_auto_20211128_0151.py b/InvenTree/part/migrations/0075_auto_20211128_0151.py new file mode 100644 index 0000000000..d484a7adce --- /dev/null +++ b/InvenTree/part/migrations/0075_auto_20211128_0151.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.5 on 2021-11-28 01:51 + +import InvenTree.fields +import InvenTree.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0074_partcategorystar'), + ] + + operations = [ + migrations.AddField( + model_name='partattachment', + name='link', + field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'), + ), + migrations.AlterField( + model_name='partattachment', + name='attachment', + field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'), + ), + ] diff --git a/InvenTree/stock/migrations/0070_auto_20211128_0151.py b/InvenTree/stock/migrations/0070_auto_20211128_0151.py new file mode 100644 index 0000000000..a2f6ef322d --- /dev/null +++ b/InvenTree/stock/migrations/0070_auto_20211128_0151.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.5 on 2021-11-28 01:51 + +import InvenTree.fields +import InvenTree.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0069_auto_20211109_2347'), + ] + + operations = [ + migrations.AddField( + model_name='stockitemattachment', + name='link', + field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'), + ), + migrations.AlterField( + model_name='stockitemattachment', + name='attachment', + field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'), + ), + ]