mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[RMV] - Remove empty file [IMP] - Update no_update cron after migration [IMP] - move contract template recurrence info to line level [FIX] - Fix contract line model description [IMP] - Link contracts to analytic accounts [FIX] - Fix pylint [IMP] - Move chatter and attachments from analytic account to contract [IMP] - Move account_analytic_id to contract line level [IMP] - Improve version check in migration script [IMP] - Move contracts followers from analytic accounts [ADD] - Add mail.activity.mixin to contract.contract model remove data drop from migration scripts [12.0][FIX] - Fix _init_last_date_invoiced fix flake8 [ADD] - Update contributors list
114 lines
3.4 KiB
Python
114 lines
3.4 KiB
Python
# Copyright 2019 ACSONE SA/NV
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
import logging
|
|
|
|
from openupgradelib import openupgrade
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
@openupgrade.migrate()
|
|
def migrate(env, version):
|
|
_logger.info(">> Pre-Migration 12.0.4.0.0")
|
|
cr = env.cr
|
|
|
|
models_to_rename = [
|
|
# Contract Line Wizard
|
|
('account.analytic.invoice.line.wizard', 'contract.line.wizard'),
|
|
# Abstract Contract
|
|
('account.abstract.analytic.contract', 'contract.abstract.contract'),
|
|
# Abstract Contract Line
|
|
(
|
|
'account.abstract.analytic.contract.line',
|
|
'contract.abstract.contract.line',
|
|
),
|
|
# Contract Line
|
|
('account.analytic.invoice.line', 'contract.line'),
|
|
# Contract Template
|
|
('account.analytic.contract', 'contract.template'),
|
|
# Contract Template Line
|
|
('account.analytic.contract.line', 'contract.template.line'),
|
|
]
|
|
tables_to_rename = [
|
|
# Contract Template
|
|
('account_analytic_contract', 'contract_template'),
|
|
# Contract Template Line
|
|
('account_analytic_contract_line', 'contract_template_line'),
|
|
]
|
|
xmlids_to_rename = [
|
|
(
|
|
'contract.account_analytic_cron_for_invoice',
|
|
'contract.contract_cron_for_invoice',
|
|
),
|
|
(
|
|
'contract.account_analytic_contract_manager',
|
|
'contract.contract_template_manager',
|
|
),
|
|
(
|
|
'contract.account_analytic_contract_user',
|
|
'contract.contract_template_user',
|
|
),
|
|
(
|
|
'contract.account_analytic_invoice_line_manager',
|
|
'contract.contract_line_manager',
|
|
),
|
|
(
|
|
'contract.account_analytic_invoice_line_user',
|
|
'contract.contract_line_user',
|
|
),
|
|
(
|
|
'contract.account_analytic_contract_line_manager',
|
|
'contract.contract_template_line_manager',
|
|
),
|
|
(
|
|
'contract.account_analytic_contract_line_user',
|
|
'contract.contract_template_line_user',
|
|
),
|
|
]
|
|
openupgrade.rename_models(cr, models_to_rename)
|
|
openupgrade.rename_tables(cr, tables_to_rename)
|
|
openupgrade.rename_xmlids(cr, xmlids_to_rename)
|
|
# A temporary column is needed to avoid breaking the foreign key constraint
|
|
# The temporary column is dropped in the post-migration script
|
|
openupgrade.logged_query(
|
|
cr,
|
|
"""
|
|
ALTER TABLE account_invoice_line
|
|
ADD COLUMN contract_line_id_tmp INTEGER
|
|
""",
|
|
)
|
|
if openupgrade.column_exists(
|
|
cr, 'account_invoice_line', 'contract_line_id'
|
|
):
|
|
openupgrade.logged_query(
|
|
cr,
|
|
"""
|
|
UPDATE account_invoice_line
|
|
SET contract_line_id_tmp = contract_line_id
|
|
""",
|
|
)
|
|
openupgrade.logged_query(
|
|
cr,
|
|
"""
|
|
UPDATE account_invoice_line SET contract_line_id = NULL
|
|
""",
|
|
)
|
|
if not openupgrade.column_exists(
|
|
cr, 'account_invoice', 'old_contract_id'
|
|
):
|
|
openupgrade.logged_query(
|
|
cr,
|
|
"""
|
|
ALTER TABLE account_invoice
|
|
ADD COLUMN old_contract_id_tmp INTEGER
|
|
""",
|
|
)
|
|
openupgrade.logged_query(
|
|
cr,
|
|
"""
|
|
UPDATE account_invoice
|
|
SET old_contract_id_tmp = contract_id
|
|
""",
|
|
)
|