|
| 1 | +<?xml version="1.0" encoding="utf-8" ?> |
| 2 | +<!-- |
| 3 | +Part of OpenSPP. See LICENSE file for full copyright and licensing details. |
| 4 | +
|
| 5 | +Area-based row-level filtering for registrants (OP#989). |
| 6 | +
|
| 7 | +Replaces / strengthens the `_prepare_domain` override in models/registrant.py |
| 8 | +which only catches `search_read` / `web_search_read`. An ir.rule applies to |
| 9 | +every ORM read path automatically: `search`, `search_count`, `read_group`, |
| 10 | +`name_search` (Many2one dropdowns), `read`, and related-field traversal. |
| 11 | +
|
| 12 | +The rule is scoped to `is_registrant = True` only — non-registrant contacts |
| 13 | +(users' own partners, admins, companies, system bots, mail followers) must |
| 14 | +remain readable, otherwise every record using `message_partner_ids` / |
| 15 | +`message_follower_ids` blows up for local users with `center_area_ids`. |
| 16 | +
|
| 17 | +The conditional domain makes the rule a no-op for users without |
| 18 | +`center_area_ids` (global roles). |
| 19 | +--> |
| 20 | +<odoo noupdate="1"> |
| 21 | + <record id="rule_res_partner_area_filter" model="ir.rule"> |
| 22 | + <field name="name">Registrants: visible only within user's center areas</field> |
| 23 | + <field name="model_id" ref="base.model_res_partner" /> |
| 24 | + <field |
| 25 | + name="domain_force" |
| 26 | + >['|', ('is_registrant', '=', False), ('area_id', 'child_of', user.center_area_ids.ids)] if user.center_area_ids else []</field> |
| 27 | + <field name="global" eval="True" /> |
| 28 | + <field name="perm_read" eval="True" /> |
| 29 | + <field name="perm_write" eval="True" /> |
| 30 | + <field name="perm_create" eval="True" /> |
| 31 | + <field name="perm_unlink" eval="True" /> |
| 32 | + </record> |
| 33 | +</odoo> |
0 commit comments