shared and customer details in exports lots

This commit is contained in:
Cayo Puigdefabregas 2023-05-04 10:23:56 +02:00
parent 4e5dbe8cd1
commit 9cafc4f72b
3 changed files with 29 additions and 9 deletions

View file

@ -1323,12 +1323,18 @@ class ExportsView(View):
'Receiver Note Date', 'Receiver Note Date',
'Receiver Note Units', 'Receiver Note Units',
'Receiver Note Weight', '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 '' delivery_note = lot.transfer and lot.transfer.delivery_note or ''
receiver_note = lot.transfer and lot.transfer.receiver_note or '' receiver_note = lot.transfer and lot.transfer.receiver_note or ''
customer = lot.transfer and lot.transfer.customer_details or ''
wb_devs = 0 wb_devs = 0
placeholders = 0 placeholders = 0
@ -1341,10 +1347,13 @@ class ExportsView(View):
elif snapshots[-1].software in [SnapshotSoftware.Workbench]: elif snapshots[-1].software in [SnapshotSoftware.Workbench]:
wb_devs += 1 wb_devs += 1
type_lot = lot.type_transfer()
if lot in share_lots:
type_lot = "Shared"
row = [ row = [
lot.id, lot.id,
lot.name, lot.name,
lot.type_transfer(), type_lot,
lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '', lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '',
lot.transfer and lot.transfer.code or '', lot.transfer and lot.transfer.code or '',
lot.transfer and lot.transfer.date 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.date or '',
receiver_note and receiver_note.units or '', receiver_note and receiver_note.units or '',
receiver_note and receiver_note.weight or '', receiver_note and receiver_note.weight or '',
customer and customer.company_name or '',
customer and customer.location or '',
] ]
cw.writerow(row) cw.writerow(row)
@ -1391,11 +1402,14 @@ class ExportsView(View):
for dev in self.find_devices(): for dev in self.find_devices():
for lot in dev.lots: for lot in dev.lots:
type_lot = lot.type_transfer()
if lot.is_shared:
type_lot = "Shared"
row = [ row = [
dev.devicehub_id, dev.devicehub_id,
lot.id, lot.id,
lot.name, lot.name,
lot.type_transfer(), type_lot,
lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '', lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '',
lot.transfer and lot.transfer.code or '', lot.transfer and lot.transfer.code or '',
lot.transfer and lot.transfer.date or '', lot.transfer and lot.transfer.date or '',

View file

@ -193,7 +193,7 @@
{% else %} {% else %}
<a class="nav-link collapsed" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#"> <a class="nav-link collapsed" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#">
{% endif %} {% endif %}
<i class="bi bi-arrow-down-right"></i><span>Incoming Lots</span><i class="bi bi-chevron-down ms-auto"></i> <i class="bi bi-arrow-down-right"></i><span>Incoming</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
{% if lot and lot.is_incoming %} {% if lot and lot.is_incoming %}
<ul id="incoming-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav"> <ul id="incoming-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
@ -223,7 +223,7 @@
{% else %} {% else %}
<a class="nav-link collapsed" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#"> <a class="nav-link collapsed" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#">
{% endif %} {% endif %}
<i class="bi bi-arrow-up-right"></i><span>Outgoing Lots</span><i class="bi bi-chevron-down ms-auto"></i> <i class="bi bi-arrow-up-right"></i><span>Outgoing</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
{% if lot and lot.is_outgoing %} {% if lot and lot.is_outgoing %}
<ul id="outgoing-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav"> <ul id="outgoing-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
@ -253,7 +253,7 @@
{% else %} {% else %}
<a class="nav-link collapsed" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#"> <a class="nav-link collapsed" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#">
{% endif %} {% endif %}
<i class="bi bi-layout-text-window-reverse"></i><span>Temporary Lots</span><i <i class="bi bi-layout-text-window-reverse"></i><span>Temporary</span><i
class="bi bi-chevron-down ms-auto"></i> class="bi bi-chevron-down ms-auto"></i>
</a> </a>
{% if lot and lot.is_temporary %} {% if lot and lot.is_temporary %}

View file

@ -13,13 +13,13 @@
<li class="breadcrumb-item active">Unassigned</li> <li class="breadcrumb-item active">Unassigned</li>
{% endif %} {% endif %}
{% elif lot.is_temporary %} {% elif lot.is_temporary %}
<li class="breadcrumb-item active">Temporary Lot</li> <li class="breadcrumb-item active">Temporary</li>
<li class="breadcrumb-item active">{{ lot.name }}</li> <li class="breadcrumb-item active">{{ lot.name }}</li>
{% elif lot.is_incoming %} {% elif lot.is_incoming %}
<li class="breadcrumb-item active">Incoming Lot</li> <li class="breadcrumb-item active">Incoming</li>
<li class="breadcrumb-item active">{{ lot.name }}</li> <li class="breadcrumb-item active">{{ lot.name }}</li>
{% elif lot.is_outgoing %} {% elif lot.is_outgoing %}
<li class="breadcrumb-item active">Outgoing Lot</li> <li class="breadcrumb-item active">Outgoing</li>
<li class="breadcrumb-item active">{{ lot.name }}</li> <li class="breadcrumb-item active">{{ lot.name }}</li>
{% elif lot.is_shared %} {% elif lot.is_shared %}
<li class="breadcrumb-item active">Shared with me</li> <li class="breadcrumb-item active">Shared with me</li>
@ -352,6 +352,12 @@
Devices Spreadsheet Devices Spreadsheet
</a> </a>
</li> </li>
<li>
<a href="javascript:export_file('devices_lots')" class="dropdown-item">
<i class="bi bi-file-spreadsheet"></i>
Devices Lots Spreadsheet
</a>
</li>
</ul> </ul>
</div> </div>
{% endif %} {% endif %}