From e0d1998811b59a32953dc5cfd9b5773058c3d32a Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Tue, 12 May 2026 13:12:45 -0400 Subject: [PATCH] feat(numbering): draw quote name from fp.quote.number on SO create Co-Authored-By: Claude Opus 4.7 (1M context) --- .../fusion_plating_jobs/__manifest__.py | 2 +- .../fusion_plating_jobs/models/sale_order.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/fusion_plating/fusion_plating_jobs/__manifest__.py b/fusion_plating/fusion_plating_jobs/__manifest__.py index 597bc30e..89ef5d71 100644 --- a/fusion_plating/fusion_plating_jobs/__manifest__.py +++ b/fusion_plating/fusion_plating_jobs/__manifest__.py @@ -3,7 +3,7 @@ # License OPL-1 (Odoo Proprietary License v1.0) { 'name': 'Fusion Plating — Native Jobs', - 'version': '19.0.8.22.0', + 'version': '19.0.8.22.1', 'category': 'Manufacturing/Plating', 'summary': 'Native plating job model — replaces mrp.production / mrp.workorder bridge.', 'author': 'Nexa Systems Inc.', diff --git a/fusion_plating/fusion_plating_jobs/models/sale_order.py b/fusion_plating/fusion_plating_jobs/models/sale_order.py index cf588971..d20b77b0 100644 --- a/fusion_plating/fusion_plating_jobs/models/sale_order.py +++ b/fusion_plating/fusion_plating_jobs/models/sale_order.py @@ -220,6 +220,30 @@ class SaleOrder(models.Model): action.update({'view_mode': 'form', 'res_id': certs.id}) return action + # ------------------------------------------------------------------ + # Parent-number hierarchy — quote naming on create + # ------------------------------------------------------------------ + @api.model_create_multi + def create(self, vals_list): + """Draw Q-YYYYMM-N from fp.quote.number when no explicit name. + + The drawn name is also stashed in x_fc_quote_ref so it survives + the confirm-time rename to SO-. If the caller + passed an explicit name we preserve that AND mirror it into + x_fc_quote_ref (covers data migration, restore, etc.). + """ + Seq = self.env['ir.sequence'] + for vals in vals_list: + existing = vals.get('name') + if not existing or existing == _('New') or existing == 'New': + quote_name = Seq.next_by_code('fp.quote.number') + if quote_name: + vals['name'] = quote_name + vals.setdefault('x_fc_quote_ref', quote_name) + elif not vals.get('x_fc_quote_ref'): + vals['x_fc_quote_ref'] = existing + return super().create(vals_list) + def action_confirm(self): result = super().action_confirm() for so in self: