Files
Odoo-Modules/fusion_plating/fusion_plating_notifications/models/fusion_shipment.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

53 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
"""Phase C - fire 'shipment_labeled' notification when tracking_number
lands on a fusion.shipment for the first time.
Triggers regardless of how tracking got set: live API call or manual
fallback wizard. Customer gets the tracking link as soon as the label
is generated, not after the package physically ships (that's the
existing 'shipped' event on fp.delivery)."""
import logging
from odoo import models
_logger = logging.getLogger(__name__)
class FusionShipment(models.Model):
_inherit = 'fusion.shipment'
def write(self, vals):
# Identify shipments that gain a tracking number for the first
# time. Done BEFORE super().write so we can compare before/after.
will_fire = self.browse()
if 'tracking_number' in vals and vals.get('tracking_number'):
will_fire = self.filtered(lambda s: not s.tracking_number)
res = super().write(vals)
if not will_fire:
return res
Dispatch = self.env.get('fp.notification.template')
if Dispatch is None:
return res
for ship in will_fire:
partner = (
ship.sale_order_id.partner_id
if ship.sale_order_id else False
)
if not partner:
continue
try:
Dispatch._dispatch(
'shipment_labeled',
ship,
partner,
sale_order=ship.sale_order_id or False,
)
except Exception as e:
_logger.warning(
'Shipment %s: shipment_labeled dispatch failed: %s',
ship.name, e,
)
return res