Merge pull request #2214 from SchrodingersGat/sales-order-export-fix

convert sale_price to string before exporting
This commit is contained in:
Oliver 2021-10-31 00:34:28 +11:00 committed by GitHub
commit fe5cb3ddca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,7 +83,9 @@ class POLineItemResource(ModelResource):
class SOLineItemResource(ModelResource):
""" Class for managing import / export of SOLineItem data """
"""
Class for managing import / export of SOLineItem data
"""
part_name = Field(attribute='part__name', readonly=True)
@ -93,6 +95,17 @@ class SOLineItemResource(ModelResource):
fulfilled = Field(attribute='fulfilled_quantity', readonly=True)
def dehydrate_sale_price(self, item):
"""
Return a string value of the 'sale_price' field, rather than the 'Money' object.
Ref: https://github.com/inventree/InvenTree/issues/2207
"""
if item.sale_price:
return str(item.sale_price)
else:
return ''
class Meta:
model = SalesOrderLineItem
skip_unchanged = True