feat(numbering): wire CoC/RCV/DLV/PU into parent-numbered mixin + rename counters
Per-model counter fields on sale.order renamed to x_fc_pn_*_count to avoid collision with pre-existing compute fields of the same short name in bridge_mrp / receiving / configurator (silent compute-override was suppressing the storage). 4 child models (fp.certificate, fp.receiving, fusion.plating.delivery, fusion.plating.pickup.request) now derive names as PFX-<parent> with -NN suffix from the 2nd onward. fusion.plating.pickup.request gains a sale_order_id field (optional) so pickups created against an SO get parent-derived names, while standalone pickups (pre-SO) fall back to PU/YYYY/NNNN. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ class FpReceiving(models.Model):
|
||||
"""
|
||||
_name = 'fp.receiving'
|
||||
_description = 'Fusion Plating — Receiving'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin', 'fp.parent.numbered.mixin']
|
||||
_order = 'received_date desc, id desc'
|
||||
|
||||
name = fields.Char(string='Reference', readonly=True, copy=False, default='New')
|
||||
@@ -97,19 +97,38 @@ class FpReceiving(models.Model):
|
||||
rec.unresolved_damage_count = len(rec.damage_ids.filtered(lambda d: not d.resolved))
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Sequence
|
||||
# Sequence + parent-derived naming
|
||||
# -------------------------------------------------------------------------
|
||||
def _fp_parent_sale_order(self):
|
||||
return self.sale_order_id
|
||||
|
||||
def _fp_name_prefix(self):
|
||||
return 'RCV'
|
||||
|
||||
def _fp_parent_counter_field(self):
|
||||
return 'x_fc_pn_receiving_count'
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if vals.get('name', 'New') == 'New':
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('fp.receiving') or 'New'
|
||||
# Prefill received_qty from expected_qty so the operator only
|
||||
# types when the count is wrong (the common case is "all
|
||||
# arrived"). Saves a step on every routine receipt.
|
||||
# types when the count is wrong.
|
||||
if vals.get('expected_qty') and not vals.get('received_qty'):
|
||||
vals['received_qty'] = vals['expected_qty']
|
||||
return super().create(vals_list)
|
||||
if not vals.get('name'):
|
||||
vals['name'] = 'New'
|
||||
records = super().create(vals_list)
|
||||
for rec in records:
|
||||
if rec.name and rec.name != 'New':
|
||||
continue
|
||||
if not rec._fp_assign_parent_name():
|
||||
seq = self.env['ir.sequence'].next_by_code('fp.receiving') or 'New'
|
||||
self.env.cr.execute(
|
||||
"UPDATE fp_receiving SET name = %s WHERE id = %s",
|
||||
(seq, rec.id),
|
||||
)
|
||||
rec.invalidate_recordset(['name'])
|
||||
return records
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Sub 8 — box-count-only actions (new primary flow)
|
||||
|
||||
Reference in New Issue
Block a user