Files
Odoo-18.0-20251222/sale_stock_line_customer_ref/hooks.py
tocmo0nlord adbe430761
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

35 lines
1.0 KiB
Python
Executable File

# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
import logging
from odoo.tools import sql
logger = logging.getLogger(__name__)
def pre_init_hook(env):
"""Create table columns for computed fields to not get them computed by Odoo.
This is done to avoid MemoryError when installing the module on big databases.
Also it is useless to compute these fields which should be empty when installing
the module because no SO lines have a customer reference set.
"""
# Create columns
cr = env.cr
if not sql.column_exists(cr, "stock_move", "customer_ref_sale_line_id"):
sql.create_column(
cr,
"stock_move",
"customer_ref_sale_line_id",
"int4",
comment="Sale Line With Customer Ref",
)
if not sql.column_exists(cr, "stock_move", "customer_ref"):
sql.create_column(
cr,
"stock_move",
"customer_ref",
"VARCHAR",
)