Files
Odoo-Modules/fusion_plating/fusion_plating_notifications/models/account_move_send.py
gsinghpal 6b7b44264a changes
2026-05-10 10:25:12 -04:00

51 lines
2.1 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 api, models
class AccountMoveSend(models.AbstractModel):
_inherit = 'account.move.send'
@api.model
def _get_default_pdf_report_id(self, move):
"""Make the Fusion Plating invoice the official invoice PDF.
Odoo's Send wizard renders the chosen ``pdf_report`` as the
legal/audit-trail PDF (stored on ``move.invoice_pdf_report_id``)
and ALSO renders every extra report listed in the mail
template's ``report_template_ids`` minus the chosen pdf_report
and ``account.account_invoices`` (see
``_get_placeholder_mail_template_dynamic_attachments_data``).
Without this override the wizard picks ``account.account_invoices``
as the official PDF, so the email ships TWO invoices: the stock
Odoo one + our branded plating one (which is in our mail
template's ``report_template_ids``). Returning our report as the
default makes the set-difference cancel out and the customer
receives a single, branded invoice.
Partner-level and journal-level ``invoice_template_pdf_report_id``
overrides still win — admins can opt out per customer or journal.
"""
partner_default = move.commercial_partner_id.with_company(
move.company_id
).invoice_template_pdf_report_id
if partner_default:
return partner_default
journal_default = move.journal_id.with_company(
move.company_id
).invoice_template_pdf_report_id
if journal_default:
return journal_default
if move.move_type == 'out_invoice':
fp_report = self.env.ref(
'fusion_plating_reports.action_report_fp_invoice_portrait',
raise_if_not_found=False,
)
if fp_report and move._is_action_report_available(fp_report):
return fp_report
return super()._get_default_pdf_report_id(move)