Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOBUMP][FIX] fiscal_company_base: By default, 'basic users' doesn't have access to all companies. (readonly) that is a problem in a CAE context #64

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fiscal_company_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "CAE - Base",
"version": "16.0.1.1.1",
"version": "16.0.2.0.0",
"category": "CAE",
"summary": "Manage CAE (Cooperatives of Activities and Employment)",
"author": "GRAP",
Expand All @@ -18,7 +18,7 @@
"mail",
],
"data": [
# "security/ir_rule.xml",
"security/ir_rule.xml",
"views/view_res_company.xml",
],
"demo": [
Expand Down
25 changes: 25 additions & 0 deletions fiscal_company_base/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)


_CORE_RULES = [
"base.res_company_rule_employee", # res.company
]


def post_init_hook(cr, registry):
_toggle_standard_rules(cr, False)


def uninstall_hook(cr, registry):
_toggle_standard_rules(cr, True)


def _toggle_standard_rules(cr, enabled):
env = api.Environment(cr, SUPERUSER_ID, {})
for xml_id in _CORE_RULES:
rule = env.ref(xml_id)
rule.active = enabled
11 changes: 11 additions & 0 deletions fiscal_company_base/migrations/16.0.2.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2024-Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


# pylint: disable=W8150
from odoo.addons.fiscal_company_base import hooks


def migrate(cr, version):
hooks._toggle_standard_rules(cr, False)
17 changes: 15 additions & 2 deletions fiscal_company_base/security/ir_rule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ Copyright (C) 2013-Today GRAP (http://www.grap.coop)

<odoo>

<!-- res.company -->
<!-- See all the res.company -->
<!-- Odoo DEFAULT: [('id','in', company_ids)] -->
<record id="rule_res_company" model="ir.rule">
<field name="name">res.company (fiscal_company_base)</field>
<field name="model_id" ref="base.model_res_company"/>
<field name="groups" eval="[Command.set([ref('base.group_user')])]"/>
<field name="global" eval="False"/>
<field name="domain_force">
[(1,'=',1)]
</field>
</record>

<!--
recreate a new rule, because base.res_partner_rule is noupdatable
and to prevent errors, when uninstalling module
-->
<record id="res_partner_rule" model="ir.rule">
<!-- <record id="res_partner_rule" model="ir.rule">
<field name="name">res.partner CAE company</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="domain_force">[
Expand All @@ -25,6 +38,6 @@ Copyright (C) 2013-Today GRAP (http://www.grap.coop)
('is_odoo_company', '=', True),
]</field>

</record>
</record> -->

</odoo>
Loading