feat(configurator): auto-load latest part description version on order entry

Wizard line (direct + express) and SO line now pre-fill BOTH internal +
customer-facing from the part's latest version (fallback to
default_specification_text), without clobbering typed text.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-29 19:57:16 -04:00
parent da7ec59474
commit 855b160752
3 changed files with 34 additions and 6 deletions

View File

@@ -42,6 +42,20 @@ class SaleOrderLine(models.Model):
return tail.lstrip(' \t\r\n-—–:').strip()
return name
@api.onchange('x_fc_part_catalog_id')
def _fp_onchange_part_load_description(self):
"""Pre-fill name (customer-facing) + x_fc_internal_description from
the part's latest description version, when empty (spec 2026-05-29)."""
for line in self:
part = line.x_fc_part_catalog_id
if not part:
continue
descs = part._fp_resolve_line_descriptions()
if not line.name and descs['customer_facing']:
line.name = descs['customer_facing']
if not line.x_fc_internal_description and descs['internal']:
line.x_fc_internal_description = descs['internal']
x_fc_part_catalog_id = fields.Many2one(
'fp.part.catalog', string='Part',
)