Migration cleanup (#7792)

* Add new "ON_HOLD" status code to order models

* Update legacy migration for build status

- Pin it to the "live" build status codes

* Fix legacy migrations for order status codes

* Revert "ON_HOLD" status codes

- Just limiting this PR to cleanup
This commit is contained in:
Oliver 2024-08-02 12:17:00 +10:00 committed by GitHub
parent 964096aedf
commit 66d1c77d19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 37 additions and 8 deletions

View File

@ -5,6 +5,8 @@ from django.db import migrations, models
import django.db.models.deletion
import mptt.fields
from build.status_codes import BuildStatus
class Migration(migrations.Migration):
@ -40,7 +42,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='build',
name='status',
field=models.PositiveIntegerField(choices=[(10, 'Pending'), (20, 'Production'), (30, 'Cancelled'), (40, 'Complete')], default=10, help_text='Build status code', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Build Status'),
field=models.PositiveIntegerField(choices=BuildStatus.items(), default=BuildStatus.PENDING.value, help_text='Build status code', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Build Status'),
),
migrations.AlterField(
model_name='build',

View File

@ -9,7 +9,7 @@ class BuildStatus(StatusCode):
"""Build status codes."""
PENDING = 10, _('Pending'), 'secondary' # Build is pending / active
PRODUCTION = 20, _('Production'), 'primary' # BuildOrder is in production
PRODUCTION = 20, _('Production'), 'primary' # Build is in production
CANCELLED = 30, _('Cancelled'), 'danger' # Build was cancelled
COMPLETE = 40, _('Complete'), 'success' # Build is complete
@ -17,4 +17,7 @@ class BuildStatus(StatusCode):
class BuildStatusGroups:
"""Groups for BuildStatus codes."""
ACTIVE_CODES = [BuildStatus.PENDING.value, BuildStatus.PRODUCTION.value]
ACTIVE_CODES = [
BuildStatus.PENDING.value,
BuildStatus.PRODUCTION.value,
]

View File

@ -5,6 +5,8 @@ import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
from order.status_codes import PurchaseOrderStatus
class Migration(migrations.Migration):
@ -17,7 +19,12 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='purchaseorder',
name='status',
field=models.PositiveIntegerField(choices=[(10, 'Pending'), (20, 'Placed'), (30, 'Complete'), (40, 'Cancelled'), (50, 'Lost'), (60, 'Returned')], default=10, help_text='Purchase order status'),
field=models.PositiveIntegerField(
choices=PurchaseOrderStatus.items(),
default=PurchaseOrderStatus.PENDING.value,
help_text='Purchase order status',
verbose_name='Status',
),
),
migrations.AlterField(
model_name='salesorder',

View File

@ -2,6 +2,8 @@
from django.db import migrations, models
from order.status_codes import ReturnOrderStatus
class Migration(migrations.Migration):
@ -23,7 +25,11 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='returnorder',
name='status',
field=models.PositiveIntegerField(choices=[(10, 'Pending'), (20, 'In Progress'), (30, 'Complete'), (40, 'Cancelled')], default=10, help_text='Return order status', verbose_name='Status'),
field=models.PositiveIntegerField(
choices=ReturnOrderStatus.items(),
default=ReturnOrderStatus.PENDING.value,
help_text='Return order status', verbose_name='Status'
),
),
migrations.AlterField(
model_name='salesorder',

View File

@ -2,6 +2,8 @@
from django.db import migrations, models
from order.status_codes import SalesOrderStatus
class Migration(migrations.Migration):
@ -13,6 +15,10 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='salesorder',
name='status',
field=models.PositiveIntegerField(choices=[(10, 'Pending'), (15, 'In Progress'), (20, 'Shipped'), (40, 'Cancelled'), (50, 'Lost'), (60, 'Returned')], default=10, help_text='Purchase order status', verbose_name='Status'),
field=models.PositiveIntegerField(
choices=SalesOrderStatus.items(),
default=SalesOrderStatus.PENDING.value,
help_text='Sales order status', verbose_name='Status'
),
),
]

View File

@ -15,6 +15,10 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='salesorder',
name='status',
field=models.PositiveIntegerField(choices=order.status_codes.SalesOrderStatus.items(), default=10, help_text='Purchase order status', verbose_name='Status'),
field=models.PositiveIntegerField(
choices=order.status_codes.SalesOrderStatus.items(),
default=order.status_codes.SalesOrderStatus.PENDING.value,
help_text='Sales order status', verbose_name='Status'
),
),
]

View File

@ -474,6 +474,7 @@ class PurchaseOrder(TotalPriceMixin, Order):
status = models.PositiveIntegerField(
default=PurchaseOrderStatus.PENDING.value,
choices=PurchaseOrderStatus.items(),
verbose_name=_('Status'),
help_text=_('Purchase order status'),
)
@ -967,7 +968,7 @@ class SalesOrder(TotalPriceMixin, Order):
default=SalesOrderStatus.PENDING.value,
choices=SalesOrderStatus.items(),
verbose_name=_('Status'),
help_text=_('Purchase order status'),
help_text=_('Sales order status'),
)
@property