Skip to content

[IMP] subscription_oca: add multi-company security rules#1439

Open
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-imp-subscription_oca-multicompany-rules
Open

[IMP] subscription_oca: add multi-company security rules#1439
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-imp-subscription_oca-multicompany-rules

Conversation

@alvaro-domatix
Copy link
Copy Markdown

Problem

Without record rules, a salesman from company A can read and write subscriptions belonging to company B. The module only ships ACLs in ir.model.access.csv and no ir.rule records, so multi-company isolation is missing for both sale.subscription and sale.subscription.line.

Solution

Add security/subscription_security.xml with two non-global record rules attached to the sales_team.group_sale_salesman group:

  • sale_subscription_company_rule: domain [('company_id', 'in', company_ids)].
  • sale_subscription_line_company_rule: domain [('sale_subscription_id.company_id', 'in', company_ids)].

The new security file is declared in the manifest before security/ir.model.access.csv so the rules are available as soon as access rights are created.

How to test

Run:

odoo-bin -d <db> --init=subscription_oca --stop-after-init
odoo-bin -d <db> -u subscription_oca --test-enable --test-tags=/subscription_oca --stop-after-init

New test module tests/test_subscription_security.py covers:

  • A salesman scoped to company A can read its own subscriptions and lines.
  • The same salesman gets AccessError when reading a subscription or a line in company B.
  • Searching for a foreign-company subscription returns an empty recordset (rule applies at search time, not just read).

Without record rules, a salesman from company A could read or write
subscriptions belonging to company B. This change adds record rules on
sale.subscription and sale.subscription.line so that the salesman group
only sees records whose company_id is in the user's allowed companies,
matching the standard multi-company pattern used across OCA.

The new security file is declared in the manifest before the ACL CSV
so that rules are available as soon as access rights are created.
@alvaro-domatix alvaro-domatix force-pushed the 19.0-imp-subscription_oca-multicompany-rules branch from dc10651 to ff1205c Compare May 27, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants