forked from OCA/l10n-france
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_install.py
55 lines (50 loc) · 2.06 KB
/
post_install.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
55
# Copyright 2017-2020 Akretion France
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from odoo import SUPERUSER_ID, api
logger = logging.getLogger(__name__)
def set_fr_company_intrastat(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
imdo = env["ir.model.data"]
afpo = env["account.fiscal.position"]
fr_id = env.ref("base.fr").id
companies = env["res.company"].search([("partner_id.country_id", "=", fr_id)])
out_inv_trans_id = env.ref(
"l10n_fr_intrastat_product.intrastat_transaction_21_11"
).id
out_ref_trans_id = env.ref(
"l10n_fr_intrastat_product.intrastat_transaction_25"
).id
in_inv_trans_id = env.ref(
"l10n_fr_intrastat_product.intrastat_transaction_11_11"
).id
for company in companies:
company.write(
{
"intrastat_transaction_out_invoice": out_inv_trans_id,
"intrastat_transaction_out_refund": out_ref_trans_id,
"intrastat_transaction_in_invoice": in_inv_trans_id,
"intrastat_accessory_costs": True,
}
)
fps = afpo.search([("company_id", "=", company.id)])
for fp in fps:
xmlid_rec = imdo.search(
[
("model", "=", "account.fiscal.position"),
("module", "=", "l10n_fr"),
("res_id", "=", fp.id),
("name", "=like", "%_fiscal_position_template_intraeub2b"),
],
limit=1,
)
if xmlid_rec:
logger.debug(
"set_fr_company_intrastat writing intrastat=True "
"on fiscal position ID %d",
fp.id,
)
fp.write({"intrastat": True})
return