Skip to content

Commit dd45d76

Browse files
author
John75SunCity
committed
feat: Container type selection with Type 01 as default
- Added Container Size section to create form - Type 01 is pre-selected and marked as 'Currently Accepted' - Shows dimensions and cubic feet for Type 01 - Other container types shown in collapsed section (read-only) - Controller auto-selects Type 01 by code/name if not selected - Fallback to any default type if Type 01 not found Currently only accepting Type 01 containers, other sizes shown for reference.
1 parent 47c7d5c commit dd45d76

File tree

2 files changed

+107
-2
lines changed

2 files changed

+107
-2
lines changed

records_management/controllers/portal.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,12 +2486,22 @@ def portal_container_create(self, **post):
24862486
'error_message': _('Please select a department.'),
24872487
})
24882488

2489-
# Container type - auto-select default if not provided
2489+
# Container type - auto-select Type 01 if not provided (standard accepted size)
24902490
if not container_type_id:
2491+
# First try to find Type 01 by code or name
24912492
default_type = request.env['records.container.type'].sudo().search([
2492-
('is_default', '=', True)
2493+
'|', '|',
2494+
('code', '=', 'TYPE01'),
2495+
('code', '=', '01'),
2496+
('name', 'ilike', 'Type 01')
24932497
], limit=1)
24942498
if not default_type:
2499+
# Fallback to any default type
2500+
default_type = request.env['records.container.type'].sudo().search([
2501+
('is_default', '=', True)
2502+
], limit=1)
2503+
if not default_type:
2504+
# Last resort - first available type
24952505
default_type = request.env['records.container.type'].sudo().search([], limit=1)
24962506
if default_type:
24972507
container_type_id = default_type.id

records_management/templates/portal_container_create.xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,101 @@
108108
</t>
109109
</div>
110110

111+
<!-- Container Size/Type -->
112+
<div class="row">
113+
<div class="col-md-12">
114+
<h5 class="border-bottom pb-2 mb-3 mt-3">
115+
<i class="fa fa-cube"></i> Container Size
116+
</h5>
117+
</div>
118+
</div>
119+
120+
<div class="row">
121+
<div class="col-md-12 mb-3">
122+
<label class="form-label">Container Type *</label>
123+
<div class="container-type-grid">
124+
<!-- Type 01 - Default and Currently Accepted -->
125+
<t t-foreach="container_types or []" t-as="ctype">
126+
<t t-if="ctype.code == 'TYPE01' or ctype.code == '01' or ctype.name == 'Type 01'">
127+
<div class="card mb-2 border-primary">
128+
<div class="card-body p-2">
129+
<div class="form-check">
130+
<input class="form-check-input" type="radio"
131+
name="container_type_id"
132+
t-att-id="'type_%s' % ctype.id"
133+
t-att-value="ctype.id"
134+
checked="checked"/>
135+
<label class="form-check-label w-100" t-att-for="'type_%s' % ctype.id">
136+
<strong class="text-primary">
137+
<i class="fa fa-check-circle"></i>
138+
<t t-esc="ctype.name"/>
139+
</strong>
140+
<span class="badge bg-success ms-2">Currently Accepted</span>
141+
<br/>
142+
<small class="text-muted">
143+
<t t-if="ctype.dimensions">
144+
Dimensions: <t t-esc="ctype.dimensions"/>
145+
</t>
146+
<t t-elif="ctype.length and ctype.width and ctype.height">
147+
<t t-esc="ctype.length"/>″ x <t t-esc="ctype.width"/>″ x <t t-esc="ctype.height"/>″
148+
</t>
149+
<t t-if="ctype.cubic_feet">
150+
| <t t-esc="'%.2f' % ctype.cubic_feet"/> cu ft
151+
</t>
152+
</small>
153+
</label>
154+
</div>
155+
</div>
156+
</div>
157+
</t>
158+
</t>
159+
160+
<!-- Other Types - Shown as disabled/read-only for reference -->
161+
<div class="mt-3">
162+
<a class="text-muted small" data-bs-toggle="collapse" href="#otherContainerTypes" role="button" aria-expanded="false">
163+
<i class="fa fa-info-circle"></i> View other container sizes (not currently accepted)
164+
</a>
165+
<div class="collapse mt-2" id="otherContainerTypes">
166+
<div class="card card-body bg-light p-2">
167+
<small class="text-muted mb-2">
168+
<i class="fa fa-lock"></i> These sizes are for reference only. We currently only accept Type 01 containers.
169+
</small>
170+
<t t-foreach="container_types or []" t-as="ctype">
171+
<t t-if="ctype.code != 'TYPE01' and ctype.code != '01' and ctype.name != 'Type 01'">
172+
<div class="d-flex justify-content-between align-items-center py-1 border-bottom">
173+
<span class="text-muted">
174+
<i class="fa fa-cube"></i>
175+
<t t-esc="ctype.name"/>
176+
<t t-if="ctype.code">
177+
(<t t-esc="ctype.code"/>)
178+
</t>
179+
</span>
180+
<small class="text-muted">
181+
<t t-if="ctype.dimensions">
182+
<t t-esc="ctype.dimensions"/>
183+
</t>
184+
<t t-elif="ctype.length and ctype.width and ctype.height">
185+
<t t-esc="ctype.length"/>″ x <t t-esc="ctype.width"/>″ x <t t-esc="ctype.height"/>″
186+
</t>
187+
</small>
188+
</div>
189+
</t>
190+
</t>
191+
</div>
192+
</div>
193+
</div>
194+
195+
<!-- Fallback: If no Type 01 found, show first type or create hidden default -->
196+
<t t-if="not container_types">
197+
<div class="alert alert-info">
198+
<i class="fa fa-info-circle"></i>
199+
Standard Type 01 container will be assigned automatically.
200+
</div>
201+
</t>
202+
</div>
203+
</div>
204+
</div>
205+
111206
<!-- Industry Template -->
112207
<div class="row">
113208
<div class="col-md-12">

0 commit comments

Comments
 (0)