forked from OCA/l10n-spain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
35 lines (29 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
# Copyright 2022 Acsone SA - Xavier Bouquiaux
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from odoo import tools
from odoo.tools.sql import column_exists
_logger = logging.getLogger(__name__)
def create_column_thirdparty_invoice(cr):
if not column_exists(
cr, "account_journal", "thirdparty_invoice"
) and not column_exists(cr, "account_move", "thirdparty_invoice"):
_logger.info("Initializing column thirdparty_invoice on table account_move")
tools.create_column(
cr=cr,
tablename="account_move",
columnname="thirdparty_invoice",
columntype="boolean",
comment="Third-party invoice",
)
tools.create_column(
cr=cr,
tablename="account_journal",
columnname="thirdparty_invoice",
columntype="boolean",
comment="Third-party invoice",
)
cr.execute("UPDATE account_move SET thirdparty_invoice = False")
cr.execute("UPDATE account_journal SET thirdparty_invoice = False")
def pre_init_hook(cr):
create_column_thirdparty_invoice(cr)