forked from OCA/account-invoicing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_hook.py
38 lines (31 loc) · 1.15 KB
/
init_hook.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
# Copyright 2021 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tools.sql import column_exists
logger = logging.getLogger(__name__)
def pre_init_hook(cr):
"""
The objective of this hook is to speed up the installation
of the module on an existing Odoo instance.
"""
store_exception_fields(cr)
def store_exception_fields(cr):
if not column_exists(cr, "account_move", "main_exception_id"):
logger.info("Creating field main_exception_id on account_move")
cr.execute(
"""
ALTER TABLE account_move
ADD COLUMN main_exception_id int;
COMMENT ON COLUMN account_move.main_exception_id IS 'Main Exception';
"""
)
if not column_exists(cr, "account_move", "ignore_exception"):
logger.info("Creating field ignore_exception on account_move")
cr.execute(
"""
ALTER TABLE account_move
ADD COLUMN ignore_exception boolean;
COMMENT ON COLUMN account_move.ignore_exception IS 'Ignore Exceptions';
"""
)