0

everyone! First of all, thanks in advance.

I've searched everywhere for a solution for my problem. Even when copying from the source code, it doesn't solve it.

I'm doing the Advanced B: ACL and Record Rules tutorial

When completing the sub-chapter on multi-company security, I can't do it.

My user can't get access to my new company

The problems I've encountered so far are:

  1. The new company isn't in company_ids
  2. When changing the Default Company and allowed companies, if:
    • The company is the new company

    • The only allowed company is the new company

      Then, I get the error: Access Error: Access to unauthorized or invalid companies.

I don't know why my new company is invalid

I'm trying to access another company's records

This is my rule:

<record id="estate_private_companies_properties" model="ir.rule">
    <field name="name">Privacy Plan Multi-Company</field>
    <field name="model_id" ref="model_estate_property"/>
    <field name="global" eval="True"/>
    <field name="domain_force">[
            ('company_id', 'in', company_ids)
    ]</field>
</record>

EDIT:

Sorry for the confusion. I know the xml is not the problem

The problem is that my company is unauthorized or invalid and it doesn't show up in my company_ids

  • Please remove everything involving the tutorial and the xml file. Only the company not being accessible should be in your question. – switch87 Nov 11 '22 at 00:07

2 Answers2

0

What the xml does is filter so you can only access the estate properties that are assigned to the currently active company (or companies). So it hasn't any effect on creating a company or making a company accessible.

If this is not the problem, please rephrase your question.

switch87
  • 295
  • 1
  • 18
0

Make sure the user you test with has access to the company.

  • Login as the admin user
  • go to settings
  • Users & companies -> Users
  • select your user
  • in the user form you see a new field "Allowed Companies" which is only visible once you added a new company.
  • Make sure the new company is in this many2many list
  • login as your user
switch87
  • 295
  • 1
  • 18