File size: 2,146 Bytes
ce4b573 | 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # Copyright (C) 2020 Renato Lima - Akretion <renato.lima@akretion.com.br>
# 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, {})
sale_orders = env["sale.order"].search(
[("company_id", "!=", env.ref("base.main_company").id)]
)
for order in sale_orders:
defaults = order.sudo(user=order.user_id.id).default_get(order._fields)
defaults.update(
{
"name": order.name,
"fiscal_operation_id": order.fiscal_operation_id.id,
}
)
order.write(defaults)
# 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_sale",
"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_sale",
"demo/fiscal_operation_generic.xml",
None,
mode="init",
noupdate=True,
kind="init",
report=None,
)
|