feat(thickness): single Char range field — drop fp.recipe.thickness picker

Per client direction: every order is a thickness RANGE (e.g.
"0.0005-0.0008 mils" or "5-10 mils"), never a single value. The
old picker model (fp.recipe.thickness with a single 'value' Float)
was modelling the wrong concept and overcrowding the order entry
UI. Replaced with one free-text Char field that auto-fills from
last-used or part default.

DELETED entirely:
- fp.recipe.thickness model (file + view + ACL + manifest entry)
- recipe.thickness_option_ids One2many (the picker source)
- "Thickness Options" inline list on the recipe form
- sale.order.line.x_fc_thickness_id (M2O picker)
- account.move.line.x_fc_thickness_id
- fp.delivery.x_fc_thickness_id
- fp.direct.order.line.thickness_id

ADDED:
- sale.order.line.x_fc_thickness_range (Char) — operator types range
- account.move.line.x_fc_thickness_range — for invoice rendering
- fp.delivery.x_fc_thickness_range — for packing slip
- fp.direct.order.line.thickness_range — for the wizard
- fp.part.catalog.x_fc_default_thickness_range — part default

AUTO-FILL CHAIN (sale.order.line + wizard line):
1. Operator already typed → keep
2. Most recent SO line for (this part, this customer) with a
   non-empty thickness_range → copy that
3. part.x_fc_default_thickness_range → copy
4. Blank — operator types

Implemented as both an @api.onchange (interactive) AND a
create() override (programmatic — wizard, sale_mrp bridge,
imports). Same logic in both paths.

WIZARD push-to-defaults: when "Save as Default" toggle is ticked
on a wizard line, persist the line's thickness_range to
part.x_fc_default_thickness_range so future first-customer orders
get a sensible starting point.

REPORTS: customer_line_header.xml + report_fp_wo_sticker.xml now
print the Char range as-typed (no display_name lookup needed).

KEPT (admin documentation only — doesn't affect order entry):
- recipe.thickness_min, thickness_max, thickness_uom on the recipe
  root: documents the recipe's CAPABILITY range. No UI gate; just
  for spec authors to record what the chemistry can produce.

JOB GROUPING: fp.job auto-create groups SO lines by (recipe, part,
spec, thickness, serial). Updated to key on the thickness_range
Char (stripped) instead of the deleted thickness_id integer.

DB cleanup: --update=base ran on the upgrade, dropping the
fp_recipe_thickness table + the four x_fc_thickness_id columns.
Existing data was already nulled in earlier dev work.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-15 08:54:40 -04:00
parent 21754c1660
commit 152ed86c3a
23 changed files with 164 additions and 169 deletions

View File

@@ -394,11 +394,11 @@ class FpDirectOrderLine(models.Model):
if rec.serial_id and rec.serial_id not in rec.serial_ids:
rec.serial_ids = [(4, rec.serial_id.id)]
job_number = fields.Char(string='Job #')
thickness_id = fields.Many2one(
'fp.recipe.thickness',
thickness_range = fields.Char(
string='Thickness',
domain="[('recipe_id', '=', process_variant_id)]",
ondelete='set null',
help='Free-form range, e.g. "0.0005-0.0008 mils" or "5-10 mils". '
'Auto-fills from last order for this (part, customer) pair, '
'or from the part\'s default range.',
)
# ---- Computes ----
@@ -416,12 +416,36 @@ class FpDirectOrderLine(models.Model):
and rec.quantity
)
@api.onchange('process_variant_id')
def _onchange_recipe_clears_thickness(self):
@api.onchange('part_catalog_id')
def _onchange_part_default_thickness(self):
"""Auto-fill thickness range — same chain as the SO line.
1. Operator already typed → keep
2. Most recent SO line for (part, customer) with a thickness → copy
3. Part's x_fc_default_thickness_range → copy
4. Blank
"""
for rec in self:
if (rec.thickness_id
and rec.thickness_id.recipe_id != rec.process_variant_id):
rec.thickness_id = False
if rec.thickness_range:
continue
if not rec.part_catalog_id:
continue
partner = rec.wizard_id.partner_id
if partner:
recent = self.env['sale.order.line'].search([
('x_fc_part_catalog_id', '=', rec.part_catalog_id.id),
('order_id.partner_id', '=', partner.id),
('x_fc_thickness_range', '!=', False),
('x_fc_thickness_range', '!=', ''),
], order='create_date desc', limit=1)
if recent:
rec.thickness_range = recent.x_fc_thickness_range
continue
part_default = getattr(
rec.part_catalog_id, 'x_fc_default_thickness_range', None,
)
if part_default:
rec.thickness_range = part_default
def action_generate_serial(self):
"""Generate one auto-sequenced fp.serial and append to the M2M.

View File

@@ -595,7 +595,7 @@ class FpDirectOrderWizard(models.Model):
if line.serial_ids else False),
'x_fc_serial_id': line.serial_id.id or False,
'x_fc_job_number': line.job_number or False,
'x_fc_thickness_id': line.thickness_id.id or False,
'x_fc_thickness_range': line.thickness_range or False,
# Sub 9 — explicit tax override from the wizard line.
# When blank, Odoo will compute taxes from the product
# defaults at SO-line save time (the standard behaviour).
@@ -633,6 +633,15 @@ class FpDirectOrderWizard(models.Model):
# 6. Push-to-defaults — Specification carry-over to the part's
# x_fc_default_customer_spec_id is handled by an inherit in
# fusion_plating_quality (the field lives there).
# Thickness range: lives in configurator, push here.
for line in self.line_ids:
if not line.push_to_defaults or line.is_one_off:
continue
part = resolved_parts.get(line.id) or line.part_catalog_id
if not part:
continue
if line.thickness_range and not part.x_fc_default_thickness_range:
part.x_fc_default_thickness_range = line.thickness_range
so.message_post(body=_(
'Quotation created from PO %s with %d line(s). '
'Review and confirm manually when ready.'

View File

@@ -172,11 +172,8 @@
string="Process Source"
readonly="1"
optional="hide"/>
<field name="thickness_id"
options="{'no_quick_create': True}"
context="{'default_recipe_id': process_variant_id}"
domain="[('recipe_id', '=', process_variant_id)]"
invisible="not process_variant_id"
<field name="thickness_range"
placeholder="e.g. 0.0005-0.0008 mils"
optional="show"/>
<field name="serial_ids"
widget="many2many_tags"