mirror of
https://github.com/bringout/oca-mrp.git
synced 2026-04-24 17:12:04 +02:00
Initial commit: OCA Mrp packages (117 packages)
This commit is contained in:
commit
277e84fd7a
4403 changed files with 395154 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright 2019 Camptocamp SA
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
import logging
|
||||
|
||||
from psycopg2 import sql
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def pre_init_hook(cr):
|
||||
"""Initialize the value of the given column for existing rows in a fast way."""
|
||||
_logger.info(
|
||||
"Initializing column `unit_amount_rounded` with the " "value of `unit_amount`"
|
||||
)
|
||||
table = sql.Identifier("account_analytic_line")
|
||||
column = sql.Identifier("unit_amount_rounded")
|
||||
cr.execute( # pylint: disable=E8103
|
||||
sql.SQL("ALTER TABLE {} ADD COLUMN IF NOT EXISTS {} NUMERIC").format(
|
||||
table, column
|
||||
)
|
||||
)
|
||||
cr.execute( # pylint: disable=E8103
|
||||
sql.SQL(
|
||||
"UPDATE {table} SET {column} = unit_amount WHERE {column} IS NULL"
|
||||
).format(table=table, column=column)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue