forked from OCA/l10n-brazil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
54 lines (47 loc) · 1.65 KB
/
hooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright (C) 2020 Renato Lima - Akretion <[email protected]>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import SUPERUSER_ID, api, tools
def post_init_hook(cr, registry):
if not tools.config["without_demo"]:
env = api.Environment(cr, SUPERUSER_ID, {})
# Load COA Fiscal Operation properties
company = env.ref(
"l10n_br_base.empresa_simples_nacional", raise_if_not_found=False
)
# COA Simple Fiscal Operation properties
if company and env["ir.module.module"].search_count(
[
("name", "=", "l10n_br_coa_simple"),
("state", "=", "installed"),
]
):
tools.convert_file(
cr,
"l10n_br_stock_account",
"demo/fiscal_operation_simple.xml",
None,
mode="init",
noupdate=True,
kind="init",
report=None,
)
company_lc = env.ref(
"l10n_br_base.empresa_lucro_presumido", raise_if_not_found=False
)
# COA Generic Fiscal Operation properties
if company_lc and env["ir.module.module"].search_count(
[
("name", "=", "l10n_br_coa_generic"),
("state", "=", "installed"),
]
):
tools.convert_file(
cr,
"l10n_br_stock_account",
"demo/fiscal_operation_generic.xml",
None,
mode="init",
noupdate=True,
kind="init",
report=None,
)