3 Commits

Author SHA1 Message Date
gsinghpal
2af9d37f45 feat(portal): customer configurator wizard — upload, coating, estimate, submit
Three-step self-service quoting flow on the customer portal:
- Step 1: Upload part (STL/PDF) or enter manual measurements + material
- Step 2: Select coating config from card grid with specs and thickness
- Step 3: View estimated price range and submit quote request

Adds dependency on fusion_plating_configurator for fp.coating.config
and fp.pricing.rule models. Price estimation uses the same rule-matching
logic as the backend configurator with a +/-15-25% range.

Dashboard updated with prominent "Get a Quote" button and portal sidebar
entry. Breadcrumbs added for configurator pages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 21:00:59 -04:00
gsinghpal
3db30339b5 feat(configurator): Three.js 3D viewer for STL files
Add OWL field widget (fp_3d_preview) that renders uploaded STL files
in an interactive 3D viewport:
- Three.js r170 ESM loaded lazily via dynamic import with importmap
- STLLoader + OrbitControls for full model interaction
- Fallback binary STL parser when addon import fails
- Toolbar with wireframe toggle and camera reset
- Vertex/face count display
- Theme-aware SCSS using CSS custom properties and $border-color
- Registered on model_attachment_id in the Part Catalog form

Vendored libs: three.module.min.js (691KB), STLLoader.js, OrbitControls.js

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 20:54:30 -04:00
gsinghpal
795c66c126 feat(configurator): server-side surface area calculation from STL
Add trimesh-based surface area calculation for uploaded STL files:
- New /fp/configurator/calculate_surface_area jsonrpc endpoint
- action_calculate_surface_area() method on fp.part.catalog
- "Calculate from 3D Model" button visible when a 3D model is attached
- Returns area in sq in (converted from mm2), vertex/face counts,
  and bounding box dimensions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 20:53:54 -04:00
18 changed files with 3314 additions and 4 deletions

View File

@@ -3,4 +3,5 @@
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from . import controllers
from . import models

View File

@@ -46,6 +46,13 @@ Provides:
'views/sale_order_views.xml',
'views/fp_configurator_menu.xml',
],
'assets': {
'web.assets_backend': [
'fusion_plating_configurator/static/src/scss/fp_3d_viewer.scss',
'fusion_plating_configurator/static/src/xml/fp_3d_viewer.xml',
'fusion_plating_configurator/static/src/js/fp_3d_viewer.js',
],
},
'installable': True,
'application': False,
'auto_install': False,

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import configurator_controller

View File

@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
import base64
import io
import logging
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)
class FpConfiguratorController(http.Controller):
@http.route('/fp/configurator/calculate_surface_area', type='jsonrpc', auth='user')
def calculate_surface_area(self, attachment_id, **kw):
"""Calculate surface area from an uploaded STL file using trimesh."""
attachment = request.env['ir.attachment'].browse(int(attachment_id))
if not attachment.exists():
return {'error': 'Attachment not found.'}
try:
import trimesh
except ImportError:
return {'error': 'trimesh library not installed. Run: pip install trimesh'}
try:
raw = base64.b64decode(attachment.datas)
mesh = trimesh.load(io.BytesIO(raw), file_type='stl')
# trimesh returns area in the file's native units (usually mm²)
area_mm2 = mesh.area
area_sqin = area_mm2 / 645.16 # mm² to sq in
return {
'surface_area': round(area_sqin, 4),
'surface_area_mm2': round(area_mm2, 2),
'unit': 'sq_in',
'vertex_count': len(mesh.vertices),
'face_count': len(mesh.faces),
'bounding_box': {
'x': round(float(mesh.bounding_box.extents[0]), 2),
'y': round(float(mesh.bounding_box.extents[1]), 2),
'z': round(float(mesh.bounding_box.extents[2]), 2),
},
}
except Exception as e:
_logger.warning('STL surface area calculation failed: %s', e)
return {'error': str(e)}

View File

@@ -3,7 +3,7 @@
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from odoo import fields, models
from odoo import api, fields, models, _
class FpPartCatalog(models.Model):
@@ -63,3 +63,39 @@ class FpPartCatalog(models.Model):
('fp_part_catalog_partner_partnum_uniq', 'unique(partner_id, part_number)',
'Part number must be unique per customer.'),
]
def action_calculate_surface_area(self):
"""Calculate surface area from the uploaded 3D model file."""
self.ensure_one()
if not self.model_attachment_id:
from odoo.exceptions import UserError
raise UserError(_('No 3D model file uploaded.'))
try:
import trimesh
except ImportError:
from odoo.exceptions import UserError
raise UserError(_('trimesh library not installed on the server. Contact your administrator.'))
import base64
import io
raw = base64.b64decode(self.model_attachment_id.datas)
mesh = trimesh.load(io.BytesIO(raw), file_type='stl')
area_mm2 = mesh.area
area_sqin = area_mm2 / 645.16
self.surface_area = round(area_sqin, 4)
self.surface_area_uom = 'sq_in'
self.geometry_source = '3d_model'
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Surface Area Calculated'),
'message': _('%.4f sq in (%.2f mm\u00b2) from %d faces') % (area_sqin, area_mm2, len(mesh.faces)),
'type': 'success',
'sticky': False,
},
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,411 @@
import {
BufferAttribute,
BufferGeometry,
Color,
FileLoader,
Float32BufferAttribute,
Loader,
Vector3,
SRGBColorSpace
} from 'three';
/**
* Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
*
* Supports both binary and ASCII encoded files, with automatic detection of type.
*
* The loader returns a non-indexed buffer geometry.
*
* Limitations:
* Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
* There is perhaps some question as to how valid it is to always assume little-endian-ness.
* ASCII decoding assumes file is UTF-8.
*
* Usage:
* const loader = new STLLoader();
* loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
* scene.add( new THREE.Mesh( geometry ) );
* });
*
* For binary STLs geometry might contain colors for vertices. To use it:
* // use the same code to load STL as above
* if (geometry.hasColors) {
* material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true });
* } else { .... }
* const mesh = new THREE.Mesh( geometry, material );
*
* For ASCII STLs containing multiple solids, each solid is assigned to a different group.
* Groups can be used to assign a different color by defining an array of materials with the same length of
* geometry.groups and passing it to the Mesh constructor:
*
* const mesh = new THREE.Mesh( geometry, material );
*
* For example:
*
* const materials = [];
* const nGeometryGroups = geometry.groups.length;
*
* const colorMap = ...; // Some logic to index colors.
*
* for (let i = 0; i < nGeometryGroups; i++) {
*
* const material = new THREE.MeshPhongMaterial({
* color: colorMap[i],
* wireframe: false
* });
*
* }
*
* materials.push(material);
* const mesh = new THREE.Mesh(geometry, materials);
*/
class STLLoader extends Loader {
constructor( manager ) {
super( manager );
}
load( url, onLoad, onProgress, onError ) {
const scope = this;
const loader = new FileLoader( this.manager );
loader.setPath( this.path );
loader.setResponseType( 'arraybuffer' );
loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials );
loader.load( url, function ( text ) {
try {
onLoad( scope.parse( text ) );
} catch ( e ) {
if ( onError ) {
onError( e );
} else {
console.error( e );
}
scope.manager.itemError( url );
}
}, onProgress, onError );
}
parse( data ) {
function isBinary( data ) {
const reader = new DataView( data );
const face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
const n_faces = reader.getUint32( 80, true );
const expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
if ( expect === reader.byteLength ) {
return true;
}
// An ASCII STL data must begin with 'solid ' as the first six bytes.
// However, ASCII STLs lacking the SPACE after the 'd' are known to be
// plentiful. So, check the first 5 bytes for 'solid'.
// Several encodings, such as UTF-8, precede the text with up to 5 bytes:
// https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
// Search for "solid" to start anywhere after those prefixes.
// US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
const solid = [ 115, 111, 108, 105, 100 ];
for ( let off = 0; off < 5; off ++ ) {
// If "solid" text is matched to the current offset, declare it to be an ASCII STL.
if ( matchDataViewAt( solid, reader, off ) ) return false;
}
// Couldn't find "solid" text at the beginning; it is binary STL.
return true;
}
function matchDataViewAt( query, reader, offset ) {
// Check if each byte in query matches the corresponding byte from the current offset
for ( let i = 0, il = query.length; i < il; i ++ ) {
if ( query[ i ] !== reader.getUint8( offset + i ) ) return false;
}
return true;
}
function parseBinary( data ) {
const reader = new DataView( data );
const faces = reader.getUint32( 80, true );
let r, g, b, hasColors = false, colors;
let defaultR, defaultG, defaultB, alpha;
// process STL header
// check for default color in header ("COLOR=rgba" sequence).
for ( let index = 0; index < 80 - 10; index ++ ) {
if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) &&
( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) &&
( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
hasColors = true;
colors = new Float32Array( faces * 3 * 3 );
defaultR = reader.getUint8( index + 6 ) / 255;
defaultG = reader.getUint8( index + 7 ) / 255;
defaultB = reader.getUint8( index + 8 ) / 255;
alpha = reader.getUint8( index + 9 ) / 255;
}
}
const dataOffset = 84;
const faceLength = 12 * 4 + 2;
const geometry = new BufferGeometry();
const vertices = new Float32Array( faces * 3 * 3 );
const normals = new Float32Array( faces * 3 * 3 );
const color = new Color();
for ( let face = 0; face < faces; face ++ ) {
const start = dataOffset + face * faceLength;
const normalX = reader.getFloat32( start, true );
const normalY = reader.getFloat32( start + 4, true );
const normalZ = reader.getFloat32( start + 8, true );
if ( hasColors ) {
const packedColor = reader.getUint16( start + 48, true );
if ( ( packedColor & 0x8000 ) === 0 ) {
// facet has its own unique color
r = ( packedColor & 0x1F ) / 31;
g = ( ( packedColor >> 5 ) & 0x1F ) / 31;
b = ( ( packedColor >> 10 ) & 0x1F ) / 31;
} else {
r = defaultR;
g = defaultG;
b = defaultB;
}
}
for ( let i = 1; i <= 3; i ++ ) {
const vertexstart = start + i * 12;
const componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 );
vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
normals[ componentIdx ] = normalX;
normals[ componentIdx + 1 ] = normalY;
normals[ componentIdx + 2 ] = normalZ;
if ( hasColors ) {
color.setRGB( r, g, b, SRGBColorSpace );
colors[ componentIdx ] = color.r;
colors[ componentIdx + 1 ] = color.g;
colors[ componentIdx + 2 ] = color.b;
}
}
}
geometry.setAttribute( 'position', new BufferAttribute( vertices, 3 ) );
geometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ) );
if ( hasColors ) {
geometry.setAttribute( 'color', new BufferAttribute( colors, 3 ) );
geometry.hasColors = true;
geometry.alpha = alpha;
}
return geometry;
}
function parseASCII( data ) {
const geometry = new BufferGeometry();
const patternSolid = /solid([\s\S]*?)endsolid/g;
const patternFace = /facet([\s\S]*?)endfacet/g;
const patternName = /solid\s(.+)/;
let faceCounter = 0;
const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
const patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
const patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
const vertices = [];
const normals = [];
const groupNames = [];
const normal = new Vector3();
let result;
let groupCount = 0;
let startVertex = 0;
let endVertex = 0;
while ( ( result = patternSolid.exec( data ) ) !== null ) {
startVertex = endVertex;
const solid = result[ 0 ];
const name = ( result = patternName.exec( solid ) ) !== null ? result[ 1 ] : '';
groupNames.push( name );
while ( ( result = patternFace.exec( solid ) ) !== null ) {
let vertexCountPerFace = 0;
let normalCountPerFace = 0;
const text = result[ 0 ];
while ( ( result = patternNormal.exec( text ) ) !== null ) {
normal.x = parseFloat( result[ 1 ] );
normal.y = parseFloat( result[ 2 ] );
normal.z = parseFloat( result[ 3 ] );
normalCountPerFace ++;
}
while ( ( result = patternVertex.exec( text ) ) !== null ) {
vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
normals.push( normal.x, normal.y, normal.z );
vertexCountPerFace ++;
endVertex ++;
}
// every face have to own ONE valid normal
if ( normalCountPerFace !== 1 ) {
console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter );
}
// each face have to own THREE valid vertices
if ( vertexCountPerFace !== 3 ) {
console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter );
}
faceCounter ++;
}
const start = startVertex;
const count = endVertex - startVertex;
geometry.userData.groupNames = groupNames;
geometry.addGroup( start, count, groupCount );
groupCount ++;
}
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
geometry.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
return geometry;
}
function ensureString( buffer ) {
if ( typeof buffer !== 'string' ) {
return new TextDecoder().decode( buffer );
}
return buffer;
}
function ensureBinary( buffer ) {
if ( typeof buffer === 'string' ) {
const array_buffer = new Uint8Array( buffer.length );
for ( let i = 0; i < buffer.length; i ++ ) {
array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
}
return array_buffer.buffer || array_buffer;
} else {
return buffer;
}
}
// start
const binData = ensureBinary( data );
return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
}
}
export { STLLoader };

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,291 @@
/** @odoo-module **/
// =============================================================================
// Fusion Plating -- 3D STL Viewer (OWL field widget)
// Copyright 2026 Nexa Systems Inc.
// License OPL-1 (Odoo Proprietary License v1.0)
//
// Renders STL files using Three.js inside an OWL field widget.
// Three.js (+ STLLoader + OrbitControls) are loaded lazily on first use
// via dynamic import() with a programmatic importmap so the vendored ESM
// addon files can resolve their bare `from 'three'` specifier.
//
// Registered as field widget `fp_3d_preview` for Many2one fields
// (ir.attachment).
// =============================================================================
import { Component, useRef, onMounted, onWillUnmount, useState } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
// ---------------------------------------------------------------------------
// Three.js lazy loader
// ---------------------------------------------------------------------------
let _threePromise = null;
/**
* Inject an importmap so `from 'three'` inside STLLoader / OrbitControls
* resolves to our vendored three.module.min.js. Then dynamically import
* all three files and return the combined namespace.
*/
async function loadThreeJs() {
if (_threePromise) return _threePromise;
_threePromise = (async () => {
// Inject importmap (idempotent -- only once)
if (!document.querySelector('script[type="importmap"][data-fp-three]')) {
const map = document.createElement("script");
map.type = "importmap";
map.setAttribute("data-fp-three", "1");
map.textContent = JSON.stringify({
imports: {
three: "/fusion_plating_configurator/static/lib/three.module.min.js",
},
});
document.head.appendChild(map);
}
// Dynamic imports -- browser resolves `from 'three'` via the importmap
const THREE = await import("/fusion_plating_configurator/static/lib/three.module.min.js");
const { STLLoader } = await import("/fusion_plating_configurator/static/lib/STLLoader.js");
const { OrbitControls } = await import("/fusion_plating_configurator/static/lib/OrbitControls.js");
// Attach for convenience
THREE.STLLoader = STLLoader;
THREE.OrbitControls = OrbitControls;
return THREE;
})();
return _threePromise;
}
// ---------------------------------------------------------------------------
// OWL Component
// ---------------------------------------------------------------------------
export class Fp3dViewer extends Component {
static template = "fusion_plating_configurator.Fp3dViewer";
static props = {
...standardFieldProps,
};
setup() {
this.canvasRef = useRef("canvas3d");
this.state = useState({
loading: false,
error: null,
wireframe: false,
vertexCount: 0,
faceCount: 0,
hasAttachment: false,
});
this.scene = null;
this.camera = null;
this.renderer = null;
this.controls = null;
this.mesh = null;
this.animationId = null;
onMounted(() => this._onMounted());
onWillUnmount(() => this._cleanup());
}
/** Return the raw value of the Many2one field (could be [id, name] or false). */
get rawValue() {
return this.props.record.data[this.props.name];
}
/** Return the attachment id (integer) or 0. */
get attachmentId() {
const v = this.rawValue;
if (!v) return 0;
if (Array.isArray(v)) return v[0] || 0;
if (typeof v === "object" && v.id) return v.id;
return typeof v === "number" ? v : 0;
}
async _onMounted() {
const aid = this.attachmentId;
this.state.hasAttachment = !!aid;
if (!aid || !this.canvasRef.el) return;
await this._initViewer();
}
async _initViewer() {
this.state.loading = true;
this.state.error = null;
let THREE;
try {
THREE = await loadThreeJs();
} catch (e) {
// importmap injection may fail if the page already has one -- fall
// back to loading Three.js core alone and skip addons.
this.state.error = "Three.js failed to load: " + (e.message || e);
this.state.loading = false;
return;
}
const container = this.canvasRef.el;
const width = container.clientWidth || 500;
const height = 350;
// ---- Scene ----
this.scene = new THREE.Scene();
// Respect Odoo theme -- use a neutral slightly-warm grey
this.scene.background = new THREE.Color(0xf5f5f5);
// ---- Camera ----
this.camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 10000);
this.camera.position.set(0, 0, 100);
// ---- Renderer ----
this.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
this.renderer.setPixelRatio(window.devicePixelRatio || 1);
this.renderer.setSize(width, height);
container.appendChild(this.renderer.domElement);
// ---- Lights ----
const ambient = new THREE.AmbientLight(0x808080, 1.5);
this.scene.add(ambient);
const dir1 = new THREE.DirectionalLight(0xffffff, 1.0);
dir1.position.set(1, 1, 1);
this.scene.add(dir1);
const dir2 = new THREE.DirectionalLight(0xffffff, 0.4);
dir2.position.set(-1, -0.5, -1);
this.scene.add(dir2);
// ---- Orbit controls ----
if (THREE.OrbitControls) {
this.controls = new THREE.OrbitControls(this.camera, this.renderer.domElement);
this.controls.enableDamping = true;
this.controls.dampingFactor = 0.12;
}
// ---- Load STL ----
try {
const url = `/web/content/${this.attachmentId}`;
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const buffer = await response.arrayBuffer();
let geometry;
if (THREE.STLLoader) {
const loader = new THREE.STLLoader();
geometry = loader.parse(buffer);
} else {
// Fallback: parse binary STL manually
geometry = this._parseSTLBinary(THREE, buffer);
}
geometry.computeVertexNormals();
const material = new THREE.MeshPhongMaterial({
color: 0x1a8cff,
specular: 0x333333,
shininess: 120,
wireframe: false,
});
this.mesh = new THREE.Mesh(geometry, material);
// Centre and auto-scale to fit viewport
geometry.computeBoundingBox();
const box = geometry.boundingBox;
const center = box.getCenter(new THREE.Vector3());
const size = box.getSize(new THREE.Vector3());
const maxDim = Math.max(size.x, size.y, size.z);
const scale = 60 / (maxDim || 1);
this.mesh.geometry.translate(-center.x, -center.y, -center.z);
this.mesh.scale.set(scale, scale, scale);
this.scene.add(this.mesh);
this.state.vertexCount = geometry.attributes.position.count;
this.state.faceCount = Math.floor(geometry.attributes.position.count / 3);
this.state.loading = false;
this._animate();
} catch (e) {
this.state.error = "Failed to load STL: " + (e.message || e);
this.state.loading = false;
}
}
/**
* Minimal binary STL parser (fallback when STLLoader is unavailable).
* Binary STL: 80-byte header, 4-byte uint32 triangle count, then
* 50 bytes per triangle (12 floats for normal + 3 vertices, 2-byte attr).
*/
_parseSTLBinary(THREE, buffer) {
const dv = new DataView(buffer);
const triangles = dv.getUint32(80, true);
const positions = new Float32Array(triangles * 9);
const normals = new Float32Array(triangles * 9);
let offset = 84;
for (let i = 0; i < triangles; i++) {
const nx = dv.getFloat32(offset, true);
const ny = dv.getFloat32(offset + 4, true);
const nz = dv.getFloat32(offset + 8, true);
offset += 12;
for (let v = 0; v < 3; v++) {
const idx = i * 9 + v * 3;
positions[idx] = dv.getFloat32(offset, true);
positions[idx + 1] = dv.getFloat32(offset + 4, true);
positions[idx + 2] = dv.getFloat32(offset + 8, true);
normals[idx] = nx;
normals[idx + 1] = ny;
normals[idx + 2] = nz;
offset += 12;
}
offset += 2; // attribute byte count
}
const geo = new THREE.BufferGeometry();
geo.setAttribute("position", new THREE.BufferAttribute(positions, 3));
geo.setAttribute("normal", new THREE.BufferAttribute(normals, 3));
return geo;
}
_animate() {
this.animationId = requestAnimationFrame(() => this._animate());
if (this.controls) this.controls.update();
if (this.renderer && this.scene && this.camera) {
this.renderer.render(this.scene, this.camera);
}
}
toggleWireframe() {
if (!this.mesh) return;
this.state.wireframe = !this.state.wireframe;
this.mesh.material.wireframe = this.state.wireframe;
}
resetView() {
if (!this.camera) return;
this.camera.position.set(0, 0, 100);
this.camera.lookAt(0, 0, 0);
if (this.controls) this.controls.reset();
}
_cleanup() {
if (this.animationId) {
cancelAnimationFrame(this.animationId);
this.animationId = null;
}
if (this.controls) {
this.controls.dispose();
this.controls = null;
}
if (this.renderer) {
this.renderer.dispose();
if (this.renderer.domElement && this.renderer.domElement.parentNode) {
this.renderer.domElement.parentNode.removeChild(this.renderer.domElement);
}
this.renderer = null;
}
this.scene = null;
this.camera = null;
this.mesh = null;
}
}
// Register as a field widget for Many2one (ir.attachment) fields
registry.category("fields").add("fp_3d_preview", {
component: Fp3dViewer,
supportedTypes: ["many2one"],
});

View File

@@ -0,0 +1,62 @@
// =============================================================================
// Fusion Plating -- 3D Viewer Widget Styles
// Copyright 2026 Nexa Systems Inc.
// License OPL-1 (Odoo Proprietary License v1.0)
// =============================================================================
.o_fp_3d_viewer_root {
width: 100%;
}
.o_fp_3d_placeholder {
border: 2px dashed $border-color;
border-radius: 0.375rem;
min-height: 120px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: var(--bs-secondary-color);
}
.o_fp_3d_toolbar {
.btn {
font-size: 0.8125rem;
padding: 0.2rem 0.5rem;
}
}
.o_fp_3d_canvas_container {
width: 100%;
height: 350px;
border: 1px solid $border-color;
border-radius: 0.375rem;
overflow: hidden;
position: relative;
background-color: var(--bs-body-bg);
canvas {
display: block;
width: 100% !important;
height: 100% !important;
}
}
.o_fp_3d_loading {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
z-index: 10;
}
.o_fp_3d_error {
font-size: 0.875rem;
}

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2026 Nexa Systems Inc.
License OPL-1 (Odoo Proprietary License v1.0)
Part of the Fusion Plating product family.
-->
<templates xml:space="preserve">
<t t-name="fusion_plating_configurator.Fp3dViewer">
<div class="o_fp_3d_viewer_root">
<!-- No attachment uploaded yet -->
<t t-if="!state.hasAttachment">
<div class="o_fp_3d_placeholder text-center text-muted p-4">
<i class="fa fa-cube fa-3x mb-2 d-block"/>
<span>Upload a 3D model (STL) to preview it here.</span>
</div>
</t>
<!-- Viewer -->
<t t-if="state.hasAttachment">
<!-- Toolbar -->
<div class="o_fp_3d_toolbar d-flex align-items-center gap-2 mb-1">
<button class="btn btn-sm btn-outline-secondary" t-on-click="toggleWireframe"
title="Toggle wireframe">
<i class="fa fa-th"/> <t t-if="state.wireframe">Solid</t><t t-else="">Wireframe</t>
</button>
<button class="btn btn-sm btn-outline-secondary" t-on-click="resetView"
title="Reset camera">
<i class="fa fa-crosshairs"/> Reset
</button>
<span class="ms-auto small text-muted" t-if="state.vertexCount">
<i class="fa fa-cubes"/>
<t t-esc="state.faceCount"/> faces
/
<t t-esc="state.vertexCount"/> verts
</span>
</div>
<!-- Canvas container -->
<div t-ref="canvas3d" class="o_fp_3d_canvas_container">
<!-- Three.js renderer appends here -->
</div>
<!-- Loading spinner -->
<div t-if="state.loading" class="o_fp_3d_loading text-center p-4">
<i class="fa fa-spinner fa-spin fa-2x"/>
<div class="mt-2">Loading 3D model...</div>
</div>
<!-- Error -->
<div t-if="state.error" class="o_fp_3d_error alert alert-warning mt-2 mb-0">
<i class="fa fa-exclamation-triangle"/>
<t t-esc="state.error"/>
</div>
</t>
</div>
</t>
</templates>

View File

@@ -44,7 +44,14 @@
<field name="geometry_source"/>
</group>
<group>
<field name="surface_area"/>
<label for="surface_area"/>
<div class="d-flex align-items-center gap-2">
<field name="surface_area" class="oe_inline"/>
<button name="action_calculate_surface_area" type="object"
string="Calculate from 3D Model"
class="btn-link" icon="fa-calculator"
invisible="not model_attachment_id"/>
</div>
<field name="surface_area_uom"/>
<field name="weight"/>
</group>
@@ -71,7 +78,7 @@
</page>
<page string="Attachments" name="attachments">
<group>
<field name="model_attachment_id"/>
<field name="model_attachment_id" widget="fp_3d_preview"/>
<field name="drawing_attachment_ids" widget="many2many_binary"/>
</group>
</page>

View File

@@ -43,6 +43,7 @@ Copyright (c) 2026 Nexa Systems Inc. All rights reserved.
'currency': 'CAD',
'depends': [
'fusion_plating',
'fusion_plating_configurator',
'portal',
'website',
'mail',
@@ -57,6 +58,7 @@ Copyright (c) 2026 Nexa Systems Inc. All rights reserved.
'views/fp_quote_request_views.xml',
'views/fp_portal_dashboard.xml',
'views/fp_portal_templates.xml',
'views/fp_portal_configurator_templates.xml',
'views/fp_portal_breadcrumbs.xml',
'views/fp_menu.xml',
],

View File

@@ -4,3 +4,4 @@
# Part of the Fusion Plating product family.
from . import portal
from . import portal_configurator

View File

@@ -0,0 +1,311 @@
# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
import base64
import logging
from odoo import _, http
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal
_logger = logging.getLogger(__name__)
class FpPortalConfigurator(CustomerPortal):
"""Self-service configurator wizard on the customer portal.
Three-step flow:
1. Upload part (3D / PDF) or enter manual measurements
2. Select a coating configuration
3. View estimated price range and submit quote request
"""
# ======================================================================
# Landing — start new or view past requests
# ======================================================================
@http.route('/my/configurator', type='http', auth='user', website=True)
def portal_configurator_landing(self, **kw):
"""Landing page -- start new quote or view past requests."""
partner = request.env.user.partner_id
quotes = request.env['fusion.plating.quote.request'].sudo().search(
[('partner_id', 'child_of', partner.commercial_partner_id.id)],
order='create_date desc', limit=10,
)
return request.render('fusion_plating_portal.portal_configurator_landing', {
'page_name': 'fp_configurator',
'quotes': quotes,
})
# ======================================================================
# Step 1 — Upload part or enter manual measurements
# ======================================================================
@http.route(
'/my/configurator/new', type='http', auth='user', website=True,
methods=['GET', 'POST'], csrf=True,
)
def portal_configurator_step1(self, **kw):
"""Step 1: upload part or enter manual measurements."""
if request.httprequest.method == 'POST':
# Save step 1 data to session
session_data = {
'part_name': kw.get('part_name', ''),
'part_number': kw.get('part_number', ''),
'substrate_material': kw.get('substrate_material', 'steel'),
'geometry_source': kw.get('geometry_source', 'manual'),
'surface_area': float(kw.get('surface_area', 0) or 0),
'dimensions_length': float(kw.get('dimensions_length', 0) or 0),
'dimensions_width': float(kw.get('dimensions_width', 0) or 0),
'dimensions_height': float(kw.get('dimensions_height', 0) or 0),
}
# Handle file upload
file_upload = kw.get('part_file')
if file_upload and hasattr(file_upload, 'read'):
file_data = file_upload.read()
if file_data:
attachment = request.env['ir.attachment'].sudo().create({
'name': file_upload.filename,
'datas': base64.b64encode(file_data),
'res_model': 'fusion.plating.quote.request',
'type': 'binary',
})
session_data['attachment_id'] = attachment.id
session_data['attachment_name'] = file_upload.filename
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'):
try:
import io
import trimesh
mesh = trimesh.load(io.BytesIO(file_data), file_type='stl')
# Convert mm^2 to sq in (1 sq in = 645.16 mm^2)
session_data['surface_area'] = round(mesh.area / 645.16, 4)
session_data['auto_calculated'] = True
except Exception:
_logger.info('Could not auto-calculate STL surface area (trimesh not available).')
request.session['fp_configurator'] = session_data
return request.redirect('/my/configurator/coating')
# GET -- show form
materials = [
('aluminium', 'Aluminium'),
('steel', 'Steel'),
('stainless', 'Stainless Steel'),
('copper', 'Copper'),
('titanium', 'Titanium'),
('other', 'Other'),
]
return request.render('fusion_plating_portal.portal_configurator_step1', {
'page_name': 'fp_configurator',
'materials': materials,
})
# ======================================================================
# Step 2 — Select coating configuration
# ======================================================================
@http.route(
'/my/configurator/coating', type='http', auth='user', website=True,
methods=['GET', 'POST'], csrf=True,
)
def portal_configurator_step2(self, **kw):
"""Step 2: select coating configuration."""
session_data = request.session.get('fp_configurator', {})
if not session_data:
return request.redirect('/my/configurator/new')
if request.httprequest.method == 'POST':
coating_id = int(kw.get('coating_config_id', 0))
quantity = int(kw.get('quantity', 1) or 1)
session_data['coating_config_id'] = coating_id
session_data['quantity'] = quantity
request.session['fp_configurator'] = session_data
return request.redirect('/my/configurator/estimate')
coatings = request.env['fp.coating.config'].sudo().search(
[('active', '=', True)], order='sequence',
)
return request.render('fusion_plating_portal.portal_configurator_step2', {
'page_name': 'fp_configurator',
'coatings': coatings,
'session_data': session_data,
})
# ======================================================================
# Step 3 — Estimate & submit
# ======================================================================
@http.route('/my/configurator/estimate', type='http', auth='user', website=True)
def portal_configurator_step3(self, **kw):
"""Step 3: show estimated price and submit."""
session_data = request.session.get('fp_configurator', {})
if not session_data or not session_data.get('coating_config_id'):
return request.redirect('/my/configurator/new')
coating = request.env['fp.coating.config'].sudo().browse(
session_data['coating_config_id'],
)
if not coating.exists():
return request.redirect('/my/configurator/coating')
# Calculate estimated price from pricing rules
estimated_price = self._estimate_price(session_data, coating)
return request.render('fusion_plating_portal.portal_configurator_step3', {
'page_name': 'fp_configurator',
'session_data': session_data,
'coating': coating,
'estimated_price': estimated_price,
})
# ======================================================================
# Submit — create quote request
# ======================================================================
@http.route(
'/my/configurator/submit', type='http', auth='user', website=True,
methods=['POST'], csrf=True,
)
def portal_configurator_submit(self, **kw):
"""Submit quote request from configurator."""
session_data = request.session.get('fp_configurator', {})
if not session_data or not session_data.get('coating_config_id'):
return request.redirect('/my/configurator/new')
partner = request.env.user.partner_id
coating = request.env['fp.coating.config'].sudo().browse(
session_data['coating_config_id'],
)
# Build part description HTML
part_desc = '<p><strong>%s</strong></p>' % (
session_data.get('part_name', '') or 'Unnamed Part',
)
if session_data.get('part_number'):
part_desc += '<p>Part Number: %s</p>' % session_data['part_number']
part_desc += '<p>Material: %s</p>' % session_data.get('substrate_material', '')
if session_data.get('surface_area'):
part_desc += '<p>Surface Area: %s sq in</p>' % session_data['surface_area']
dims = []
for dim_key, dim_label in [
('dimensions_length', 'L'), ('dimensions_width', 'W'), ('dimensions_height', 'H'),
]:
val = session_data.get(dim_key, 0)
if val:
dims.append('%s: %s in' % (dim_label, val))
if dims:
part_desc += '<p>Dimensions: %s</p>' % ', '.join(dims)
if coating.exists():
part_desc += '<p>Coating: %s</p>' % coating.name
vals = {
'partner_id': partner.id,
'contact_name': partner.name,
'contact_email': partner.email,
'contact_phone': partner.phone or '',
'company_name': partner.parent_id.name if partner.parent_id else partner.name,
'part_description': part_desc,
'quantity': session_data.get('quantity', 1),
'special_instructions': kw.get('special_instructions', ''),
}
# Link coating process type
if coating.exists() and coating.process_type_id:
vals['process_type_ids'] = [(4, coating.process_type_id.id)]
quote = request.env['fusion.plating.quote.request'].sudo().create(vals)
# Attach uploaded file to the quote request
attachment_id = session_data.get('attachment_id')
if attachment_id:
attachment = request.env['ir.attachment'].sudo().browse(attachment_id)
if attachment.exists():
attachment.write({
'res_model': 'fusion.plating.quote.request',
'res_id': quote.id,
})
quote.drawing_attachment_ids = [(4, attachment.id)]
# Clear session
request.session.pop('fp_configurator', None)
return request.render('fusion_plating_portal.portal_configurator_success', {
'page_name': 'fp_configurator',
'quote': quote,
})
# ======================================================================
# Pricing helper
# ======================================================================
def _estimate_price(self, session_data, coating):
"""Calculate estimated price range from pricing rules.
Returns a dict with ``min``, ``max``, and ``available`` keys.
The range is deliberately wide (+/- 15-25%) because final quotes
account for masking complexity, rack configuration, etc.
"""
rules = request.env['fp.pricing.rule'].sudo().search(
[('active', '=', True)], order='sequence',
)
area = float(session_data.get('surface_area', 0))
qty = int(session_data.get('quantity', 1))
substrate = session_data.get('substrate_material', '')
cert_level = coating.certification_level if coating else 'commercial'
if not area or not rules:
return {'min': 0, 'max': 0, 'available': False}
# Find best matching rule (same scoring as fp.quote.configurator)
best = None
best_score = -1
for rule in rules:
score = 0
if rule.coating_config_id:
if rule.coating_config_id.id != coating.id:
continue
score += 4
if rule.substrate_material:
if rule.substrate_material != substrate:
continue
score += 2
if rule.certification_level:
if rule.certification_level != cert_level:
continue
score += 1
if score > best_score:
best_score = score
best = rule
if not best:
return {'min': 0, 'max': 0, 'available': False}
# Calculate base price
if best.pricing_method == 'per_sqin':
unit = area * best.base_rate
elif best.pricing_method == 'per_sqft':
unit = (area / 144.0) * best.base_rate
elif best.pricing_method == 'per_piece':
unit = best.base_rate
else:
unit = best.base_rate
# Apply thickness factor (use min thickness from coating)
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:
base_total = best.minimum_charge
# Return a range (85% to 125%) to account for complexity, masking, etc.
return {
'min': round(base_total * 0.85, 2),
'max': round(base_total * 1.25, 2),
'available': True,
}

View File

@@ -22,6 +22,13 @@
Dashboard
</li>
<!-- Configurator -->
<li t-if="page_name == 'fp_configurator'"
class="breadcrumb-item active"
aria-current="page">
Get a Quote
</li>
<!-- Quote Requests list -->
<li t-if="page_name == 'fp_quote_requests'"
class="breadcrumb-item active"

View File

@@ -0,0 +1,524 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2026 Nexa Systems Inc.
License OPL-1 (Odoo Proprietary License v1.0)
Part of the Fusion Plating product family.
Portal Configurator Templates -- 3-step self-service quoting wizard.
-->
<odoo>
<!-- ================================================================== -->
<!-- REUSABLE: Progress Bar (Step 1 / 2 / 3) -->
<!-- ================================================================== -->
<template id="portal_configurator_progress" name="Configurator Progress Bar">
<div class="d-flex align-items-center justify-content-center mb-4">
<t t-foreach="[('1', 'Upload Part'), ('2', 'Select Coating'), ('3', 'Review &amp; Submit')]" t-as="step_item">
<t t-set="step_num" t-value="step_item[0]"/>
<t t-set="step_label" t-value="step_item[1]"/>
<div class="d-flex align-items-center">
<div t-attf-class="rounded-circle d-flex align-items-center justify-content-center fw-bold
#{'bg-primary text-white' if current_step == step_num else
'bg-success text-white' if int(current_step) > int(step_num) else
'bg-body-tertiary text-muted'}"
style="width: 32px; height: 32px; font-size: 0.85rem;">
<t t-if="int(current_step) > int(step_num)">
<i class="fa fa-check"/>
</t>
<t t-else="">
<t t-out="step_num"/>
</t>
</div>
<span t-attf-class="ms-2 small fw-semibold
#{'text-primary' if current_step == step_num else
'text-success' if int(current_step) > int(step_num) else
'text-muted'}"
t-out="step_label"/>
</div>
<t t-if="step_num != '3'">
<div class="mx-3" style="width: 40px; height: 2px; background: var(--bs-border-color);"/>
</t>
</t>
</div>
</template>
<!-- ================================================================== -->
<!-- LANDING PAGE -->
<!-- ================================================================== -->
<template id="portal_configurator_landing" name="Configurator Landing">
<t t-call="portal.portal_layout">
<div class="o_fp_portal_form mt-3">
<!-- Hero card -->
<div class="card mb-4" style="border: 2px solid var(--bs-primary); border-radius: 12px;">
<div class="card-body text-center py-5">
<i class="fa fa-cog fa-3x mb-3" style="color: var(--bs-primary);"/>
<h3 class="mb-2">Get a Quote</h3>
<p class="text-muted mb-4" style="max-width: 500px; margin: 0 auto;">
Use our configurator to upload your part, select a coating, and
receive an estimated price range in minutes.
</p>
<a href="/my/configurator/new" class="btn btn-primary btn-lg px-5">
<i class="fa fa-play me-2"/>Start Configurator
</a>
</div>
</div>
<!-- Recent quote requests -->
<t t-if="quotes">
<h5 class="mb-3">Recent Quote Requests</h5>
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>Reference</th>
<th>Submitted</th>
<th>Quantity</th>
<th class="text-end">Status</th>
</tr>
</thead>
<tbody>
<tr t-foreach="quotes" t-as="qr">
<td>
<a t-att-href="'/my/quote_requests/%s' % qr.id"
t-out="qr.name"/>
</td>
<td>
<span t-field="qr.create_date" t-options='{"widget": "date"}'/>
</td>
<td t-out="qr.quantity"/>
<td class="text-end">
<span t-attf-class="badge #{
'text-bg-secondary' if qr.state == 'new' else
'text-bg-info' if qr.state == 'under_review' else
'text-bg-primary' if qr.state == 'quoted' else
'text-bg-success' if qr.state == 'accepted' else
'text-bg-danger' if qr.state == 'declined' else
'text-bg-warning'}"
t-out="dict(qr._fields['state']._description_selection(qr.env)).get(qr.state)"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</div>
</t>
</template>
<!-- ================================================================== -->
<!-- STEP 1 — Upload Part / Manual Measurements -->
<!-- ================================================================== -->
<template id="portal_configurator_step1" name="Configurator Step 1 — Upload Part">
<t t-call="portal.portal_layout">
<div class="o_fp_portal_form mt-3" style="max-width: 720px; margin: 0 auto;">
<!-- Progress bar -->
<t t-set="current_step" t-value="'1'"/>
<t t-call="fusion_plating_portal.portal_configurator_progress"/>
<div class="card">
<div class="card-header">
<h5 class="mb-0">
<i class="fa fa-cube me-2"/>Part Information
</h5>
</div>
<div class="card-body">
<form method="POST" action="/my/configurator/new"
enctype="multipart/form-data">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<!-- Part Name & Number -->
<div class="row mb-3">
<div class="col-md-6">
<label for="part_name" class="form-label">Part Name *</label>
<input type="text" id="part_name" name="part_name"
class="form-control" required="required"
placeholder="e.g. Bearing Housing"/>
</div>
<div class="col-md-6">
<label for="part_number" class="form-label">Part Number</label>
<input type="text" id="part_number" name="part_number"
class="form-control"
placeholder="e.g. BH-2024-001"/>
</div>
</div>
<!-- Substrate Material -->
<div class="mb-3">
<label for="substrate_material" class="form-label">Substrate Material *</label>
<select id="substrate_material" name="substrate_material"
class="form-select" required="required">
<t t-foreach="materials" t-as="mat">
<option t-att-value="mat[0]" t-out="mat[1]"/>
</t>
</select>
</div>
<!-- File Upload -->
<div class="mb-4">
<label class="form-label">Part Drawing or 3D Model</label>
<div class="o_fp_file_drop_zone p-4">
<i class="fa fa-cloud-upload"/>
<p class="mb-1 fw-semibold">
Drag and drop your file here, or click to browse
</p>
<p class="small text-muted mb-2">
Accepted: STL, STP, STEP, IGES, PDF (max 50 MB)
</p>
<input type="file" name="part_file" id="part_file"
class="form-control"
accept=".stl,.stp,.step,.iges,.igs,.pdf"/>
</div>
</div>
<hr class="my-4"/>
<!-- Manual Measurements -->
<h6 class="mb-3">
<i class="fa fa-ruler-combined me-2"/>Manual Measurements
<span class="text-muted small fw-normal ms-2">
(if no 3D model uploaded)
</span>
</h6>
<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 -->
<div class="d-flex justify-content-between">
<a href="/my/configurator" class="btn btn-outline-secondary">
<i class="fa fa-arrow-left me-1"/>Cancel
</a>
<button type="submit" class="btn btn-primary">
Next: Select Coating
<i class="fa fa-arrow-right ms-1"/>
</button>
</div>
</form>
</div>
</div>
</div>
</t>
</template>
<!-- ================================================================== -->
<!-- STEP 2 — Select Coating Configuration -->
<!-- ================================================================== -->
<template id="portal_configurator_step2" name="Configurator Step 2 — Select Coating">
<t t-call="portal.portal_layout">
<div class="o_fp_portal_form mt-3" style="max-width: 900px; margin: 0 auto;">
<!-- Progress bar -->
<t t-set="current_step" t-value="'2'"/>
<t t-call="fusion_plating_portal.portal_configurator_progress"/>
<form method="POST" action="/my/configurator/coating">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<input type="hidden" name="coating_config_id" id="coating_config_id" value="0"/>
<!-- Part summary -->
<div class="alert alert-info d-flex align-items-center mb-4" role="alert">
<i class="fa fa-cube me-3 fa-lg"/>
<div>
<strong t-out="session_data.get('part_name', 'Part')"/>
<span t-if="session_data.get('part_number')"
class="text-muted ms-2">
(<t t-out="session_data.get('part_number')"/>)
</span>
<span class="ms-3 badge text-bg-secondary" t-out="session_data.get('substrate_material', '')"/>
<span t-if="session_data.get('surface_area')" class="ms-2 small">
<t t-out="session_data.get('surface_area')"/> sq in
</span>
</div>
</div>
<!-- Coating cards grid -->
<h5 class="mb-3">Select a Coating Configuration</h5>
<t t-if="not coatings">
<div class="alert alert-warning">
No coating configurations are available. Please contact us directly.
</div>
</t>
<div class="row g-3 mb-4">
<t t-foreach="coatings" t-as="coat">
<div class="col-md-6 col-lg-4">
<div class="card h-100 o_fp_portal_card o_fp_coating_card"
style="cursor: pointer; transition: border-color 150ms, box-shadow 150ms;"
t-att-data-coating-id="coat.id"
t-attf-onclick="
document.querySelectorAll('.o_fp_coating_card').forEach(c => {
c.style.borderColor = '';
c.style.boxShadow = '';
});
this.style.borderColor = 'var(--bs-primary)';
this.style.boxShadow = '0 0 0 2px var(--bs-primary)';
document.getElementById('coating_config_id').value = this.dataset.coatingId;
">
<div class="card-body">
<h6 class="card-title mb-2" style="color: var(--bs-body-color);">
<t t-out="coat.name"/>
</h6>
<p t-if="coat.process_type_id" class="small text-muted mb-1">
<i class="fa fa-flask me-1"/>
<t t-out="coat.process_type_id.name"/>
</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 t-if="coat.description" class="small text-muted mt-2 mb-0"
t-out="coat.description"/>
</div>
</div>
</div>
</t>
</div>
<!-- Quantity -->
<div class="row mb-4">
<div class="col-md-4">
<label for="quantity" class="form-label fw-semibold">Quantity</label>
<input type="number" id="quantity" name="quantity"
class="form-control" min="1" value="1" required="required"/>
</div>
</div>
<!-- Navigation -->
<div class="d-flex justify-content-between">
<a href="/my/configurator/new" class="btn btn-outline-secondary">
<i class="fa fa-arrow-left me-1"/>Back
</a>
<button type="submit" class="btn btn-primary">
Next: View Estimate
<i class="fa fa-arrow-right ms-1"/>
</button>
</div>
</form>
</div>
</t>
</template>
<!-- ================================================================== -->
<!-- STEP 3 — Estimate & Submit -->
<!-- ================================================================== -->
<template id="portal_configurator_step3" name="Configurator Step 3 — Estimate &amp; Submit">
<t t-call="portal.portal_layout">
<div class="o_fp_portal_form mt-3" style="max-width: 720px; margin: 0 auto;">
<!-- Progress bar -->
<t t-set="current_step" t-value="'3'"/>
<t t-call="fusion_plating_portal.portal_configurator_progress"/>
<!-- Summary card -->
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">
<i class="fa fa-clipboard me-2"/>Quote Summary
</h5>
</div>
<div class="card-body">
<!-- Part details -->
<div class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Part</div>
<div class="col-sm-8">
<strong t-out="session_data.get('part_name', '')"/>
<span t-if="session_data.get('part_number')" class="text-muted ms-1">
(<t t-out="session_data.get('part_number')"/>)
</span>
</div>
</div>
<div class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Material</div>
<div class="col-sm-8" t-out="session_data.get('substrate_material', '')"/>
</div>
<div t-if="session_data.get('surface_area')" class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Surface Area</div>
<div class="col-sm-8">
<t t-out="session_data.get('surface_area')"/> sq in
<span t-if="session_data.get('auto_calculated')"
class="badge text-bg-info ms-2">Auto-calculated from STL</span>
</div>
</div>
<div t-if="session_data.get('attachment_name')" class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Uploaded File</div>
<div class="col-sm-8">
<i class="fa fa-paperclip me-1"/>
<t t-out="session_data.get('attachment_name')"/>
</div>
</div>
<hr/>
<!-- Coating details -->
<div class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Coating</div>
<div class="col-sm-8">
<strong t-out="coating.name"/>
</div>
</div>
<div t-if="coating.spec_reference" class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Spec</div>
<div class="col-sm-8" t-out="coating.spec_reference"/>
</div>
<div class="row mb-3">
<div class="col-sm-4 text-muted small fw-semibold">Quantity</div>
<div class="col-sm-8" t-out="session_data.get('quantity', 1)"/>
</div>
<hr/>
<!-- Estimated Price -->
<div class="text-center py-3">
<t t-if="estimated_price.get('available')">
<p class="text-muted small mb-2">Estimated Price Range</p>
<p class="display-6 fw-bold mb-1" style="color: var(--bs-primary);">
$<t t-out="'{:,.2f}'.format(estimated_price['min'])"/>
<span class="text-muted mx-2" style="font-size: 0.6em;">to</span>
$<t t-out="'{:,.2f}'.format(estimated_price['max'])"/>
</p>
<p class="text-muted small mb-0">
Final pricing depends on masking complexity, batch size, and inspection requirements.
</p>
</t>
<t t-else="">
<div class="alert alert-secondary mb-0">
<i class="fa fa-info-circle me-2"/>
We could not calculate an automatic estimate for this configuration.
Our team will provide a detailed quote after reviewing your request.
</div>
</t>
</div>
</div>
</div>
<!-- Submit form -->
<div class="card">
<div class="card-body">
<form method="POST" action="/my/configurator/submit">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<div class="mb-3">
<label for="special_instructions" class="form-label fw-semibold">
Special Instructions
<span class="text-muted small fw-normal">(optional)</span>
</label>
<textarea id="special_instructions" name="special_instructions"
class="form-control" rows="3"
placeholder="Masking requirements, delivery preferences, certifications needed, etc."/>
</div>
<div class="alert alert-light border small mb-4">
<i class="fa fa-clock-o me-1"/>
Our team will review your request and provide a detailed quote
within 24 hours (business days).
</div>
<!-- Navigation -->
<div class="d-flex justify-content-between">
<a href="/my/configurator/coating" class="btn btn-outline-secondary">
<i class="fa fa-arrow-left me-1"/>Back
</a>
<button type="submit" class="btn btn-primary btn-lg">
<i class="fa fa-paper-plane me-2"/>Submit Quote Request
</button>
</div>
</form>
</div>
</div>
</div>
</t>
</template>
<!-- ================================================================== -->
<!-- SUCCESS PAGE -->
<!-- ================================================================== -->
<template id="portal_configurator_success" name="Configurator — Quote Submitted">
<t t-call="portal.portal_layout">
<div class="o_fp_portal_form mt-3" style="max-width: 600px; margin: 0 auto;">
<div class="card text-center py-5">
<div class="card-body">
<div class="mb-3">
<i class="fa fa-check-circle fa-4x" style="color: var(--bs-success);"/>
</div>
<h3 class="mb-3">Quote Request Submitted</h3>
<p class="text-muted mb-1">
Your request has been received with reference:
</p>
<p class="fw-bold fs-5 mb-4" style="color: var(--bs-primary);">
<t t-out="quote.name"/>
</p>
<p class="text-muted small mb-4">
Our estimating team will review your part details and coating
selection, then send you a detailed quote within 24 hours
(business days). You can track the status from your portal.
</p>
<div class="d-flex justify-content-center gap-3">
<a t-att-href="'/my/quote_requests/%s' % quote.id"
class="btn btn-primary">
<i class="fa fa-eye me-1"/>View Quote Request
</a>
<a href="/my/configurator" class="btn btn-outline-secondary">
<i class="fa fa-plus me-1"/>Start Another
</a>
</div>
</div>
</div>
</div>
</t>
</template>
</odoo>

View File

@@ -26,7 +26,10 @@
<!-- Quick Actions bar -->
<div class="d-flex flex-wrap gap-2 mb-4">
<a href="/my/quote_requests/new" class="btn btn-primary">
<a href="/my/configurator" class="btn btn-primary">
<i class="fa fa-cog me-1"/>Get a Quote
</a>
<a href="/my/quote_requests/new" class="btn btn-outline-primary">
<i class="fa fa-plus me-1"/>Request Quote
</a>
<a href="/my/quote_requests" class="btn btn-outline-secondary">
@@ -354,6 +357,11 @@
customize_show="True"
priority="40">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Get a Quote</t>
<t t-set="url" t-value="'/my/configurator'"/>
<t t-set="placeholder_count" t-value="'fp_quote_request_count'"/>
</t>
<t t-call="portal.portal_docs_entry">
<t t-set="title">Quote Requests</t>
<t t-set="url" t-value="'/my/quote_requests'"/>