Files
Odoo-Modules/fusion_plating/fusion_plating_bridge_mrp/models/account_move.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

54 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from odoo import models
class AccountMove(models.Model):
"""Extend invoice to auto-complete portal job when posted.
GAP 7: Invoice posted → find portal job for same customer/SO
→ set state "complete" + invoice_ref.
"""
_inherit = 'account.move'
def action_post(self):
"""Override to cascade invoice posting to portal job completion."""
res = super().action_post()
PortalJob = self.env.get('fusion.plating.portal.job')
if PortalJob is None:
return res
for invoice in self:
if invoice.move_type != 'out_invoice':
continue
# Find portal jobs for this customer that are shipped but not complete
# Match by SO origin from the invoice lines
origin = invoice.invoice_origin or ''
jobs = PortalJob.browse()
if origin:
# Try to find MO linked to this SO, then its portal job
mos = self.env['mrp.production'].search(
[('origin', '=', origin)],
)
for mo in mos:
if mo.x_fc_portal_job_id and mo.x_fc_portal_job_id.state == 'shipped':
jobs |= mo.x_fc_portal_job_id
# Fallback: find shipped jobs for same partner
if not jobs:
jobs = PortalJob.search([
('partner_id', '=', invoice.partner_id.id),
('state', '=', 'shipped'),
('invoice_ref', '=', False),
], limit=1)
for job in jobs:
job.write({
'state': 'complete',
'invoice_ref': invoice.name,
})
job.message_post(
body='Invoice %s posted - job complete.' % invoice.name,
)
return res