2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-01 21:16:46 +00:00

Specify ForeignKey widget for importing destination field (#6205) (#6206)

- Fixes https://github.com/inventree/InvenTree/issues/6201

(cherry picked from commit 7f231cb6c152b185a1756227f551b7b9762ff773)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2024-01-11 22:55:51 +11:00 committed by GitHub
parent a41efb31b6
commit 421081b8f6
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
@ -191,6 +192,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: