From 9cafc4f72bbc14156678ec70a74a25bc230fd7b5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 May 2023 10:23:56 +0200 Subject: [PATCH 1/3] shared and customer details in exports lots --- ereuse_devicehub/inventory/views.py | 20 ++++++++++++++++--- .../templates/ereuse_devicehub/base_site.html | 6 +++--- .../templates/inventory/device_list.html | 12 ++++++++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 4ddf5a23..8ccb24f8 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -1323,12 +1323,18 @@ class ExportsView(View): 'Receiver Note Date', 'Receiver Note Units', 'Receiver Note Weight', + 'Customer Company Name', + 'Customer Location', ] ) - for lot in Lot.query.filter_by(owner=g.user): + all_lots = set(Lot.query.filter_by(owner=g.user).all()) + share_lots = [s.lot for s in ShareLot.query.filter_by(user_to=g.user)] + all_lots = all_lots.union(share_lots) + for lot in all_lots: delivery_note = lot.transfer and lot.transfer.delivery_note or '' receiver_note = lot.transfer and lot.transfer.receiver_note or '' + customer = lot.transfer and lot.transfer.customer_details or '' wb_devs = 0 placeholders = 0 @@ -1341,10 +1347,13 @@ class ExportsView(View): elif snapshots[-1].software in [SnapshotSoftware.Workbench]: wb_devs += 1 + type_lot = lot.type_transfer() + if lot in share_lots: + type_lot = "Shared" row = [ lot.id, lot.name, - lot.type_transfer(), + type_lot, lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '', lot.transfer and lot.transfer.code or '', lot.transfer and lot.transfer.date or '', @@ -1362,6 +1371,8 @@ class ExportsView(View): receiver_note and receiver_note.date or '', receiver_note and receiver_note.units or '', receiver_note and receiver_note.weight or '', + customer and customer.company_name or '', + customer and customer.location or '', ] cw.writerow(row) @@ -1391,11 +1402,14 @@ class ExportsView(View): for dev in self.find_devices(): for lot in dev.lots: + type_lot = lot.type_transfer() + if lot.is_shared: + type_lot = "Shared" row = [ dev.devicehub_id, lot.id, lot.name, - lot.type_transfer(), + type_lot, lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '', lot.transfer and lot.transfer.code or '', lot.transfer and lot.transfer.date or '', diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index 179dcfd4..aaec8d2e 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -193,7 +193,7 @@ {% else %} {% if lot and lot.is_incoming %}