Files
Odoo-Modules/fusion_plating/fusion_plating_receiving/migrations/19.0.3.19.0/post-migrate.py
gsinghpal 8c76a16366 chore(plating): de-dash shipped code + intake-neutral customer emails
Replace em-dashes and en-dashes with hyphens across 789 shipped source
files (py/xml/js/scss) so the delivered module reads as human-written;
em-dashes had become a recognizable AI-generated tell. Internal .md dev
notes are excluded. The WO-sticker mojibake strippers keep their dash
search targets (now written — / –). No logic changes: comments
and display strings only; validated with py_compile + lxml parse.

Rewrite the 7 customer notification emails to be intake-neutral
(ship-in / drop-off / pickup) and repair-aware, and fix the Shipped
email documents line (packing slip vs bill of lading; certificate only
when issued). Subjects use a hyphen separator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 00:16:19 -04:00

45 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
#
# Backfill fp.job.qty_received from closed fp.receiving lines.
#
# Triggering issue (2026-05-20): WO-30043 - and any other job created
# before the new _update_job_qty_received hook shipped - has
# qty_received=0 even though its receiving is closed. The
# button_mark_done gate then blocks the operator with no obvious next
# step ("Quantity Received is blank - close the receiving record...").
# Receiving IS closed. The propagation was missing.
#
# This migration walks every (closed / accepted / resolved) receiving,
# matches lines to their corresponding fp.job by (sale_order_id +
# part_catalog_id), and writes received_qty onto the job. Idempotent.
import logging
_logger = logging.getLogger(__name__)
def migrate(cr, version):
"""Backfill fp.job.qty_received from already-closed receivings."""
# Match by SO + part_catalog. Same logic as the new runtime hook.
cr.execute("""
UPDATE fp_job j
SET qty_received = rl.received_qty
FROM fp_receiving r
JOIN fp_receiving_line rl ON rl.receiving_id = r.id
WHERE r.state IN ('closed', 'accepted', 'resolved')
AND r.sale_order_id = j.sale_order_id
AND rl.part_catalog_id = j.part_catalog_id
AND (j.qty_received IS NULL OR j.qty_received = 0)
AND rl.received_qty IS NOT NULL
AND rl.received_qty > 0
""")
updated = cr.rowcount
if updated:
_logger.info(
'fp.job.qty_received backfilled from receiving lines on '
'%d job(s) - fixes WO-30043 and any sibling stuck jobs.',
updated,
)