-
-
Notifications
You must be signed in to change notification settings - Fork 248
/
hooks.py
46 lines (41 loc) · 1.13 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
# Copyright (C) 2019-2020 - Raphael Valyi Akretion
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
import logging
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
def pre_init_hook(cr):
"""
The objective of this hook is to ensure the Brazil country is
translated as "Brasil" in pt_BR to get the NFe tests pass
even if the pt_BR language pack is not installed.
"""
cr.execute(
"""SELECT id
FROM ir_translation
WHERE name='res.country,name' AND
lang='pt_BR'"""
)
if not cr.fetchone():
env = api.Environment(cr, SUPERUSER_ID, {})
brazil_country_id = env.ref("base.br").id
insert_query = """
INSERT INTO ir_translation (
name,
res_id,
lang,
type,
src,
value,
module,
state)
VALUES (
'res.country,name',
%s,
'pt_BR',
'model',
'Brazil',
'Brasil',
'base',
'translated');
"""
cr.execute(insert_query, (brazil_country_id,))