mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-30 16:41:35 +00:00
* Add "round_up_multiple" field * Adjust field def * Add serializer field * Update frontend * Nullify empty numerical values * Calculate round_up_multiple value * Adjust table rendering * Update API version * Add unit test * Additional unit test * Change name of value * Update BOM docs * Add new fields * Add data migration for new fields * Bug fix for data migration * Adjust API fields * Bump API docs * Update frontend * Remove old 'overage' field * Updated BOM docs * Docs tweak * Fix required quantity calculation * additional unit tests * Tweak BOM table * Enhanced "can_build" serializer * Refactor "can_build" calculations * Code cleanup * Serializer fix * Enhanced rendering * Updated playwright tests * Fix method name * Update API unit test * Refactor 'can_build' calculation - Make it much more efficient - Reduce code duplication * Fix unit test * Adjust serializer type * Update src/backend/InvenTree/part/models.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/backend/InvenTree/part/test_bom_item.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/docs/manufacturing/bom.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/docs/manufacturing/bom.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Adjust unit test * Adjust tests * Tweak requirements * Tweak playwright tests * More playwright fixes --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
106 lines
5.4 KiB
Python
106 lines
5.4 KiB
Python
# Generated by Django 2.2 on 2019-05-20 12:04
|
|
|
|
import os
|
|
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
from django.conf import settings
|
|
import django.core.validators
|
|
|
|
import InvenTree.validators
|
|
import part.models
|
|
|
|
|
|
def attach_file(instance, filename): # pragma: no cover
|
|
"""
|
|
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):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='BomItem',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('quantity', models.PositiveIntegerField(default=1, help_text='BOM quantity for this BOM item', validators=[django.core.validators.MinValueValidator(0)])),
|
|
('overage', models.CharField(blank=True, help_text='Estimated build wastage quantity (absolute or percentage)', max_length=24, validators=[])),
|
|
('note', models.CharField(blank=True, help_text='BOM item notes', max_length=100)),
|
|
],
|
|
options={
|
|
'verbose_name': 'BOM Item',
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='Part',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(help_text='Part name', max_length=100)),
|
|
('variant', models.CharField(blank=True, help_text='Part variant or revision code', max_length=32)),
|
|
('description', models.CharField(help_text='Part description', max_length=250)),
|
|
('keywords', models.CharField(blank=True, help_text='Part keywords to improve visibility in search results', max_length=250)),
|
|
('IPN', models.CharField(blank=True, help_text='Internal Part Number', max_length=100)),
|
|
('URL', models.URLField(blank=True, help_text='Link to external URL')),
|
|
('image', models.ImageField(blank=True, max_length=255, null=True, upload_to=part.models.rename_part_image)),
|
|
('minimum_stock', models.PositiveIntegerField(default=0, help_text='Minimum allowed stock level', validators=[django.core.validators.MinValueValidator(0)])),
|
|
('units', models.CharField(blank=True, default='pcs', help_text='Stock keeping units for this part', max_length=20)),
|
|
('buildable', models.BooleanField(default=False, help_text='Can this part be built from other parts?')),
|
|
('consumable', models.BooleanField(default=True, help_text='Can this part be used to build other parts?')),
|
|
('trackable', models.BooleanField(default=False, help_text='Does this part have tracking for unique items?')),
|
|
('purchaseable', models.BooleanField(default=True, help_text='Can this part be purchased from external suppliers?')),
|
|
('salable', models.BooleanField(default=False, help_text='Can this part be sold to customers?')),
|
|
('active', models.BooleanField(default=True, help_text='Is this part active?')),
|
|
('notes', models.TextField(blank=True)),
|
|
('bom_checksum', models.CharField(blank=True, help_text='Stored BOM checksum', max_length=128)),
|
|
('bom_checked_date', models.DateField(blank=True, null=True)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Part',
|
|
'verbose_name_plural': 'Parts',
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='PartAttachment',
|
|
fields=[
|
|
('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=attach_file)),
|
|
('comment', models.CharField(help_text='File comment', max_length=100)),
|
|
],
|
|
),
|
|
migrations.CreateModel(
|
|
name='PartCategory',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(max_length=100, unique=True)),
|
|
('description', models.CharField(max_length=250)),
|
|
('default_keywords', models.CharField(blank=True, help_text='Default keywords for parts in this category', max_length=250)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Part Category',
|
|
'verbose_name_plural': 'Part Categories',
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='PartStar',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('part', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_users', to='part.Part')),
|
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_parts', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
),
|
|
]
|