-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
53 lines (42 loc) · 1.86 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
# Copyright (C) 2022-Today - Engenere (<https://engenere.one>).
# @author Antônio S. Pereira Neto <neto@engenere.one>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api, tools
def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
load_simples_nacional_demo(env, registry)
def load_simples_nacional_demo(env, registry):
"""
Load demo data for company 'Simples Nacional' with
default user company set to this company.
"""
# Load XML file with demo data.
if not tools.config["without_demo"]:
# Allow all companies for OdooBot user and set default user company
companies = env["res.company"].search([])
env.user.company_ids = [(6, 0, companies.ids)]
env.user.company_id = env.ref("l10n_br_base.empresa_simples_nacional")
tools.convert_file(
env.cr,
"l10n_br_account_nfe",
"demo/account_invoice_sn_demo.xml",
None,
mode="init",
noupdate=True,
kind="demo",
)
# É necessário rodar os onchanges fiscais para
# preencher os campos referentes aos Impostos
invoice_tag_cobranca = env.ref("l10n_br_account_nfe.demo_nfe_dados_de_cobranca")
for line in invoice_tag_cobranca.invoice_line_ids:
line._onchange_fiscal_operation_line_id()
line._onchange_fiscal_tax_ids()
invoice_sem_tag_cobranca = env.ref(
"l10n_br_account_nfe.demo_nfe_sem_dados_de_cobranca"
)
for line in invoice_sem_tag_cobranca.invoice_line_ids:
line._onchange_fiscal_operation_line_id()
line._onchange_fiscal_tax_ids()
# back to the main company as the next modules to be installed
# expect this to be the default company.
env.user.company_id = env.ref("base.main_company")