multi-company icon indicating copy to clipboard operation
multi-company copied to clipboard

[16.0][ADD] new module res_company_access_all_children

Open legalsylvain opened this issue 1 year ago • 6 comments

Description

This module is usefull in a multi-company context with hierarchy. (with parent and child companies)

Once installed, if a user has access to a parent company, he will have access to all the child companies.

If a new child company is created, all the users that have access to the parent company will have access to the new child company.

This module avoids the need for parameterization, which can be fastidious in a context with many companies and users.

legalsylvain avatar Aug 03 '24 23:08 legalsylvain

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Feb 02 '25 12:02 github-actions[bot]

@legalsylvain Great feature! I can test as soon as the runboat is built. I would only rename it in proper English res_company_access_all_children ;-)

polchampion avatar Mar 25 '25 15:03 polchampion

thanks for your english review !

module renamed. runboat should be available in some minutes. please ping me if there is a problem.

legalsylvain avatar Mar 25 '25 16:03 legalsylvain

@legalsylvain I have this error when trying to set a company_id on a partner:

​​
code: 200
​​
columnNumber: 274
​​
data: Object { name: "odoo.exceptions.AccessError", debug: `Traceback (most recent call last):\n  File "/opt/odoo/odoo/http.py", line 1658, in _serve_db\n    return service_model.retrying(self._serve_ir_http, self.env)\n  File "/opt/odoo/odoo/service/model.py", line 152, in retrying\n    result = func()\n  File "/opt/odoo/odoo/http.py", line 1686, in _serve_ir_http\n    response = self.dispatcher.dispatch(rule.endpoint, args)\n  File "/opt/odoo/odoo/http.py", line 1890, in dispatch\n    result = self.request.registry['ir.http']._dispatch(endpoint)\n  File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch\n    result = endpoint(**request.params)\n  File "/opt/odoo/odoo/http.py", line 734, in route_wrapper\n    result = endpoint(self, *args, **params_ok)\n  File "/opt/odoo/addons/web/controllers/dataset.py", line 43, in call_kw\n    return self._call_kw(model, method, args, kwargs)\n  File "/opt/odoo/addons/web/controllers/dataset.py", line 34, in _call_kw\n    return call_kw(Model, method, args, kwargs)\n  File "/opt/odoo/odoo/api.py", line 482, in call_kw\n    result = _call_kw_model_create(method, model, args, kwargs)\n  File "/opt/odoo/odoo/api.py", line 460, in _call_kw_model_create\n    result = method(recs, *args, **kwargs)\n  File "<decorator-gen-151>", line 2, in create\n  File "/opt/odoo/odoo/api.py", line 430, in _model_create_multi\n    return create(self, [arg])\n  File "/opt/odoo/addons/partner_autocomplete/models/res_partner.py", line 212, in create\n    partners = super(ResPartner, self).create(vals_list)\n  File "<decorator-gen-104>", line 2, in create\n  File "/opt/odoo/odoo/api.py", line 431, in _model_create_multi\n    return create(self, arg)\n  File "/opt/odoo/odoo/addons/base/models/res_partner.py", line 746, in create\n    partners = super(Partner, self).create(vals_list)\n  File "<decorator-gen-128>", line 2, in create\n  File "/opt/odoo/odoo/api.py", line 431, in _model_create_multi\n    return create(self, arg)\n  File "/opt/odoo/addons/mail/models/mail_thread.py", line 258, in create\n    threads = super(MailThread, self).create(vals_list)\n  File "<decorator-gen-68>", line 2, in create\n  File "/opt/odoo/odoo/api.py", line 431, in _model_create_multi\n    return create(self, arg)\n  File "/opt/odoo/odoo/addons/base/models/ir_fields.py", line 670, in create\n    recs = super().create(vals_list)\n  File "<decorator-gen-15>", line 2, in create\n  File "/opt/odoo/odoo/api.py", line 431, in _model_create_multi\n    return create(self, arg)\n  File "/opt/odoo/odoo/models.py", line 4019, in create\n    records = self._create(data_list)\n  File "/opt/odoo/odoo/models.py", line 4272, in _create\n    records.check_access_rule('create')\n  File "/opt/odoo/odoo/models.py", line 3536, in check_access_rule\n    raise self.env['ir.rule']._make_access_error(operation, forbidden)\nodoo.exceptions.AccessError: Due to security restrictions, you are not allowed to create 'Contact' (res.partner) records.\n\nContact your administrator to request access if necessary.\n`, message: "Due to security restrictions, you are not allowed to create 'Contact' (res.partner) records.\n\nContact your administrator to request access if necessary.", … }
​​
exceptionName: "odoo.exceptions.AccessError"
​​
fileName: "http://oca-multi-company-16-0-pr676-8e30efda9ad1.runboat.odoo-community.org/web/assets/216-4cd1e31/web.assets_backend.min.js"
​​
lineNumber: 998```

polchampion avatar Mar 27 '25 09:03 polchampion

hi @polchampion.

This error looks legit and occures in native Odoo instance.

legalsylvain avatar Mar 31 '25 07:03 legalsylvain

Hey @polchampion could review it again ? :)

quentinDupont avatar Jun 11 '25 09:06 quentinDupont