From a659eba8f5b51098e79dada6adf086a353fd9932 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Tue, 21 Apr 2026 22:49:49 -0400 Subject: [PATCH] feat(configurator): SO-line template picker + dual descriptions + onchange (Sub 2 Task 15) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surfaces the per-part description template on the SO line list alongside a hidden-by-default internal description column. Picking a template fires an onchange that copies `customer_facing_description` into Odoo's standard `name` (customer-visible) and `internal_description` into x_fc_internal_description (shop-floor / WO only). Estimator can edit either field after the template is applied. The template picker's domain filters by the line's part, and the field stays hidden until a part is chosen — avoids showing every global template when the line is blank. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../models/sale_order_line.py | 18 +++++++++++++++++- .../views/sale_order_views.xml | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/fusion_plating/fusion_plating_configurator/models/sale_order_line.py b/fusion_plating/fusion_plating_configurator/models/sale_order_line.py index e1650ca5..87b19e6b 100644 --- a/fusion_plating/fusion_plating_configurator/models/sale_order_line.py +++ b/fusion_plating/fusion_plating_configurator/models/sale_order_line.py @@ -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 SaleOrderLine(models.Model): @@ -66,6 +66,22 @@ class SaleOrderLine(models.Model): 'preserved for audit. Useful when a part is cancelled mid-order.', ) + @api.onchange('x_fc_description_template_id') + def _onchange_description_template(self): + """When estimator picks a template, auto-fill both descriptions. + + The customer-facing text goes into `name` (Odoo's line description, + prints on customer docs). The internal text goes into + x_fc_internal_description (prints on WO / traveler only). + Estimator can edit either field after the template is applied. + """ + if self.x_fc_description_template_id: + tpl = self.x_fc_description_template_id + if tpl.customer_facing_description: + self.name = tpl.customer_facing_description + if tpl.internal_description: + self.x_fc_internal_description = tpl.internal_description + def action_archive_line(self): self.write({'x_fc_archived': True}) return True diff --git a/fusion_plating/fusion_plating_configurator/views/sale_order_views.xml b/fusion_plating/fusion_plating_configurator/views/sale_order_views.xml index 3248c4d0..d22540a4 100644 --- a/fusion_plating/fusion_plating_configurator/views/sale_order_views.xml +++ b/fusion_plating/fusion_plating_configurator/views/sale_order_views.xml @@ -179,6 +179,14 @@ + +