From 602c30a372ed503adb533381bd6ce2e33ac23643 Mon Sep 17 00:00:00 2001 From: RomainFayolle Date: Fri, 3 Nov 2023 10:49:35 -0400 Subject: [PATCH] transaction_date in orderline export --- store/resources.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/store/resources.py b/store/resources.py index 25060b5e..ceea0f42 100644 --- a/store/resources.py +++ b/store/resources.py @@ -94,10 +94,7 @@ class OrderLineResource(resources.ModelResource): attribute='content_type__model', ) - transaction_date = fields.Field( - column_name='transaction_date', - attribute='order__transaction_date', - ) + transaction_date = fields.Field() item_name = fields.Field() @@ -115,6 +112,10 @@ def dehydrate_item_id(self, orderline): model = get_model_from_name(orderline.content_type.model) return model.objects.get(id=orderline.object_id).id + def dehydrate_transaction_date(self, orderline): + date = orderline.order.transaction_date + return date.strftime('%Y-%m-%d %H:%M:%S') + class Meta: model = OrderLine fields = (