mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
Bump to Dj 4.x (#6173)
* bump to dj >4.2 * switch to experimental git release * bump django-import_export * bump mptt * replace is_ajax, which was removed https://docs.djangoproject.com/en/3.1/releases/3.1/#id2 * Save before accessing values in m2m/fk fields * move plugin init * use dev version of django for fix * update deps * fix deps * use django smaller 4.2 * fix reqs * fix merge * remove moved code * another merge fix * fix ajax call * fix refs * change python min v * fix deps * bump deps * fix deps * pin pillow * dj 4.1 upgrades * make diff smaller * bump all deps * drop down to py3.9 * bump versions * merge fix * fix diff * more bumping * diff cleanup * bump deps * fix reqs * use accurate state for model migrations using apps the historically correct state is used * try import * added more logs * add try here too * clean up rebuilds * Dj 4.2 (#161) * autochanges * bump * fix diff * fix diff * bump deps * fix req * remove select_related to test error influence * switch to mptt fork * fix reqs for upstream * move tracking ensureance into save * optimize check frequency * use psycopg instead of psycopg2 * fix header * just use the values * switch to dj < 4.2 * fix req * another req fix * switch to 4.2 again * fix merge error * Check for null pk in calculate_total_price Cannot access self.lines if pk is Null * use patched mptt * try psycopg2 again * Remove tree rebuild from migrations * Prevent notify_users if importing or migrating * Add order_by() to subquery annotations - Ref: https://stackoverflow.com/a/629691 * Update stock filters - Append order_by() * fix error if running without timezones in testing * add logging to figure this out * remove tz from self.creation if TZ is off * add tz? * move around? * only run the test i am trying to figure out not reproducible on my machine * only run the test i am trying to figure out not reproducible on my machine * run all tests again --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
@ -85,6 +85,7 @@ class LocationInline(admin.TabularInline):
|
||||
model = StockLocation
|
||||
|
||||
|
||||
@admin.register(StockLocation)
|
||||
class LocationAdmin(ImportExportModelAdmin):
|
||||
"""Admin class for Location."""
|
||||
|
||||
@ -99,6 +100,7 @@ class LocationAdmin(ImportExportModelAdmin):
|
||||
autocomplete_fields = ['parent']
|
||||
|
||||
|
||||
@admin.register(StockLocationType)
|
||||
class LocationTypeAdmin(admin.ModelAdmin):
|
||||
"""Admin class for StockLocationType."""
|
||||
|
||||
@ -268,6 +270,7 @@ class StockItemResource(InvenTreeResource):
|
||||
StockItem.objects.rebuild()
|
||||
|
||||
|
||||
@admin.register(StockItem)
|
||||
class StockItemAdmin(ImportExportModelAdmin):
|
||||
"""Admin class for StockItem."""
|
||||
|
||||
@ -292,6 +295,7 @@ class StockItemAdmin(ImportExportModelAdmin):
|
||||
]
|
||||
|
||||
|
||||
@admin.register(StockItemAttachment)
|
||||
class StockAttachmentAdmin(admin.ModelAdmin):
|
||||
"""Admin class for StockAttachment."""
|
||||
|
||||
@ -300,6 +304,7 @@ class StockAttachmentAdmin(admin.ModelAdmin):
|
||||
autocomplete_fields = ['stock_item']
|
||||
|
||||
|
||||
@admin.register(StockItemTracking)
|
||||
class StockTrackingAdmin(ImportExportModelAdmin):
|
||||
"""Admin class for StockTracking."""
|
||||
|
||||
@ -308,17 +313,10 @@ class StockTrackingAdmin(ImportExportModelAdmin):
|
||||
autocomplete_fields = ['item']
|
||||
|
||||
|
||||
@admin.register(StockItemTestResult)
|
||||
class StockItemTestResultAdmin(admin.ModelAdmin):
|
||||
"""Admin class for StockItemTestResult."""
|
||||
|
||||
list_display = ('stock_item', 'test', 'result', 'value')
|
||||
|
||||
autocomplete_fields = ['stock_item']
|
||||
|
||||
|
||||
admin.site.register(StockLocation, LocationAdmin)
|
||||
admin.site.register(StockLocationType, LocationTypeAdmin)
|
||||
admin.site.register(StockItem, StockItemAdmin)
|
||||
admin.site.register(StockItemTracking, StockTrackingAdmin)
|
||||
admin.site.register(StockItemAttachment, StockAttachmentAdmin)
|
||||
admin.site.register(StockItemTestResult, StockItemTestResultAdmin)
|
||||
|
@ -30,7 +30,9 @@ def annotate_location_items(filter: Q = None):
|
||||
Subquery(
|
||||
subquery.annotate(
|
||||
total=Func(F('pk'), function='COUNT', output_field=IntegerField())
|
||||
).values('total')
|
||||
)
|
||||
.values('total')
|
||||
.order_by()
|
||||
),
|
||||
0,
|
||||
output_field=IntegerField(),
|
||||
@ -50,7 +52,9 @@ def annotate_child_items():
|
||||
Subquery(
|
||||
child_stock_query.annotate(
|
||||
count=Func(F('pk'), function='COUNT', output_field=IntegerField())
|
||||
).values('count')
|
||||
)
|
||||
.values('count')
|
||||
.order_by()
|
||||
),
|
||||
0,
|
||||
output_field=IntegerField(),
|
||||
|
@ -2,13 +2,6 @@
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from stock import models
|
||||
|
||||
|
||||
def update_tree(apps, schema_editor):
|
||||
# Update the StockLocation MPTT model
|
||||
|
||||
models.StockLocation.objects.rebuild()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -19,6 +12,4 @@ class Migration(migrations.Migration):
|
||||
('stock', '0011_auto_20190908_0404'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_tree)
|
||||
]
|
||||
operations = []
|
||||
|
@ -1,13 +1,6 @@
|
||||
# Generated by Django 2.2.9 on 2020-02-17 11:09
|
||||
|
||||
from django.db import migrations
|
||||
from stock import models
|
||||
|
||||
|
||||
def update_stock_item_tree(apps, schema_editor):
|
||||
# Update the StockItem MPTT model
|
||||
|
||||
models.StockItem.objects.rebuild()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -18,6 +11,4 @@ class Migration(migrations.Migration):
|
||||
('stock', '0021_auto_20200215_2232'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_stock_item_tree)
|
||||
]
|
||||
operations = []
|
||||
|
@ -107,7 +107,8 @@ class StockLocationManager(TreeManager):
|
||||
|
||||
- Joins the StockLocationType by default for speedier icon access
|
||||
"""
|
||||
return super().get_queryset().select_related('location_type')
|
||||
# return super().get_queryset().select_related("location_type")
|
||||
return super().get_queryset()
|
||||
|
||||
|
||||
class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
|
||||
|
Reference in New Issue
Block a user