mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
* Add initial model structure * Initial Address model defined * Add migration and unit tests * Initial migration for Address model generated * Unit tests for Address model added * Move address field to new model * Added migration to move address field to Address model * Implement address feature to backend * API endpoints for list and detail implemented * Serializer class for Address implemented * Final migration to delete old address field from company added * Tests for API and migrations added * Amend migration file names * Fix migration names in test * Add address property to company model * Iinital view and JS code * Fix indents * Fix different things * Pre-emptive change before merge * Post-merge fixes * dotdotdot... * ... * iDots * . * . * . * Add form functionality and model checks * Forms require a confirmation slider to be checked to submit if address is selected as primary * Backend resets primary address before saving if new address is designated as primary * Fix pre-save logic to enforce primary uniqueness * Fix typos * Sort out migrations * Forgot one * Add admin entry and small fixes * Fix migration file name and dependency * Update InvenTree/company/models.py Co-authored-by: Matthias Mair <code@mjmair.com> * Update InvenTree/company/models.py Co-authored-by: Matthias Mair <code@mjmair.com> * Correct final issues * . --------- Co-authored-by: Matthias Mair <code@mjmair.com>
38 lines
2.4 KiB
Python
38 lines
2.4 KiB
Python
# Generated by Django 3.2.18 on 2023-05-02 19:56
|
|
|
|
import InvenTree.fields
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('company', '0062_contact_metadata'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='Address',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('title', models.CharField(help_text='Title describing the address entry', max_length=100, verbose_name='Address title')),
|
|
('primary', models.BooleanField(default=False, help_text='Set as primary address', verbose_name='Primary address')),
|
|
('line1', models.CharField(blank=True, help_text='Address line 1', max_length=50, verbose_name='Line 1')),
|
|
('line2', models.CharField(blank=True, help_text='Address line 2', max_length=50, verbose_name='Line 2')),
|
|
('postal_code', models.CharField(blank=True, help_text='Postal code', max_length=10, verbose_name='Postal code')),
|
|
('postal_city', models.CharField(blank=True, help_text='Postal code city', max_length=50, verbose_name='City')),
|
|
('province', models.CharField(blank=True, help_text='State or province', max_length=50, verbose_name='State/Province')),
|
|
('country', models.CharField(blank=True, help_text='Address country', max_length=50, verbose_name='Country')),
|
|
('shipping_notes', models.CharField(blank=True, help_text='Notes for shipping courier', max_length=100, verbose_name='Courier shipping notes')),
|
|
('internal_shipping_notes', models.CharField(blank=True, help_text='Shipping notes for internal use', max_length=100, verbose_name='Internal shipping notes')),
|
|
('link', InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to address information (external)', verbose_name='Link')),
|
|
('company', models.ForeignKey(help_text='Select company', on_delete=django.db.models.deletion.CASCADE, related_name='addresses', to='company.company', verbose_name='Company')),
|
|
],
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='address',
|
|
constraint=models.UniqueConstraint(condition=models.Q(('primary', True)), fields=('company',), name='one_primary_per_company'),
|
|
),
|
|
]
|