Skip to content

Commit bbba8ca

Browse files
author
John75SunCity
committed
fix: Portal inventory error + restore customer locations feature
- Fixed 'Invalid field status on records.container' error - Changed box.status to box.state in portal_inventory_template.xml - The model field is 'state' not 'status' - Restored Customer Staging Locations feature in portal - Added 'My Locations' tab to inventory dashboard tabs - Added Locations card to Overview section - Links to /my/inventory/locations for address/floor/room setup - Updated /my/inventory/counts endpoint - Changed from HTTP to JSON type for proper AJAX response - Added temp inventory count - Added staging locations count Container states are: pending, in, out, perm_out, destroyed (not draft - 'pending' is the initial state for newly created containers)
1 parent 54cb11a commit bbba8ca

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

records_management/controllers/portal.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5411,10 +5411,9 @@ def portal_reports_export(self, **kw):
54115411
values.update({'page_name': 'reports_export'})
54125412
return request.render('records_management.portal_reports_export', values)
54135413

5414-
@http.route(['/my/inventory/counts'], type='http', auth='user', website=True)
5414+
@http.route(['/my/inventory/counts'], type='json', auth='user', website=True)
54155415
def portal_inventory_counts(self, **kw):
5416-
"""Inventory count summary."""
5417-
values = self._prepare_portal_layout_values()
5416+
"""Inventory count summary - Returns JSON for AJAX calls."""
54185417
user = request.env.user
54195418
partner = user.partner_id
54205419

@@ -5425,17 +5424,26 @@ def portal_inventory_counts(self, **kw):
54255424
if accessible_departments:
54265425
domain.append(('department_id', 'in', accessible_departments))
54275426

5428-
counts = {
5429-
'containers': request.env['records.container'].search_count(domain),
5430-
'files': request.env['records.file'].search_count(domain),
5431-
'documents': request.env['records.document'].search_count(domain),
5432-
}
5427+
# Get counts for all inventory types
5428+
containers_count = request.env['records.container'].search_count(domain)
5429+
files_count = request.env['records.file'].search_count(domain)
5430+
documents_count = request.env['records.document'].search_count(domain)
5431+
5432+
# Temp inventory count
5433+
temp_domain = [('partner_id', '=', partner.commercial_partner_id.id)]
5434+
temp_count = request.env['temp.inventory'].search_count(temp_domain)
5435+
5436+
# Customer staging locations count
5437+
locations_domain = [('partner_id', '=', partner.commercial_partner_id.id)]
5438+
locations_count = request.env['customer.staging.location'].search_count(locations_domain)
54335439

5434-
values.update({
5435-
'counts': counts,
5436-
'page_name': 'inventory_counts',
5437-
})
5438-
return request.render('records_management.portal_inventory_enhanced', values)
5440+
return {
5441+
'containers': containers_count,
5442+
'files': files_count,
5443+
'documents': documents_count,
5444+
'temp': temp_count,
5445+
'locations': locations_count,
5446+
}
54395447

54405448
@http.route(['/my/inventory/recent_activity'], type='http', auth='user', website=True)
54415449
def portal_inventory_recent_activity(self, page=1, **kw):

records_management/templates/my_portal_inventory.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@
8686
<span class="badge badge-warning ml-1">0</span>
8787
</a>
8888
</li>
89+
<li class="nav-item" role="presentation">
90+
<a class="nav-link" id="locations-tab" data-toggle="tab" href="#locations" role="tab">
91+
<i class="fa fa-map-marker"></i> My Locations
92+
<span class="badge badge-secondary ml-1">0</span>
93+
</a>
94+
</li>
8995
</ul>
9096

9197
<!-- Tab Content -->
@@ -135,6 +141,21 @@
135141
</div>
136142
</div>
137143

144+
<!-- Second Row: Locations Card -->
145+
<div class="row mt-3">
146+
<div class="col-md-4">
147+
<div class="card text-center bg-secondary text-white">
148+
<div class="card-body">
149+
<i class="fa fa-map-marker fa-2x mb-2"></i>
150+
<h4 id="locations-count">Loading...</h4>
151+
<p>My Locations</p>
152+
<small class="d-block mb-2">Organize by floor, room, department</small>
153+
<button class="btn btn-light btn-sm" onclick="switchTab('locations')">Manage Locations</button>
154+
</div>
155+
</div>
156+
</div>
157+
</div>
158+
138159
<!-- Recent Activity -->
139160
<div class="card mt-4">
140161
<div class="card-header">
@@ -165,6 +186,11 @@
165186
<div class="tab-pane fade" id="temp" role="tabpanel">
166187
<iframe id="temp-frame" src="/my/inventory/temp" style="width: 100%; height: 800px; border: none;"></iframe>
167188
</div>
189+
190+
<!-- Customer Locations Tab (Address/Floor/Room Setup) -->
191+
<div class="tab-pane fade" id="locations" role="tabpanel">
192+
<iframe id="locations-frame" src="/my/inventory/locations" style="width: 100%; height: 800px; border: none;"></iframe>
193+
</div>
168194
</div>
169195
</div>
170196

@@ -190,6 +216,7 @@
190216
$('#files-count').text(data.files || 0);
191217
$('#documents-count').text(data.documents || 0);
192218
$('#temp-count').text(data.temp || 0);
219+
$('#locations-count').text(data.locations || 0);
193220
},
194221
error: function() {
195222
$('#containers-count, #files-count, #documents-count, #temp-count').text('Error');

records_management/templates/portal_inventory_template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
<p><strong>Document Count:</strong> <t t-esc="box.document_count"/></p>
260260
</div>
261261
<div class="col-md-6">
262-
<p><strong>Status:</strong> <t t-esc="box.status"/></p>
262+
<p><strong>Status:</strong> <t t-esc="dict(box._fields['state'].selection).get(box.state, box.state) if box.state else 'Pending'"/></p>
263263
<p><strong>Last Activity:</strong> <t t-esc="box.last_activity_date"/></p>
264264
<p><strong>Storage Fee:</strong> <t t-esc="box.storage_fee_monthly"/></p>
265265
</div>

0 commit comments

Comments
 (0)