mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update SupplierPart model to allow data importing
- django-import-export plugin seems to require null=True for char fields - yes, this goes against django "best practice" - Hopefully a better solution can be found
This commit is contained in:
parent
bdc3a9ef02
commit
2a91bb0c87
@ -38,7 +38,9 @@ class CompanyAdmin(ImportExportModelAdmin):
|
|||||||
|
|
||||||
|
|
||||||
class SupplierPartResource(ModelResource):
|
class SupplierPartResource(ModelResource):
|
||||||
""" Class for managing SupplierPart data import/export """
|
"""
|
||||||
|
Class for managing SupplierPart data import/export
|
||||||
|
"""
|
||||||
|
|
||||||
part = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part))
|
part = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part))
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ class SupplierPartResource(ModelResource):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
skip_unchanged = True
|
skip_unchanged = True
|
||||||
report_skipped = False
|
report_skipped = True
|
||||||
clean_model_instances = True
|
clean_model_instances = True
|
||||||
|
|
||||||
|
|
||||||
|
61
InvenTree/company/migrations/0031_auto_20210103_2215.py
Normal file
61
InvenTree/company/migrations/0031_auto_20210103_2215.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2021-01-03 11:15
|
||||||
|
|
||||||
|
import InvenTree.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('part', '0060_merge_20201112_1722'),
|
||||||
|
('company', '0030_auto_20201112_1112'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='MPN',
|
||||||
|
field=models.CharField(blank=True, help_text='Manufacturer part number', max_length=100, null=True, verbose_name='MPN'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='SKU',
|
||||||
|
field=models.CharField(help_text='Supplier stock keeping unit', max_length=100, verbose_name='SKU'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='description',
|
||||||
|
field=models.CharField(blank=True, help_text='Supplier part description', max_length=250, null=True, verbose_name='Description'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='link',
|
||||||
|
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='URL for external supplier part link', null=True, verbose_name='Link'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='manufacturer',
|
||||||
|
field=models.ForeignKey(blank=True, help_text='Select manufacturer', limit_choices_to={'is_manufacturer': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='manufactured_parts', to='company.Company', verbose_name='Manufacturer'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='note',
|
||||||
|
field=models.CharField(blank=True, help_text='Notes', max_length=100, null=True, verbose_name='Note'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='packaging',
|
||||||
|
field=models.CharField(blank=True, help_text='Part packaging', max_length=50, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='part',
|
||||||
|
field=models.ForeignKey(help_text='Select part', limit_choices_to={'purchaseable': True}, on_delete=django.db.models.deletion.CASCADE, related_name='supplier_parts', to='part.Part', verbose_name='Base Part'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='supplier',
|
||||||
|
field=models.ForeignKey(help_text='Select supplier', limit_choices_to={'is_supplier': True}, on_delete=django.db.models.deletion.CASCADE, related_name='supplied_parts', to='company.Company', verbose_name='Supplier'),
|
||||||
|
),
|
||||||
|
]
|
@ -313,7 +313,6 @@ class SupplierPart(models.Model):
|
|||||||
verbose_name=_('Base Part'),
|
verbose_name=_('Base Part'),
|
||||||
limit_choices_to={
|
limit_choices_to={
|
||||||
'purchaseable': True,
|
'purchaseable': True,
|
||||||
'is_template': False,
|
|
||||||
},
|
},
|
||||||
help_text=_('Select part'),
|
help_text=_('Select part'),
|
||||||
)
|
)
|
||||||
@ -321,31 +320,55 @@ class SupplierPart(models.Model):
|
|||||||
supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
|
supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
|
||||||
related_name='supplied_parts',
|
related_name='supplied_parts',
|
||||||
limit_choices_to={'is_supplier': True},
|
limit_choices_to={'is_supplier': True},
|
||||||
|
verbose_name=_('Supplier'),
|
||||||
help_text=_('Select supplier'),
|
help_text=_('Select supplier'),
|
||||||
)
|
)
|
||||||
|
|
||||||
SKU = models.CharField(max_length=100, help_text=_('Supplier stock keeping unit'))
|
SKU = models.CharField(
|
||||||
|
max_length=100,
|
||||||
|
verbose_name=_('SKU'),
|
||||||
|
help_text=_('Supplier stock keeping unit')
|
||||||
|
)
|
||||||
|
|
||||||
manufacturer = models.ForeignKey(
|
manufacturer = models.ForeignKey(
|
||||||
Company,
|
Company,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
related_name='manufactured_parts',
|
related_name='manufactured_parts',
|
||||||
limit_choices_to={'is_manufacturer': True},
|
limit_choices_to={
|
||||||
|
'is_manufacturer': True
|
||||||
|
},
|
||||||
|
verbose_name=_('Manufacturer'),
|
||||||
help_text=_('Select manufacturer'),
|
help_text=_('Select manufacturer'),
|
||||||
null=True, blank=True
|
null=True, blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
MPN = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer part number'))
|
MPN = models.CharField(
|
||||||
|
max_length=100, blank=True, null=True,
|
||||||
|
verbose_name=_('MPN'),
|
||||||
|
help_text=_('Manufacturer part number')
|
||||||
|
)
|
||||||
|
|
||||||
link = InvenTreeURLField(blank=True, help_text=_('URL for external supplier part link'))
|
link = InvenTreeURLField(
|
||||||
|
blank=True, null=True,
|
||||||
|
verbose_name=_('Link'),
|
||||||
|
help_text=_('URL for external supplier part link')
|
||||||
|
)
|
||||||
|
|
||||||
description = models.CharField(max_length=250, blank=True, help_text=_('Supplier part description'))
|
description = models.CharField(
|
||||||
|
max_length=250, blank=True, null=True,
|
||||||
|
verbose_name=_('Description'),
|
||||||
|
help_text=_('Supplier part description')
|
||||||
|
)
|
||||||
|
|
||||||
note = models.CharField(max_length=100, blank=True, help_text=_('Notes'))
|
note = models.CharField(
|
||||||
|
max_length=100, blank=True, null=True,
|
||||||
|
verbose_name=_('Note'),
|
||||||
|
help_text=_('Notes')
|
||||||
|
)
|
||||||
|
|
||||||
base_cost = models.DecimalField(max_digits=10, decimal_places=3, default=0, validators=[MinValueValidator(0)], help_text=_('Minimum charge (e.g. stocking fee)'))
|
base_cost = models.DecimalField(max_digits=10, decimal_places=3, default=0, validators=[MinValueValidator(0)], help_text=_('Minimum charge (e.g. stocking fee)'))
|
||||||
|
|
||||||
packaging = models.CharField(max_length=50, blank=True, help_text=_('Part packaging'))
|
packaging = models.CharField(max_length=50, blank=True, null=True, help_text=_('Part packaging'))
|
||||||
|
|
||||||
multiple = models.PositiveIntegerField(default=1, validators=[MinValueValidator(1)], help_text=('Order multiple'))
|
multiple = models.PositiveIntegerField(default=1, validators=[MinValueValidator(1)], help_text=('Order multiple'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user