2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 20:15:44 +00:00

Merge remote-tracking branch 'inventree/master' into stock-expiry

# Conflicts:
#	InvenTree/common/models.py
This commit is contained in:
Oliver Walters
2021-01-05 00:58:32 +11:00
15 changed files with 246 additions and 46 deletions

View File

@ -641,36 +641,69 @@ class Part(MPTTModel):
parent_part.clean()
parent_part.save()
name = models.CharField(max_length=100, blank=False,
help_text=_('Part name'),
validators=[validators.validate_part_name]
)
name = models.CharField(
max_length=100, blank=False,
help_text=_('Part name'),
verbose_name=_('Name'),
validators=[validators.validate_part_name]
)
is_template = models.BooleanField(default=False, help_text=_('Is this part a template part?'))
is_template = models.BooleanField(
default=part_settings.part_template_default,
verbose_name=_('Is Template'),
help_text=_('Is this part a template part?')
)
variant_of = models.ForeignKey('part.Part', related_name='variants',
null=True, blank=True,
limit_choices_to={
'is_template': True,
'active': True,
},
on_delete=models.SET_NULL,
help_text=_('Is this part a variant of another part?'))
variant_of = models.ForeignKey(
'part.Part', related_name='variants',
null=True, blank=True,
limit_choices_to={
'is_template': True,
'active': True,
},
on_delete=models.SET_NULL,
help_text=_('Is this part a variant of another part?'),
verbose_name=_('Variant Of'),
)
description = models.CharField(max_length=250, blank=False, help_text=_('Part description'))
description = models.CharField(
max_length=250, blank=False,
verbose_name=_('Description'),
help_text=_('Part description')
)
keywords = models.CharField(max_length=250, blank=True, null=True, help_text=_('Part keywords to improve visibility in search results'))
keywords = models.CharField(
max_length=250, blank=True, null=True,
verbose_name=_('Keywords'),
help_text=_('Part keywords to improve visibility in search results')
)
category = TreeForeignKey(PartCategory, related_name='parts',
null=True, blank=True,
on_delete=models.DO_NOTHING,
help_text=_('Part category'))
category = TreeForeignKey(
PartCategory, related_name='parts',
null=True, blank=True,
on_delete=models.DO_NOTHING,
verbose_name=_('Category'),
help_text=_('Part category')
)
IPN = models.CharField(max_length=100, blank=True, null=True, help_text=_('Internal Part Number'), validators=[validators.validate_part_ipn])
IPN = models.CharField(
max_length=100, blank=True, null=True,
verbose_name=_('IPN'),
help_text=_('Internal Part Number'),
validators=[validators.validate_part_ipn]
)
revision = models.CharField(max_length=100, blank=True, null=True, help_text=_('Part revision or version number'))
revision = models.CharField(
max_length=100, blank=True, null=True,
help_text=_('Part revision or version number'),
verbose_name=_('Revision'),
)
link = InvenTreeURLField(blank=True, null=True, help_text=_('Link to external URL'))
link = InvenTreeURLField(
blank=True, null=True,
verbose_name=_('Link'),
help_text=_('Link to external URL')
)
image = StdImageField(
upload_to=rename_part_image,
@ -680,10 +713,14 @@ class Part(MPTTModel):
delete_orphans=True,
)
default_location = TreeForeignKey('stock.StockLocation', on_delete=models.SET_NULL,
blank=True, null=True,
help_text=_('Where is this item normally stored?'),
related_name='default_parts')
default_location = TreeForeignKey(
'stock.StockLocation',
on_delete=models.SET_NULL,
blank=True, null=True,
help_text=_('Where is this item normally stored?'),
related_name='default_parts',
verbose_name=_('Default Location'),
)
def get_default_location(self):
""" Get the default location for a Part (may be None).
@ -753,7 +790,7 @@ class Part(MPTTModel):
)
assembly = models.BooleanField(
default=False,
default=part_settings.part_assembly_default,
verbose_name=_('Assembly'),
help_text=_('Can this part be built from other parts?')
)
@ -785,11 +822,15 @@ class Part(MPTTModel):
help_text=_('Is this part active?'))
virtual = models.BooleanField(
default=False,
default=part_settings.part_virtual_default,
verbose_name=_('Virtual'),
help_text=_('Is this a virtual part, such as a software product or license?'))
notes = MarkdownxField(blank=True, null=True, help_text=_('Part notes - supports Markdown formatting'))
notes = MarkdownxField(
blank=True, null=True,
verbose_name=_('Notes'),
help_text=_('Part notes - supports Markdown formatting')
)
bom_checksum = models.CharField(max_length=128, blank=True, help_text=_('Stored BOM checksum'))