Coverage for src/backend/InvenTree/part/migrations/0001_initial.py: 92%
13 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1# Generated by Django 2.2 on 2019-05-20 12:04
3import os
5from django.db import migrations, models
6import django.db.models.deletion
7from django.conf import settings
8import django.core.validators
10import InvenTree.validators
11import part.models
14def attach_file(instance, filename): # pragma: no cover
15 """
16 Generate a filename for the uploaded attachment.
18 2021-11-17 - This was moved here from part.models.py,
19 as the function itself is no longer used,
20 but is still required for migration
21 """
23 # Construct a path to store a file attachment
24 return os.path.join('part_files', str(instance.part.id), filename)
27class Migration(migrations.Migration):
29 initial = True
31 dependencies = [
32 migrations.swappable_dependency(settings.AUTH_USER_MODEL),
33 ]
35 operations = [
36 migrations.CreateModel(
37 name='BomItem',
38 fields=[
39 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
40 ('quantity', models.PositiveIntegerField(default=1, help_text='BOM quantity for this BOM item', validators=[django.core.validators.MinValueValidator(0)])),
41 ('overage', models.CharField(blank=True, help_text='Estimated build wastage quantity (absolute or percentage)', max_length=24, validators=[])),
42 ('note', models.CharField(blank=True, help_text='BOM item notes', max_length=100)),
43 ],
44 options={
45 'verbose_name': 'BOM Item',
46 },
47 ),
48 migrations.CreateModel(
49 name='Part',
50 fields=[
51 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
52 ('name', models.CharField(help_text='Part name', max_length=100)),
53 ('variant', models.CharField(blank=True, help_text='Part variant or revision code', max_length=32)),
54 ('description', models.CharField(help_text='Part description', max_length=250)),
55 ('keywords', models.CharField(blank=True, help_text='Part keywords to improve visibility in search results', max_length=250)),
56 ('IPN', models.CharField(blank=True, help_text='Internal Part Number', max_length=100)),
57 ('URL', models.URLField(blank=True, help_text='Link to external URL')),
58 ('image', models.ImageField(blank=True, max_length=255, null=True, upload_to=part.models.rename_part_image)),
59 ('minimum_stock', models.PositiveIntegerField(default=0, help_text='Minimum allowed stock level', validators=[django.core.validators.MinValueValidator(0)])),
60 ('units', models.CharField(blank=True, default='pcs', help_text='Stock keeping units for this part', max_length=20)),
61 ('buildable', models.BooleanField(default=False, help_text='Can this part be built from other parts?')),
62 ('consumable', models.BooleanField(default=True, help_text='Can this part be used to build other parts?')),
63 ('trackable', models.BooleanField(default=False, help_text='Does this part have tracking for unique items?')),
64 ('purchaseable', models.BooleanField(default=True, help_text='Can this part be purchased from external suppliers?')),
65 ('salable', models.BooleanField(default=False, help_text='Can this part be sold to customers?')),
66 ('active', models.BooleanField(default=True, help_text='Is this part active?')),
67 ('notes', models.TextField(blank=True)),
68 ('bom_checksum', models.CharField(blank=True, help_text='Stored BOM checksum', max_length=128)),
69 ('bom_checked_date', models.DateField(blank=True, null=True)),
70 ],
71 options={
72 'verbose_name': 'Part',
73 'verbose_name_plural': 'Parts',
74 },
75 ),
76 migrations.CreateModel(
77 name='PartAttachment',
78 fields=[
79 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
80 ('attachment', models.FileField(help_text='Select file to attach', upload_to=attach_file)),
81 ('comment', models.CharField(help_text='File comment', max_length=100)),
82 ],
83 ),
84 migrations.CreateModel(
85 name='PartCategory',
86 fields=[
87 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
88 ('name', models.CharField(max_length=100, unique=True)),
89 ('description', models.CharField(max_length=250)),
90 ('default_keywords', models.CharField(blank=True, help_text='Default keywords for parts in this category', max_length=250)),
91 ],
92 options={
93 'verbose_name': 'Part Category',
94 'verbose_name_plural': 'Part Categories',
95 },
96 ),
97 migrations.CreateModel(
98 name='PartStar',
99 fields=[
100 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
101 ('part', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_users', to='part.Part')),
102 ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_parts', to=settings.AUTH_USER_MODEL)),
103 ],
104 ),
105 ]