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

[FIX] fiscal_company_account: overload correctly ir.rule #61

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
1 change: 1 addition & 0 deletions fiscal_company_account/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from .hooks import post_init_hook, uninstall_hook
11 changes: 9 additions & 2 deletions fiscal_company_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@

{
"name": "CAE - Account",
"version": "16.0.1.1.0",
"version": "16.0.2.0.0",
"category": "CAE",
"summary": "Glue Module between CAE and Account modules",
"author": "GRAP",
"website": "https://github.com/grap/odoo-addons-cae",
"license": "AGPL-3",
"depends": ["fiscal_company_base", "account"],
"depends": [
# Odoo
"account",
# GRAP
"fiscal_company_base",
],
"data": [
"security/ir_rule.xml",
# "views/menu.xml",
Expand All @@ -26,6 +31,8 @@
"demo/res_partner.xml",
"demo/ir_property.xml",
],
"post_init_hook": "post_init_hook",
"uninstall_hook": "uninstall_hook",
"installable": True,
"auto_install": True,
}
29 changes: 29 additions & 0 deletions fiscal_company_account/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)


_CORE_RULES = [
"account.account_comp_rule", # account.account
"account.account_fiscal_position_comp_rule", # account.fiscal.position
"account.journal_comp_rule", # account.journal
"account.account_root_comp_rule", # account.root
"account.tax_comp_rule", # account.tax
]


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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

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


def migrate(cr, version):
hooks._toggle_standard_rules(cr, False)
29 changes: 24 additions & 5 deletions fiscal_company_account/security/ir_rule.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2013-Today GRAP (http://www.grap.coop)
@author Julien Weste
Expand All @@ -11,7 +11,20 @@ Copyright (C) 2013-Today GRAP (http://www.grap.coop)
<!-- account.account -->
<!-- See the accounts of the fiscal mother company -->
<!-- Odoo DEFAULT: [('company_id', 'in', company_ids)] -->
<record id="account.account_comp_rule" model="ir.rule">
<record id="rule_account_account" model="ir.rule">
<field name="name">account.account (fiscal_company_account)</field>
<field name="model_id" ref="account.model_account_account"/>
<field name="domain_force">
[('company_id', 'in', user._include_fiscal_company_ids(company_ids))]
</field>
</record>

<!-- account.root -->
<!-- See the account roots of the fiscal mother company -->
<!-- Odoo DEFAULT: [('company_id', 'in', company_ids + [False])] -->
<record id="rule_account_root" model="ir.rule">
<field name="name">account.root (fiscal_company_account)</field>
<field name="model_id" ref="account.model_account_root"/>
<field name="domain_force">
[('company_id', 'in', user._include_fiscal_company_ids(company_ids))]
</field>
Expand All @@ -20,7 +33,9 @@ Copyright (C) 2013-Today GRAP (http://www.grap.coop)
<!-- account.tax -->
<!-- See the taxes of the fiscal mother company -->
<!-- Odoo DEFAULT: [('company_id', 'in', company_ids)] -->
<record id="account.tax_comp_rule" model="ir.rule">
<record id="rule_account_tax" model="ir.rule">
<field name="name">account.tax (fiscal_company_account)</field>
<field name="model_id" ref="account.model_account_tax"/>
<field name="domain_force">
[('company_id', 'in', user._include_fiscal_company_ids(company_ids))]
</field>
Expand All @@ -29,7 +44,9 @@ Copyright (C) 2013-Today GRAP (http://www.grap.coop)
<!-- account.journal -->
<!-- See the journals of the fiscal mother company -->
<!-- Odoo DEFAULT: [('company_id', 'in', company_ids)] -->
<record id="account.journal_comp_rule" model="ir.rule">
<record id="rule_account_journal" model="ir.rule">
<field name="name">account.journal (fiscal_company_account)</field>
<field name="model_id" ref="account.model_account_journal"/>
<field name="domain_force">
[('company_id', 'in', user._include_fiscal_company_ids(company_ids))]
</field>
Expand All @@ -38,7 +55,9 @@ Copyright (C) 2013-Today GRAP (http://www.grap.coop)
<!-- account.fiscal.position -->
<!-- See the fiscal positions of the fiscal mother company -->
<!-- Odoo DEFAULT: [('company_id', 'in', company_ids)] -->
<record id="account.account_fiscal_position_comp_rule" model="ir.rule">
<record id="rule_account_fiscal_position" model="ir.rule">
<field name="name">account.fiscal.position (fiscal_company_account)</field>
<field name="model_id" ref="account.model_account_fiscal_position"/>
<field name="domain_force">
[('company_id', 'in', user._include_fiscal_company_ids(company_ids))]
</field>
Expand Down
Loading