[IMP] tax_receipt_in_portal: pick report per company, hide missing PDFs
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m30s
tests / test (pull_request) Failing after 1m41s

Replace the ``tax_receipt_in_portal.report_uuid`` system parameter by a
per-company setting, in Settings > Invoicing > Tax Receipts
(``res.company.tax_receipt_report_id``). Each receipt is rendered with
the report of its issuing company, not the current one: in the portal,
the current company is the website's. The selector only offers PDF Form
reports on ``l10n.fr.tax.receipt``; type and model are still checked at
rendering time since the report can be edited after selection.

The download buttons of the list and detail pages are only shown when
the PDF can actually be rendered: a valid report is configured for the
issuing company and no mapped field resolves to an empty value. The
checks are those of the rendering itself, exposed as a filter
(``_get_pdf_available_receipts``) and run in sudo to avoid false
negatives on field paths the donor cannot read. Otherwise a discreet
"PDF available soon" mention replaces the button, and the download URL
redirects to the receipt page.

The detail page download link now also carries the share token, so a
visitor reaching the page by token can download the PDF.
This commit is contained in:
Stéphan Sainléger
2026-10-23 13:00:01 +02:00
parent 73c0684623
commit 5eb3fe766b
11 changed files with 397 additions and 93 deletions

View File

@@ -99,6 +99,7 @@
</td>
<td class="text-end">
<a
t-if="receipt.id in pdf_available_ids"
class="btn btn-sm btn-secondary"
t-attf-href="/my/tax-receipts/#{receipt.id}/download"
t-att-title="receipt.name"
@@ -106,6 +107,10 @@
<i class="fa fa-download me-1" role="img" />
<span>PDF</span>
</a>
<span
t-else=""
class="text-muted small o_tax_receipt_pdf_pending"
>PDF available soon</span>
</td>
</tr>
</tbody>
@@ -132,12 +137,17 @@
</div>
<div class="col-12 col-md-6 text-md-end">
<a
t-if="pdf_available"
class="btn btn-primary"
t-attf-href="/my/tax-receipts/#{tax_receipt.id}/download"
t-attf-href="/my/tax-receipts/#{tax_receipt.id}/download#{'?access_token=%s' % access_token if access_token else ''}"
>
<i class="fa fa-download me-1" role="img" />
<span>Download PDF</span>
</a>
<span
t-else=""
class="text-muted o_tax_receipt_pdf_pending"
>PDF available soon</span>
</div>
</div>
<div class="row mt-4" id="tax_receipt_information">

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.tax.receipt.portal</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//block[@id='invoicing_settings']" position="after">
<block title="Tax Receipts" id="tax_receipt_settings">
<setting
id="tax_receipt_report"
string="Tax Receipt Report"
company_dependent="1"
help="PDF Form report used to render tax receipts downloaded from the portal"
>
<field
name="tax_receipt_report_id"
options="{'no_create': True}"
/>
</setting>
</block>
</xpath>
</field>
</record>
</odoo>