mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Bug fixes
- Part creation form was setting a field as HiddenInput() rather than its widget - Added 'comment' file to FileAttachment model
This commit is contained in:
parent
7dd960a299
commit
7c11d917de
@ -19,7 +19,7 @@ class PartCategoryAdmin(ImportExportModelAdmin):
|
||||
|
||||
class PartAttachmentAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('part', 'attachment')
|
||||
list_display = ('part', 'attachment', 'comment')
|
||||
|
||||
|
||||
class BomItemAdmin(ImportExportModelAdmin):
|
||||
|
18
InvenTree/part/migrations/0014_partattachment_comment.py
Normal file
18
InvenTree/part/migrations/0014_partattachment_comment.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2 on 2019-04-30 23:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('part', '0013_auto_20190429_2229'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='partattachment',
|
||||
name='comment',
|
||||
field=models.CharField(blank=True, help_text='Attachment description', max_length=100),
|
||||
),
|
||||
]
|
@ -366,6 +366,8 @@ class PartAttachment(models.Model):
|
||||
|
||||
attachment = models.FileField(upload_to=attach_file, null=True, blank=True)
|
||||
|
||||
comment = models.CharField(max_length=100, blank=True, help_text="Attachment description")
|
||||
|
||||
@property
|
||||
def basename(self):
|
||||
return os.path.basename(self.attachment.name)
|
||||
@ -405,8 +407,11 @@ class BomItem(models.Model):
|
||||
- A part cannot refer to a part which refers to it
|
||||
"""
|
||||
|
||||
if self.part is None or self.sub_part is None:
|
||||
# Field validation will catch these None values
|
||||
pass
|
||||
# A part cannot refer to itself in its BOM
|
||||
if self.part == self.sub_part:
|
||||
elif self.part == self.sub_part:
|
||||
raise ValidationError({'sub_part': _('Part cannot be added to its own Bill of Materials')})
|
||||
|
||||
# Test for simple recursion
|
||||
|
@ -98,7 +98,7 @@ class PartCreate(AjaxCreateView):
|
||||
form = super(AjaxCreateView, self).get_form()
|
||||
|
||||
# Hide the default_supplier field (there are no matching supplier parts yet!)
|
||||
form.fields['default_supplier'] = HiddenInput()
|
||||
form.fields['default_supplier'].widget = HiddenInput()
|
||||
|
||||
return form
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user