feat(portal): fix configurator 500, hide manual measurements, upgrade job card

1. Configurator step 2/3 500 fix: fp.coating.config was retired
   (Sub-11) but the controller still queried it -> KeyError. Swapped
   to fusion.plating.process.type (the real coating taxonomy on entech:
   Hard Chrome, EN Low Phos, Type I Anodize, etc). Step 2 template
   dropped dead refs (coat.process_type_id / spec_reference / thickness_*
   / certification_level), now shows code + process_family + description.
   Pricing helper relaxed: filters out rules keyed to the dead model
   and silently returns {'available': False} -> template shows 'Quote
   will be priced by EN Plating' instead of fake numbers.

2. Configurator step 1: manual measurements hidden per customer
   feedback. Length/Width/Height/Surface Area are kept as hidden 0s so
   the rest of the flow doesn't error; backend trimesh still auto-calcs
   surface area silently when STL is uploaded. Single file input split
   into two: separate Drawing (PDF) + 3D Model (STL/STP/STEP/IGES)
   uploads so customer can send both. Multi-upload session shape:
   attachment_ids list. Submit handler re-keys ALL uploads onto the
   new quote_request.

3. Job card upgraded: new fp_portal_job_card macro shared by dashboard
   + jobs list. Renders wrap div containing main anchor (whole card
   clickable -> detail page) + sibling actions footer (4 doc download
   quick-buttons: SO / WO / CoC / Packing + Repeat Order form).
   Forms-inside-anchor is invalid HTML so the footer lives as a
   sibling, not a child. Card now shows part name+number and ship-to
   address pulled inline from job.x_fc_job_id.sale_order_id chain.
   Same data also added to detail-page hero for consistency.

Version bump: 19.0.3.6.0 -> 19.0.3.7.0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-17 12:34:06 -04:00
parent 153b980e2b
commit 2802fcf738
7 changed files with 393 additions and 256 deletions

View File

@@ -5,7 +5,7 @@
{ {
'name': 'Fusion Plating — Customer Portal', 'name': 'Fusion Plating — Customer Portal',
'version': '19.0.3.6.0', 'version': '19.0.3.7.0',
'category': 'Manufacturing/Plating', 'category': 'Manufacturing/Plating',
'summary': 'Customer-facing portal for plating shops: online RFQ, job status, ' 'summary': 'Customer-facing portal for plating shops: online RFQ, job status, '
'CoC downloads, invoice access.', 'CoC downloads, invoice access.',

View File

@@ -53,42 +53,58 @@ class FpPortalConfigurator(CustomerPortal):
'part_name': kw.get('part_name', ''), 'part_name': kw.get('part_name', ''),
'part_number': kw.get('part_number', ''), 'part_number': kw.get('part_number', ''),
'substrate_material': kw.get('substrate_material', 'steel'), 'substrate_material': kw.get('substrate_material', 'steel'),
'geometry_source': kw.get('geometry_source', 'manual'), 'geometry_source': kw.get('geometry_source', 'upload'),
# Manual measurements are HIDDEN in the template per customer
# feedback 2026-05-17 — kept as hidden 0s so the rest of the
# flow doesn't error on missing keys. Backend computes them
# if/when needed.
'surface_area': float(kw.get('surface_area', 0) or 0), 'surface_area': float(kw.get('surface_area', 0) or 0),
'dimensions_length': float(kw.get('dimensions_length', 0) or 0), 'dimensions_length': float(kw.get('dimensions_length', 0) or 0),
'dimensions_width': float(kw.get('dimensions_width', 0) or 0), 'dimensions_width': float(kw.get('dimensions_width', 0) or 0),
'dimensions_height': float(kw.get('dimensions_height', 0) or 0), 'dimensions_height': float(kw.get('dimensions_height', 0) or 0),
# Multi-upload: customer may submit drawing + 3D + others.
# Collect IDs in a list so they all flow through to the RFQ.
'attachment_ids': [],
'attachment_names': [],
} }
# Handle file upload
file_upload = kw.get('part_file') def _save_upload(file_upload, label):
if file_upload and hasattr(file_upload, 'read'): """Persist a single uploaded file and append to session lists.
Returns the attachment record or None."""
if not (file_upload and hasattr(file_upload, 'read')):
return None
file_data = file_upload.read() file_data = file_upload.read()
if file_data: if not file_data:
return None
attachment = request.env['ir.attachment'].sudo().create({ attachment = request.env['ir.attachment'].sudo().create({
'name': file_upload.filename, 'name': file_upload.filename,
'datas': base64.b64encode(file_data), 'datas': base64.b64encode(file_data),
'res_model': 'fusion.plating.quote.request', 'res_model': 'fusion.plating.quote.request',
'type': 'binary', 'type': 'binary',
}) })
session_data['attachment_id'] = attachment.id session_data['attachment_ids'].append(attachment.id)
session_data['attachment_name'] = file_upload.filename session_data['attachment_names'].append(
'%s (%s)' % (file_upload.filename, label),
)
# STL surface-area auto-calc (silent — backend value only,
# not surfaced in UI per the hidden-measurements decision).
fname = file_upload.filename.lower() fname = file_upload.filename.lower()
if fname.endswith(('.stl', '.stp', '.step', '.iges', '.igs')):
session_data['geometry_source'] = '3d_model'
else:
session_data['geometry_source'] = 'pdf_drawing'
# Try to calculate surface area for STL files
if fname.endswith('.stl'): if fname.endswith('.stl'):
try: try:
import io import io
import trimesh import trimesh
mesh = trimesh.load(io.BytesIO(file_data), file_type='stl') mesh = trimesh.load(io.BytesIO(file_data), file_type='stl')
# Convert mm^2 to sq in (1 sq in = 645.16 mm^2) # mm^2 -> sq in (1 sq in = 645.16 mm^2)
session_data['surface_area'] = round(mesh.area / 645.16, 4) session_data['surface_area'] = round(mesh.area / 645.16, 4)
session_data['auto_calculated'] = True session_data['auto_calculated'] = True
except Exception: except Exception:
_logger.info('Could not auto-calculate STL surface area (trimesh not available).') _logger.info('STL surface-area auto-calc skipped (trimesh missing or bad mesh).')
return attachment
_save_upload(kw.get('part_drawing'), 'drawing')
_save_upload(kw.get('part_3d_model'), '3D model')
# Back-compat: legacy single-file input still accepted.
_save_upload(kw.get('part_file'), 'attachment')
request.session['fp_configurator'] = session_data request.session['fp_configurator'] = session_data
return request.redirect('/my/configurator/coating') return request.redirect('/my/configurator/coating')
@@ -128,8 +144,11 @@ class FpPortalConfigurator(CustomerPortal):
request.session['fp_configurator'] = session_data request.session['fp_configurator'] = session_data
return request.redirect('/my/configurator/estimate') return request.redirect('/my/configurator/estimate')
coatings = request.env['fp.coating.config'].sudo().search( # fp.coating.config retired post-Sub-11. Use process.type as the
[('active', '=', True)], order='sequence', # customer-facing coating picker — its records (Hard Chrome, EN
# Low-Phos, etc.) are exactly what a customer would select from.
coatings = request.env['fusion.plating.process.type'].sudo().search(
[('active', '=', True)], order='sequence, name',
) )
return request.render('fusion_plating_portal.portal_configurator_step2', { return request.render('fusion_plating_portal.portal_configurator_step2', {
'page_name': 'fp_configurator', 'page_name': 'fp_configurator',
@@ -147,14 +166,20 @@ class FpPortalConfigurator(CustomerPortal):
if not session_data or not session_data.get('coating_config_id'): if not session_data or not session_data.get('coating_config_id'):
return request.redirect('/my/configurator/new') return request.redirect('/my/configurator/new')
coating = request.env['fp.coating.config'].sudo().browse( coating = request.env['fusion.plating.process.type'].sudo().browse(
session_data['coating_config_id'], session_data['coating_config_id'],
) )
if not coating.exists(): if not coating.exists():
return request.redirect('/my/configurator/coating') return request.redirect('/my/configurator/coating')
# Calculate estimated price from pricing rules # Estimate price from pricing rules. Best-effort: returns
# {'available': False} when rules don't match or process.type
# lacks the data the rules expect (post-coating-retire transition).
try:
estimated_price = self._estimate_price(session_data, coating) estimated_price = self._estimate_price(session_data, coating)
except Exception:
_logger.info('Skipping price estimate — pricing helper unavailable.', exc_info=True)
estimated_price = {'min': 0, 'max': 0, 'available': False}
return request.render('fusion_plating_portal.portal_configurator_step3', { return request.render('fusion_plating_portal.portal_configurator_step3', {
'page_name': 'fp_configurator', 'page_name': 'fp_configurator',
@@ -177,7 +202,7 @@ class FpPortalConfigurator(CustomerPortal):
return request.redirect('/my/configurator/new') return request.redirect('/my/configurator/new')
partner = request.env.user.partner_id partner = request.env.user.partner_id
coating = request.env['fp.coating.config'].sudo().browse( coating = request.env['fusion.plating.process.type'].sudo().browse(
session_data['coating_config_id'], session_data['coating_config_id'],
) )
@@ -213,21 +238,28 @@ class FpPortalConfigurator(CustomerPortal):
'special_instructions': kw.get('special_instructions', ''), 'special_instructions': kw.get('special_instructions', ''),
} }
# Link coating process type # Link the selected process type (coating IS the process type now
if coating.exists() and coating.process_type_id: # that fp.coating.config is retired).
vals['process_type_ids'] = [(4, coating.process_type_id.id)] if coating.exists():
vals['process_type_ids'] = [(4, coating.id)]
quote = request.env['fusion.plating.quote.request'].sudo().create(vals) quote = request.env['fusion.plating.quote.request'].sudo().create(vals)
# Attach uploaded file to the quote request # Re-key uploaded attachments onto the new quote request so they
attachment_id = session_data.get('attachment_id') # appear on its chatter. Multi-upload — customer may have sent
if attachment_id: # both a drawing and a 3D model (or more).
attachment = request.env['ir.attachment'].sudo().browse(attachment_id) att_ids = session_data.get('attachment_ids') or []
if not att_ids and session_data.get('attachment_id'):
# Back-compat for old session shape (single attachment_id key).
att_ids = [session_data['attachment_id']]
for att_id in att_ids:
attachment = request.env['ir.attachment'].sudo().browse(att_id)
if attachment.exists(): if attachment.exists():
attachment.write({ attachment.write({
'res_model': 'fusion.plating.quote.request', 'res_model': 'fusion.plating.quote.request',
'res_id': quote.id, 'res_id': quote.id,
}) })
if 'drawing_attachment_ids' in quote._fields:
quote.drawing_attachment_ids = [(4, attachment.id)] quote.drawing_attachment_ids = [(4, attachment.id)]
# Clear session # Clear session
@@ -242,40 +274,37 @@ class FpPortalConfigurator(CustomerPortal):
# Pricing helper # Pricing helper
# ====================================================================== # ======================================================================
def _estimate_price(self, session_data, coating): def _estimate_price(self, session_data, coating):
"""Calculate estimated price range from pricing rules. """Best-effort price estimate. Returns {'min', 'max', 'available'}.
Returns a dict with ``min``, ``max``, and ``available`` keys. Post-coating-retire (Sub-11) the rule schema still references
The range is deliberately wide (+/- 15-25%) because final quotes fp.coating.config; ``coating`` here is now a process.type record.
account for masking complexity, rack configuration, etc. That means rules with a ``coating_config_id`` set won't match
and we silently fall through to {'available': False} — which
the template renders as 'Quote will be priced by EN Plating'.
Estimate is non-essential; final price comes from EN's review.
""" """
rules = request.env['fp.pricing.rule'].sudo().search( Rule = request.env.get('fp.pricing.rule')
[('active', '=', True)], order='sequence', if Rule is None:
) return {'min': 0, 'max': 0, 'available': False}
rules = Rule.sudo().search([('active', '=', True)], order='sequence')
area = float(session_data.get('surface_area', 0)) area = float(session_data.get('surface_area', 0))
qty = int(session_data.get('quantity', 1)) qty = int(session_data.get('quantity', 1))
substrate = session_data.get('substrate_material', '') substrate = session_data.get('substrate_material', '')
cert_level = coating.certification_level if coating else 'commercial'
if not area or not rules: if not area or not rules:
return {'min': 0, 'max': 0, 'available': False} return {'min': 0, 'max': 0, 'available': False}
# Find best matching rule (same scoring as fp.quote.configurator)
best = None best = None
best_score = -1 best_score = -1
for rule in rules: for rule in rules:
score = 0 score = 0
if rule.coating_config_id: # Skip any rule keyed to coating_config — model is gone.
if rule.coating_config_id.id != coating.id: if 'coating_config_id' in rule._fields and rule.coating_config_id:
continue continue
score += 4 if getattr(rule, 'substrate_material', None):
if rule.substrate_material:
if rule.substrate_material != substrate: if rule.substrate_material != substrate:
continue continue
score += 2 score += 2
if rule.certification_level:
if rule.certification_level != cert_level:
continue
score += 1
if score > best_score: if score > best_score:
best_score = score best_score = score
best = rule best = rule
@@ -283,7 +312,6 @@ class FpPortalConfigurator(CustomerPortal):
if not best: if not best:
return {'min': 0, 'max': 0, 'available': False} return {'min': 0, 'max': 0, 'available': False}
# Calculate base price
if best.pricing_method == 'per_sqin': if best.pricing_method == 'per_sqin':
unit = area * best.base_rate unit = area * best.base_rate
elif best.pricing_method == 'per_sqft': elif best.pricing_method == 'per_sqft':
@@ -293,17 +321,10 @@ class FpPortalConfigurator(CustomerPortal):
else: else:
unit = best.base_rate unit = best.base_rate
# Apply thickness factor (use min thickness from coating) base_total = unit * qty + (best.setup_fee or 0)
thickness = coating.thickness_min or 1.0
unit *= thickness * best.thickness_factor
base_total = unit * qty + best.setup_fee
# Apply minimum charge
if best.minimum_charge and base_total < best.minimum_charge: if best.minimum_charge and base_total < best.minimum_charge:
base_total = best.minimum_charge base_total = best.minimum_charge
# Return a range (85% to 125%) to account for complexity, masking, etc.
return { return {
'min': round(base_total * 0.85, 2), 'min': round(base_total * 0.85, 2),
'max': round(base_total * 1.25, 2), 'max': round(base_total * 1.25, 2),

View File

@@ -91,38 +91,48 @@
} }
} }
// Job card: outer wrap is a plain div so we can place an interactive
// actions footer (Repeat Order form, doc download links) as a SIBLING
// of the main anchor — forms inside anchors are invalid HTML and
// browser-buggy. Hover/lift effect lives on the wrap; click target is
// the inner .o_fp_job_card_main anchor only.
.o_fp_job_card { .o_fp_job_card {
@extend .o_fp_card; @extend .o_fp_card;
padding: $fp-space-4; padding: $fp-space-4;
border-radius: $fp-radius-tile; border-radius: $fp-radius-tile;
margin-bottom: $fp-space-3; margin-bottom: $fp-space-3;
box-shadow: $fp-shadow-card; box-shadow: $fp-shadow-card;
transition: box-shadow .15s ease, transform .08s ease, border-color .15s ease;
// Works for both <div> and <a> wrappers. When rendered as an anchor &:hover {
// the whole card becomes a click target (jobs list + dashboard). box-shadow: $fp-shadow-card-hover;
border-color: $fp-aqua;
transform: translateY(-1px);
}
}
.o_fp_job_card_main {
display: block; display: block;
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
transition: box-shadow .15s ease, transform .08s ease, border-color .15s ease;
&:hover, &:hover,
&:focus-visible { &:focus-visible {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
box-shadow: $fp-shadow-card-hover;
border-color: $fp-aqua;
transform: translateY(-1px);
} }
&:focus-visible { &:focus-visible {
outline: 2px solid $fp-teal; outline: 2px solid $fp-teal;
outline-offset: 2px; outline-offset: 2px;
} }
}
.o_fp_job_header { .o_fp_job_header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: flex-start;
margin-bottom: $fp-space-3; margin-bottom: .55rem;
gap: .65rem;
.o_fp_job_ref { .o_fp_job_ref {
font-weight: 600; font-weight: 600;
@@ -132,18 +142,78 @@
.o_fp_job_meta { .o_fp_job_meta {
color: $fp-muted; color: $fp-muted;
font-size: .8rem; font-size: .8rem;
margin-left: .65rem; margin-left: .55rem;
}
} }
}
.o_fp_job_docs { // Part name / number row under the header
.o_fp_job_part {
color: $fp-text-body;
font-size: .78rem;
margin-bottom: .2rem;
.o_fp_job_part_icon { color: $fp-muted-light; margin-right: .3rem; }
}
// Shipping address row
.o_fp_job_ship {
color: $fp-muted;
font-size: .76rem;
margin-bottom: $fp-space-3;
.o_fp_job_ship_icon { color: $fp-muted-light; margin-right: .3rem; }
}
// Actions footer — siblings of the main anchor. Doc download chips on
// the left, Repeat Order on the right. Border-top visually separates.
.o_fp_job_card_actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: $fp-space-3;
margin-top: $fp-space-3;
padding-top: .7rem;
border-top: 1px solid $fp-section-bg;
flex-wrap: wrap;
}
.o_fp_job_card_docs {
display: flex;
align-items: center;
gap: .4rem;
flex-wrap: wrap;
}
// Compact icon-only download chip. Tooltip via `title` attr.
.o_fp_doc_quick_btn {
display: inline-flex;
align-items: center;
gap: .25rem;
padding: .3rem .55rem;
background: $fp-section-bg;
color: $fp-teal;
border: 1px solid $fp-card-border;
border-radius: $fp-radius-chip;
font-size: .72rem;
font-weight: 500;
text-decoration: none;
transition: background .12s ease, color .12s ease;
&:hover {
background: $fp-mint;
color: $fp-teal-dark;
text-decoration: none;
}
&.o_fp_doc_quick_btn_pending {
background: $fp-card-bg;
color: $fp-muted-light;
border: 1px dashed $fp-card-border-dark;
cursor: not-allowed;
pointer-events: none;
}
}
// Legacy: kept for any place still rendering chips below the stepper.
.o_fp_job_docs {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: .35rem; gap: .35rem;
margin-top: $fp-space-3; margin-top: $fp-space-3;
padding-top: .6rem; padding-top: .6rem;
border-top: 1px solid $fp-section-bg; border-top: 1px solid $fp-section-bg;
}
} }
.o_fp_secondary_panels { .o_fp_secondary_panels {

View File

@@ -156,67 +156,49 @@
</select> </select>
</div> </div>
<!-- File Upload --> <!-- File Uploads — separate drawing + 3D model.
<div class="mb-4"> Customer can upload either or both. STL gets
<label class="form-label">Part Drawing or 3D Model</label> trimesh surface-area auto-calc server-side
<div class="o_fp_file_drop_zone p-4"> (not shown to customer — backend uses it for
<i class="fa fa-cloud-upload"/> future pricing). -->
<p class="mb-1 fw-semibold"> <div class="row">
Drag and drop your file here, or click to browse <div class="col-md-6 mb-4">
</p> <label class="form-label">Drawing (PDF)</label>
<div class="o_fp_file_drop_zone p-3">
<i class="fa fa-file-pdf-o"/>
<p class="mb-1 fw-semibold">PDF drawing</p>
<p class="small text-muted mb-2"> <p class="small text-muted mb-2">
Accepted: STL, STP, STEP, IGES, PDF (max 50 MB) 2D / dimensioned drawing
</p> </p>
<input type="file" name="part_file" id="part_file" <input type="file" name="part_drawing" id="part_drawing"
class="form-control" class="form-control"
accept=".stl,.stp,.step,.iges,.igs,.pdf"/> accept=".pdf"/>
</div>
</div>
<div class="col-md-6 mb-4">
<label class="form-label">3D Model</label>
<div class="o_fp_file_drop_zone p-3">
<i class="fa fa-cube"/>
<p class="mb-1 fw-semibold">STL / STP / STEP / IGES</p>
<p class="small text-muted mb-2">
Optional — speeds up estimation
</p>
<input type="file" name="part_3d_model" id="part_3d_model"
class="form-control"
accept=".stl,.stp,.step,.iges,.igs"/>
</div>
</div> </div>
</div> </div>
<hr class="my-4"/> <!-- Manual measurements hidden per customer-feedback 2026-05-17:
backend computes these (or doesn't) — not the
<!-- Manual Measurements --> customer's job. Fields kept as hidden inputs at 0
<h6 class="mb-3"> so the controller doesn't error on missing keys. -->
<i class="fa fa-ruler-combined me-2"/>Manual Measurements <input type="hidden" name="geometry_source" value="upload"/>
<span class="text-muted small fw-normal ms-2"> <input type="hidden" name="dimensions_length" value="0"/>
(if no 3D model uploaded) <input type="hidden" name="dimensions_width" value="0"/>
</span> <input type="hidden" name="dimensions_height" value="0"/>
</h6> <input type="hidden" name="surface_area" value="0"/>
<input type="hidden" name="geometry_source" value="manual"/>
<div class="row mb-3">
<div class="col-md-4">
<label for="dimensions_length" class="form-label">Length (in)</label>
<input type="number" step="0.001" min="0"
id="dimensions_length" name="dimensions_length"
class="form-control" placeholder="0.000"/>
</div>
<div class="col-md-4">
<label for="dimensions_width" class="form-label">Width (in)</label>
<input type="number" step="0.001" min="0"
id="dimensions_width" name="dimensions_width"
class="form-control" placeholder="0.000"/>
</div>
<div class="col-md-4">
<label for="dimensions_height" class="form-label">Height (in)</label>
<input type="number" step="0.001" min="0"
id="dimensions_height" name="dimensions_height"
class="form-control" placeholder="0.000"/>
</div>
</div>
<div class="mb-4">
<label for="surface_area" class="form-label">
Surface Area (sq in)
<span class="text-muted small fw-normal ms-1">
-- auto-calculated if STL uploaded
</span>
</label>
<input type="number" step="0.0001" min="0"
id="surface_area" name="surface_area"
class="form-control" placeholder="0.0000"/>
</div>
<!-- Navigation --> <!-- Navigation -->
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
@@ -295,26 +277,13 @@
<h6 class="card-title mb-2" style="color: var(--bs-body-color);"> <h6 class="card-title mb-2" style="color: var(--bs-body-color);">
<t t-out="coat.name"/> <t t-out="coat.name"/>
</h6> </h6>
<p t-if="coat.process_type_id" class="small text-muted mb-1"> <p t-if="coat.code" class="small text-muted mb-1">
<i class="fa fa-tag me-1"/>
<t t-out="coat.code"/>
</p>
<p t-if="coat.process_family" class="small text-muted mb-1">
<i class="fa fa-flask me-1"/> <i class="fa fa-flask me-1"/>
<t t-out="coat.process_type_id.name"/> <t t-out="dict(coat._fields['process_family']._description_selection(coat.env)).get(coat.process_family)"/>
</p>
<p t-if="coat.spec_reference" class="small text-muted mb-1">
<i class="fa fa-bookmark me-1"/>
<t t-out="coat.spec_reference"/>
</p>
<p t-if="coat.thickness_min or coat.thickness_max" class="small text-muted mb-1">
<i class="fa fa-arrows-v me-1"/>
<t t-if="coat.thickness_min" t-out="coat.thickness_min"/>
<t t-if="coat.thickness_min and coat.thickness_max"> - </t>
<t t-if="coat.thickness_max" t-out="coat.thickness_max"/>
<t t-out="coat.thickness_uom or 'mils'"/>
</p>
<p t-if="coat.certification_level and coat.certification_level != 'commercial'"
class="small mb-0">
<span class="badge text-bg-warning">
<t t-out="dict(coat._fields['certification_level']._description_selection(coat.env)).get(coat.certification_level)"/>
</span>
</p> </p>
<p t-if="coat.description" class="small text-muted mt-2 mb-0" <p t-if="coat.description" class="small text-muted mt-2 mb-0"
t-out="coat.description"/> t-out="coat.description"/>
@@ -408,9 +377,9 @@
<strong t-out="coating.name"/> <strong t-out="coating.name"/>
</div> </div>
</div> </div>
<div t-if="coating.spec_reference" class="row mb-3"> <div t-if="coating.code" class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Spec</div> <div class="col-sm-4 text-muted small fw-semibold">Code</div>
<div class="col-sm-8" t-out="coating.spec_reference"/> <div class="col-sm-8" t-out="coating.code"/>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Quantity</div> <div class="col-sm-4 text-muted small fw-semibold">Quantity</div>

View File

@@ -67,49 +67,9 @@
<t t-if="recent_jobs"> <t t-if="recent_jobs">
<t t-foreach="recent_jobs[:3]" t-as="job"> <t t-foreach="recent_jobs[:3]" t-as="job">
<a t-att-href="'/my/jobs/%s' % job.id" class="o_fp_job_card"> <t t-call="fusion_plating_portal.fp_portal_job_card">
<div class="o_fp_job_header"> <t t-set="job" t-value="job"/>
<div>
<span class="o_fp_job_ref" t-out="job.name"/>
<span class="o_fp_job_meta">
<t t-if="job.quantity"><t t-out="job.quantity"/> units</t>
<t t-if="job.target_ship_date"> · ETA <span t-field="job.target_ship_date" t-options='{"widget": "date"}'/></t>
</span>
</div>
<t t-call="fusion_plating_portal.fp_portal_status_badge">
<t t-set="state" t-value="job.state"/>
<t t-set="label" t-value="dict(job._fields['state']._description_selection(job.env)).get(job.state)"/>
</t> </t>
</div>
<!-- State -> active step index mapping.
5 customer-visible stages: Received / Inspected / Plating / QC / Ship.
state_idx >= 5 means all done (shipped or complete). -->
<t t-set="state_to_idx" t-value="{'received': 0, 'in_progress': 2, 'quality_check': 3, 'ready_to_ship': 4, 'shipped': 5, 'complete': 5}"/>
<t t-set="state_idx" t-value="state_to_idx.get(job.state, 0)"/>
<t t-set="steps" t-value="[
{'label': 'Received', 'status': 'done' if state_idx > 0 else 'active', 'time_label': ''},
{'label': 'Inspected', 'status': 'done' if state_idx > 1 else ('active' if state_idx == 1 else 'pending'), 'time_label': ''},
{'label': 'Plating', 'status': 'done' if state_idx > 2 else ('active' if state_idx == 2 else 'pending'), 'time_label': ''},
{'label': 'QC', 'status': 'done' if state_idx > 3 else ('active' if state_idx == 3 else 'pending'), 'time_label': ''},
{'label': 'Ship', 'status': 'done' if state_idx > 4 else ('active' if state_idx == 4 else 'pending'), 'time_label': ''},
]"/>
<t t-set="active_state" t-value="'warn' if job.state == 'quality_check' else 'normal'"/>
<t t-call="fusion_plating_portal.fp_portal_stepper"/>
<!-- Doc chips: CoC + tracking (V1) -->
<div class="o_fp_job_docs">
<t t-if="job.coc_attachment_id">
<span class="o_fp_doc_chip">📑 CoC</span>
</t>
<t t-else="">
<span class="o_fp_doc_chip o_fp_doc_chip_pending">📑 CoC · pending</span>
</t>
<t t-if="job.tracking_ref">
<span class="o_fp_doc_chip">📦 <span t-out="job.tracking_ref"/></span>
</t>
</div>
</a>
</t> </t>
<t t-if="job_count > 3"> <t t-if="job_count > 3">

View File

@@ -78,6 +78,129 @@
</t> </t>
</template> </template>
<!-- ================================================================== -->
<!-- Job card — shared between /my/home dashboard and /my/jobs list. -->
<!-- Pass `job` (fusion.plating.portal.job). Renders a wrap div with -->
<!-- inner anchor (whole card click target = detail page) and a sibling -->
<!-- actions footer (doc download chips + Repeat Order form). Forms -->
<!-- live OUTSIDE the anchor because forms-inside-anchors is invalid -->
<!-- HTML and clicks would otherwise double-fire. -->
<!-- ================================================================== -->
<template id="fp_portal_job_card" name="Portal: Job Card">
<!-- Pull related backend records inline (cards are 3-5 per page,
query cost is fine). Each `t-set` is a no-op if the field
chain breaks. -->
<t t-set="backend_job" t-value="job.x_fc_job_id if 'x_fc_job_id' in job._fields else False"/>
<t t-set="so" t-value="backend_job.sale_order_id if backend_job and 'sale_order_id' in backend_job._fields else False"/>
<t t-set="part" t-value="backend_job.part_catalog_id if backend_job and 'part_catalog_id' in backend_job._fields else False"/>
<t t-set="ship_to" t-value="so.partner_shipping_id if so else False"/>
<t t-set="picking" t-value="so.picking_ids.filtered(lambda p: p.state == 'done')[:1] if so and 'picking_ids' in so._fields else False"/>
<!-- Stepper state mapping (same as detail page).
received -> idx 0; in_progress -> 2; quality_check -> 3;
ready_to_ship -> 4; shipped / complete -> 5 (all done). -->
<t t-set="state_to_idx" t-value="{'received': 0, 'in_progress': 2, 'quality_check': 3, 'ready_to_ship': 4, 'shipped': 5, 'complete': 5}"/>
<t t-set="state_idx" t-value="state_to_idx.get(job.state, 0)"/>
<t t-set="steps" t-value="[
{'label': 'Received', 'status': 'done' if state_idx > 0 else 'active', 'time_label': ''},
{'label': 'Inspected', 'status': 'done' if state_idx > 1 else ('active' if state_idx == 1 else 'pending'), 'time_label': ''},
{'label': 'Plating', 'status': 'done' if state_idx > 2 else ('active' if state_idx == 2 else 'pending'), 'time_label': ''},
{'label': 'QC', 'status': 'done' if state_idx > 3 else ('active' if state_idx == 3 else 'pending'), 'time_label': ''},
{'label': 'Ship', 'status': 'done' if state_idx > 4 else ('active' if state_idx == 4 else 'pending'), 'time_label': ''},
]"/>
<t t-set="active_state" t-value="'warn' if job.state == 'quality_check' else 'normal'"/>
<div class="o_fp_job_card">
<a t-att-href="'/my/jobs/%s' % job.id" class="o_fp_job_card_main">
<div class="o_fp_job_header">
<div>
<span class="o_fp_job_ref" t-out="job.name"/>
<span class="o_fp_job_meta">
<t t-if="job.quantity"><t t-out="job.quantity"/> units</t>
<t t-if="job.target_ship_date"> · ETA <span t-field="job.target_ship_date" t-options='{"widget": "date"}'/></t>
</span>
</div>
<t t-call="fusion_plating_portal.fp_portal_status_badge">
<t t-set="state" t-value="job.state"/>
<t t-set="label" t-value="dict(job._fields['state']._description_selection(job.env)).get(job.state)"/>
</t>
</div>
<!-- Part info: prefer the part catalog ref, fall back to
process types listed on the portal job. -->
<t t-if="part">
<div class="o_fp_job_part">
<span class="o_fp_job_part_icon">📦</span>
<t t-if="part.part_number"><b t-out="part.part_number"/> · </t>
<t t-out="part.name or part.display_name"/>
</div>
</t>
<t t-elif="job.process_type_ids">
<div class="o_fp_job_part">
<span class="o_fp_job_part_icon">📦</span>
<t t-out="', '.join(job.process_type_ids.mapped('name'))"/>
</div>
</t>
<!-- Shipping address: customer may have multiple sites; the
SO carries which one this job ships to. -->
<t t-if="ship_to and ship_to.id != job.partner_id.commercial_partner_id.id">
<div class="o_fp_job_ship">
<span class="o_fp_job_ship_icon">📍</span>
Ship to: <t t-out="ship_to.name"/>
<t t-if="ship_to.city"> · <t t-out="ship_to.city"/></t>
</div>
</t>
<t t-call="fusion_plating_portal.fp_portal_stepper"/>
</a>
<!-- Actions footer: doc quick-downloads + Repeat Order. Lives
OUTSIDE the .o_fp_job_card_main anchor so the form button
doesn't double-fire navigation + form submission. -->
<div class="o_fp_job_card_actions">
<div class="o_fp_job_card_docs">
<t t-if="so">
<a t-attf-href="/my/jobs/#{job.id}/so_confirmation"
class="o_fp_doc_quick_btn" title="Sales Order Confirmation">
📄 SO
</a>
</t>
<t t-if="backend_job">
<a t-attf-href="/my/jobs/#{job.id}/wo_detail"
class="o_fp_doc_quick_btn" title="Work Order Detail">
🛠 WO
</a>
</t>
<t t-if="job.coc_attachment_id">
<a t-attf-href="/my/jobs/#{job.id}/coc"
class="o_fp_doc_quick_btn" title="Certificate of Conformance">
📑 CoC
</a>
</t>
<t t-else="">
<span class="o_fp_doc_quick_btn o_fp_doc_quick_btn_pending"
title="Will appear after QC completes">
📑 CoC
</span>
</t>
<t t-if="job.packing_list_attachment_id">
<a t-attf-href="/web/content/#{job.packing_list_attachment_id.id}?download=true"
class="o_fp_doc_quick_btn" title="Packing Slip">
📦 Packing
</a>
</t>
</div>
<form t-attf-action="/my/jobs/#{job.id}/repeat" method="post" class="m-0">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<button type="submit" class="o_fp_btn_secondary o_fp_btn_sm">
<i class="fa fa-repeat"/> Repeat Order
</button>
</form>
</div>
</div>
</template>
<!-- ================================================================== --> <!-- ================================================================== -->
<!-- Doc group (detail page) — pass label + docs list of dicts: --> <!-- Doc group (detail page) — pass label + docs list of dicts: -->
<!-- {label, sub, url, icon_class, pending} --> <!-- {label, sub, url, icon_class, pending} -->

View File

@@ -436,34 +436,9 @@
<t t-if="jobs"> <t t-if="jobs">
<div class="o_fp_dashboard"> <div class="o_fp_dashboard">
<t t-foreach="jobs" t-as="job"> <t t-foreach="jobs" t-as="job">
<a t-att-href="'/my/jobs/%s' % job.id" class="o_fp_job_card"> <t t-call="fusion_plating_portal.fp_portal_job_card">
<div class="o_fp_job_header"> <t t-set="job" t-value="job"/>
<div>
<span class="o_fp_job_ref" t-out="job.name"/>
<span class="o_fp_job_meta">
<t t-if="job.quantity"><t t-out="job.quantity"/> units</t>
<t t-if="job.target_ship_date"> · ETA <span t-field="job.target_ship_date" t-options='{"widget": "date"}'/></t>
</span>
</div>
<t t-call="fusion_plating_portal.fp_portal_status_badge">
<t t-set="state" t-value="job.state"/>
<t t-set="label" t-value="dict(job._fields['state']._description_selection(job.env)).get(job.state)"/>
</t> </t>
</div>
<!-- State -> active step index map (same as dashboard) -->
<t t-set="state_to_idx" t-value="{'received': 0, 'in_progress': 2, 'quality_check': 3, 'ready_to_ship': 4, 'shipped': 5, 'complete': 5}"/>
<t t-set="state_idx" t-value="state_to_idx.get(job.state, 0)"/>
<t t-set="steps" t-value="[
{'label': 'Received', 'status': 'done' if state_idx > 0 else 'active', 'time_label': ''},
{'label': 'Inspected', 'status': 'done' if state_idx > 1 else ('active' if state_idx == 1 else 'pending'), 'time_label': ''},
{'label': 'Plating', 'status': 'done' if state_idx > 2 else ('active' if state_idx == 2 else 'pending'), 'time_label': ''},
{'label': 'QC', 'status': 'done' if state_idx > 3 else ('active' if state_idx == 3 else 'pending'), 'time_label': ''},
{'label': 'Ship', 'status': 'done' if state_idx > 4 else ('active' if state_idx == 4 else 'pending'), 'time_label': ''},
]"/>
<t t-set="active_state" t-value="'warn' if job.state == 'quality_check' else 'normal'"/>
<t t-call="fusion_plating_portal.fp_portal_stepper"/>
</a>
</t> </t>
</div> </div>
</t> </t>
@@ -477,15 +452,28 @@
<t t-call="portal.portal_layout"> <t t-call="portal.portal_layout">
<div class="o_fp_job_detail"> <div class="o_fp_job_detail">
<!-- Hero header --> <!-- Hero header: WO ref + part + ship-to + key facts -->
<t t-set="backend_job" t-value="job.x_fc_job_id if 'x_fc_job_id' in job._fields else False"/>
<t t-set="so" t-value="backend_job.sale_order_id if backend_job and 'sale_order_id' in backend_job._fields else False"/>
<t t-set="part" t-value="backend_job.part_catalog_id if backend_job and 'part_catalog_id' in backend_job._fields else False"/>
<t t-set="ship_to" t-value="so.partner_shipping_id if so else False"/>
<div class="o_fp_job_detail_hero"> <div class="o_fp_job_detail_hero">
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap"> <div class="d-flex justify-content-between align-items-start gap-3 flex-wrap">
<div> <div>
<div class="o_fp_detail_label">Work Order</div> <div class="o_fp_detail_label">Work Order</div>
<h2><span t-out="job.name"/></h2> <h2><span t-out="job.name"/></h2>
<div t-if="job.process_type_ids" class="o_fp_detail_subtitle"> <t t-if="part">
<div class="o_fp_detail_subtitle">
<t t-if="part.part_number"><b t-out="part.part_number"/> · </t>
<t t-out="part.name or part.display_name"/>
</div>
</t>
<t t-elif="job.process_type_ids">
<div class="o_fp_detail_subtitle">
<span t-out="', '.join(job.process_type_ids.mapped('name'))"/> <span t-out="', '.join(job.process_type_ids.mapped('name'))"/>
</div> </div>
</t>
<div class="o_fp_detail_facts"> <div class="o_fp_detail_facts">
<div t-if="job.quantity"> <div t-if="job.quantity">
<span class="o_fp_fact_label">Qty </span> <span class="o_fp_fact_label">Qty </span>
@@ -503,6 +491,12 @@
<span class="o_fp_fact_label">Tracking </span> <span class="o_fp_fact_label">Tracking </span>
<span class="o_fp_fact_value" t-out="job.tracking_ref"/> <span class="o_fp_fact_value" t-out="job.tracking_ref"/>
</div> </div>
<div t-if="ship_to and ship_to.id != job.partner_id.commercial_partner_id.id">
<span class="o_fp_fact_label">Ship to </span>
<span class="o_fp_fact_value">
<t t-out="ship_to.name"/><t t-if="ship_to.city"> · <t t-out="ship_to.city"/></t>
</span>
</div>
</div> </div>
</div> </div>
<div class="d-flex flex-column align-items-end gap-2"> <div class="d-flex flex-column align-items-end gap-2">