feat(numbering): draw quote name from fp.quote.number on SO create
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||||
{
|
{
|
||||||
'name': 'Fusion Plating — Native Jobs',
|
'name': 'Fusion Plating — Native Jobs',
|
||||||
'version': '19.0.8.22.0',
|
'version': '19.0.8.22.1',
|
||||||
'category': 'Manufacturing/Plating',
|
'category': 'Manufacturing/Plating',
|
||||||
'summary': 'Native plating job model — replaces mrp.production / mrp.workorder bridge.',
|
'summary': 'Native plating job model — replaces mrp.production / mrp.workorder bridge.',
|
||||||
'author': 'Nexa Systems Inc.',
|
'author': 'Nexa Systems Inc.',
|
||||||
|
|||||||
@@ -220,6 +220,30 @@ class SaleOrder(models.Model):
|
|||||||
action.update({'view_mode': 'form', 'res_id': certs.id})
|
action.update({'view_mode': 'form', 'res_id': certs.id})
|
||||||
return action
|
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-<parent_number>. 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):
|
def action_confirm(self):
|
||||||
result = super().action_confirm()
|
result = super().action_confirm()
|
||||||
for so in self:
|
for so in self:
|
||||||
|
|||||||
Reference in New Issue
Block a user