[ADD] tax_receipt_in_portal: publish tax receipts on the portal
Let donors view and download their own tax receipts from ``/my/tax-receipts``: a paginated list, a detail page with the receipt information, its invoices and the native portal chatter, and a PDF download rendered on demand through the configured ``pdf_form`` report. The PDF rendering is delegated to ``pdf_form_report`` and nothing is archived: a confirmed receipt is frozen by ``l10n_fr_tax_receipt``, so rendering it again yields the same document. Two safety nets compensate third-party behaviors: - report resolution by ``report_uuid`` (system parameter ``tax_receipt_in_portal.report_uuid``) with strict validation of report type and target model; - a blank-field guard which resolves every mapped PDF field value before rendering, because ``pdf_form_report`` swallows resolution errors and would otherwise silently serve a receipt with a blank amount. Access is enforced twice: a portal record rule (own commercial partner, confirmed/sent state only) and an explicit controller domain that also covers internal users browsing ``/my``. Tested with 17 tests (portal isolation, draft exposure, chatter data access, blank-field guard, report misconfiguration, private API contract of ``pdf_form_report``), including a mutation check proving the security tests fail when the record rule is opened.
This commit is contained in:
2
tax_receipt_in_portal/security/ir.model.access.csv
Normal file
2
tax_receipt_in_portal/security/ir.model.access.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_l10n_fr_tax_receipt_portal,l10n.fr.tax.receipt portal read-only,l10n_fr_tax_receipt.model_l10n_fr_tax_receipt,base.group_portal,1,0,0,0
|
||||
|
29
tax_receipt_in_portal/security/ir_rule.xml
Normal file
29
tax_receipt_in_portal/security/ir_rule.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<!--
|
||||
A donor may only read the receipts issued to their own commercial
|
||||
entity, and only once confirmed: a draft receipt carries no legal
|
||||
number yet.
|
||||
|
||||
Odoo scopes portal invoices through `message_partner_ids`, i.e. on
|
||||
followers. That is deliberately not used here: tax receipts created
|
||||
by the yearly generation wizard have no follower, so such a rule
|
||||
would always yield an empty list.
|
||||
-->
|
||||
<record id="tax_receipt_rule_portal" model="ir.rule">
|
||||
<field name="name">Portal: own confirmed tax receipts</field>
|
||||
<field
|
||||
name="model_id"
|
||||
ref="l10n_fr_tax_receipt.model_l10n_fr_tax_receipt"
|
||||
/>
|
||||
<field name="domain_force">
|
||||
[('partner_id', 'child_of', [user.commercial_partner_id.id]),
|
||||
('state', 'in', ['confirmed', 'sent'])]
|
||||
</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]" />
|
||||
<field name="perm_read" eval="True" />
|
||||
<field name="perm_write" eval="False" />
|
||||
<field name="perm_create" eval="False" />
|
||||
<field name="perm_unlink" eval="False" />
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user