forked from OpenG2P/storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.py
33 lines (30 loc) · 892 Bytes
/
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
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
_logger = logging.getLogger(__name__)
def pre_init_hook(cr):
"""Pre init hook."""
# add columns for computed fields to avoid useless computation by the ORM
# when installing the module
_logger.info("Add columns for computed fields on ir_attachment")
cr.execute(
"""
ALTER TABLE ir_attachment
ADD COLUMN fs_storage_id INTEGER;
ALTER TABLE ir_attachment
ADD FOREIGN KEY (fs_storage_id) REFERENCES fs_storage(id);
"""
)
cr.execute(
"""
ALTER TABLE ir_attachment
ADD COLUMN fs_url VARCHAR;
"""
)
cr.execute(
"""
ALTER TABLE ir_attachment
ADD COLUMN fs_storage_code VARCHAR;
"""
)
_logger.info("Columns added on ir_attachment")