Specify ForeignKey widget for importing destination field (#6205)

- Fixes https://github.com/inventree/InvenTree/issues/6201
This commit is contained in:
Oliver 2024-01-11 22:17:14 +11:00 committed by GitHub
parent df8b480abb
commit 7f231cb6c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ from import_export import widgets
from import_export.admin import ImportExportModelAdmin
from import_export.fields import Field
import stock.models
from InvenTree.admin import InvenTreeResource
from order import models
@ -173,6 +174,11 @@ class PurchaseOrderLineItemResource(PriceResourceMixin, InvenTreeResource):
SKU = Field(attribute='part__SKU', readonly=True)
destination = Field(
attribute='destination',
widget=widgets.ForeignKeyWidget(stock.models.StockLocation),
)
def dehydrate_purchase_price(self, line):
"""Return a string value of the 'purchase_price' field, rather than the 'Money' object."""
if line.purchase_price: