{"record":{"id":"682153878682b4eb","repo":"odoo/odoo","slug":"there-is-no-template-that-applies-to-invoices","errorCode":null,"errorMessage":"There is no template that applies to invoices.","messagePattern":"There is no template that applies to invoices\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"addons/account/models/account_move.py","lineNumber":6977,"sourceCode":"        if self.is_sale_document(include_receipts=True) and self.company_id.account_discount_expense_allocation_id:\n            return self.company_id.account_discount_expense_allocation_id\n        if self.is_purchase_document(include_receipts=True) and self.company_id.account_discount_income_allocation_id:\n            return self.company_id.account_discount_income_allocation_id\n        return None\n\n    def _get_available_invoice_template_pdf_report_ids(self):\n        \"\"\"\n        Helper to get available invoice template pdf reports\n        \"\"\"\n        moves = self\n\n        for move_type in ['out_invoice', 'out_refund', 'out_receipt']:\n            moves += self.new({'move_type': move_type})\n\n        available_reports = moves._get_available_action_reports()\n\n        if not available_reports:\n            raise UserError(_(\"There is no template that applies to invoices.\"))\n\n        return available_reports\n\n    def _is_user_able_to_review(self):\n        # If only account is installed, we don't check user access rights.\n        return True\n\n    # -------------------------------------------------------------------------\n    # TOOLING\n    # -------------------------------------------------------------------------\n\n    @api.model\n    def _field_will_change(self, record, vals, field_name):\n        if field_name not in vals:\n            return False\n        field = record._fields[field_name]\n        if field.type == 'many2one':\n            return record[field_name].id != vals[field_name]","sourceCodeStart":6959,"sourceCodeEnd":6995,"githubUrl":"https://github.com/odoo/odoo/blob/1e661df964b1b264c9cef3ab28430d4785be3fda/addons/account/models/account_move.py#L6959-L6995","documentation":"Raised by account.move._get_available_invoice_template_pdf_report_ids(), which builds the list of PDF report templates available for customer invoices (out_invoice, out_refund, out_receipt). It creates new-record proxies for each outgoing move type and asks _get_available_action_reports() which reports apply. If no report is bound to these move types (no invoice report action enabled), it raises this UserError — typically surfaced when clicking 'Print & Send' / previewing an invoice PDF.","triggerScenarios":"Opening the invoice PDF/preview flow when _get_available_action_reports() returns empty for all of out_invoice/out_refund/out_receipt — e.g. the standard 'account.invoice' report action is disabled (report action active=False or deleted), a custom module removed the report binding, or report XML ids were improperly cleaned during migration.","commonSituations":"Report action deactivated via Settings > Technical > Reports; a module overriding/deleting account.account_invoices without replacing it; botched database migration or cleanup scripts removing ir.actions.report rows; multi-company setups where the report is company-filtered out.","solutions":["Re-enable/recreate the ir.actions.report for invoices: Settings > Technical > Actions > Reports, find 'Invoices' (xml_id account.account_invoices) and set it active with binding for out_invoice/out_refund/out_receipt.","If a custom module replaced the report, verify its ir.actions.report record and binding_model_id/binding_view_types are correct and the module is installed/updated (odoo -u module).","Check for ir.actions.report rows deleted at SQL level — restore from a backup or re-run the module's data loading (update account module)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"reports = move._get_available_action_reports() if not move.is_purchase_document(include_receipts=True) else move.move_id.line_ids  # cheap probe\n# safer: wrap the call\ntry:\n    template_ids = move._get_available_invoice_template_pdf_report_ids()\nexcept UserError:\n    template_ids = self.env['ir.actions.report']\nif not template_ids:\n    _logger.warning('No invoice PDF report configured; skipping print & send')","typeGuard":null,"tryCatchPattern":"from odoo.exceptions import UserError\ntry:\n    report_ids = move._get_available_invoice_template_pdf_report_ids()\nexcept UserError as e:\n    if 'no template that applies' in str(e):\n        report_ids = None  # degrade gracefully: skip PDF attachment\n    else:\n        raise","preventionTips":["Include a test that asserts ir.actions.report 'account.account_invoices' exists and is active after module updates.","Avoid deleting/disabling report actions; override the QWeb template instead.","After migrations, verify report bindings for out_invoice/out_refund/out_receipt."],"tags":["accounting","reporting","pdf","qweb","configuration"],"backgroundTag":null,"analyzedSha":"1e661df964b1b264c9cef3ab28430d4785be3fda","analyzedAt":"2026-08-15T05:22:16.142Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}