Skip to content

Commit

Permalink
Merge PR #64 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
github-grap-bot committed Nov 15, 2024
2 parents 7e9f2cb + a4a66ac commit c087e55
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
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>

0 comments on commit c087e55

Please sign in to comment.