Fix resource classes for order models (#6188)

- PurchaseOrder
- ReturnOrder
- SalesOrder

Fixes https://github.com/inventree/InvenTree/issues/6155
This commit is contained in:
Oliver 2024-01-10 23:46:55 +11:00 committed by GitHub
parent 9f01962c4e
commit 73cc39bb68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,9 +79,30 @@ class PurchaseOrderLineItemInlineAdmin(admin.StackedInline):
extra = 0
class PurchaseOrderResource(ProjectCodeResourceMixin, TotalPriceResourceMixin, InvenTreeResource):
"""Class for managing import / export of PurchaseOrder data."""
class Meta:
"""Metaclass"""
model = models.PurchaseOrder
skip_unchanged = True
clean_model_instances = True
exclude = [
'metadata',
]
# Add number of line items
line_items = Field(attribute='line_count', widget=widgets.IntegerWidget(), readonly=True)
# Is this order overdue?
overdue = Field(attribute='is_overdue', widget=widgets.BooleanWidget(), readonly=True)
class PurchaseOrderAdmin(ImportExportModelAdmin):
"""Admin class for the PurchaseOrder model"""
resource_class = PurchaseOrderResource
exclude = [
'reference_int',
]
@ -107,9 +128,30 @@ class PurchaseOrderAdmin(ImportExportModelAdmin):
autocomplete_fields = ('supplier',)
class SalesOrderResource(ProjectCodeResourceMixin, TotalPriceResourceMixin, InvenTreeResource):
"""Class for managing import / export of SalesOrder data."""
class Meta:
"""Metaclass options"""
model = models.SalesOrder
skip_unchanged = True
clean_model_instances = True
exclude = [
'metadata',
]
# Add number of line items
line_items = Field(attribute='line_count', widget=widgets.IntegerWidget(), readonly=True)
# Is this order overdue?
overdue = Field(attribute='is_overdue', widget=widgets.BooleanWidget(), readonly=True)
class SalesOrderAdmin(ImportExportModelAdmin):
"""Admin class for the SalesOrder model"""
resource_class = SalesOrderResource
exclude = [
'reference_int',
]
@ -131,25 +173,6 @@ class SalesOrderAdmin(ImportExportModelAdmin):
autocomplete_fields = ('customer',)
class PurchaseOrderResource(ProjectCodeResourceMixin, TotalPriceResourceMixin, InvenTreeResource):
"""Class for managing import / export of PurchaseOrder data."""
class Meta:
"""Metaclass"""
model = models.PurchaseOrder
skip_unchanged = True
clean_model_instances = True
exclude = [
'metadata',
]
# Add number of line items
line_items = Field(attribute='line_count', widget=widgets.IntegerWidget(), readonly=True)
# Is this order overdue?
overdue = Field(attribute='is_overdue', widget=widgets.BooleanWidget(), readonly=True)
class PurchaseOrderLineItemResource(PriceResourceMixin, InvenTreeResource):
"""Class for managing import / export of PurchaseOrderLineItem data."""
@ -184,25 +207,6 @@ class PurchaseOrderExtraLineResource(PriceResourceMixin, InvenTreeResource):
model = models.PurchaseOrderExtraLine
class SalesOrderResource(ProjectCodeResourceMixin, TotalPriceResourceMixin, InvenTreeResource):
"""Class for managing import / export of SalesOrder data."""
class Meta:
"""Metaclass options"""
model = models.SalesOrder
skip_unchanged = True
clean_model_instances = True
exclude = [
'metadata',
]
# Add number of line items
line_items = Field(attribute='line_count', widget=widgets.IntegerWidget(), readonly=True)
# Is this order overdue?
overdue = Field(attribute='is_overdue', widget=widgets.BooleanWidget(), readonly=True)
class SalesOrderLineItemResource(PriceResourceMixin, InvenTreeResource):
"""Class for managing import / export of SalesOrderLineItem data."""
@ -334,6 +338,8 @@ class ReturnOrderResource(ProjectCodeResourceMixin, TotalPriceResourceMixin, Inv
class ReturnOrderAdmin(ImportExportModelAdmin):
"""Admin class for the ReturnOrder model"""
resource_class = ReturnOrderResource
exclude = [
'reference_int',
]