mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[REF] Contract Sale Invoicing: split from analytic account
[REF] Contract Sale Invoicing: update translations [IMP] - Assert that the predecessor is available for new link at uncancel [RMV] - remove usless changes [RMV] - Remove usless field recurring_invoices after the total isolation between contract model and account analytic one. recurring_invoices which was used to mark analytic account as contract became usless [IMP] - P3 syntax [IMP] - use @openupgrade.migrate() and openupgrade.logged_query [IMP] - drop transient table in migration script
This commit is contained in:
committed by
sbejaoui
parent
24f57be03d
commit
a429b10c20
@@ -11,7 +11,7 @@ _logger = logging.getLogger(__name__)
|
||||
def migrate(cr, version):
|
||||
"""Copy recurrence info from contract to contract lines and compute
|
||||
last_date_invoiced"""
|
||||
|
||||
_logger.info(">> Post-Migration 12.0.2.0.0")
|
||||
cr.execute(
|
||||
"""UPDATE account_analytic_invoice_line AS contract_line
|
||||
SET recurring_rule_type=contract.recurring_rule_type,
|
||||
@@ -23,8 +23,6 @@ def migrate(cr, version):
|
||||
FROM account_analytic_account AS contract
|
||||
WHERE contract.id=contract_line.contract_id"""
|
||||
)
|
||||
|
||||
_logger.info("order all contract line")
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
contract_lines = env["account.analytic.invoice.line"].search(
|
||||
[("recurring_next_date", "!=", False)]
|
||||
|
||||
@@ -12,7 +12,7 @@ def migrate(cr, version):
|
||||
"""
|
||||
set recurring_next_date to false for finished contract
|
||||
"""
|
||||
_logger.info("order all contract line")
|
||||
_logger.info(">> Pre-Migration 12.0.2.0.0")
|
||||
with api.Environment(cr, SUPERUSER_ID, {}) as env:
|
||||
contracts = env["account.analytic.account"].search([])
|
||||
finished_contract = contracts.filtered(
|
||||
|
||||
@@ -9,6 +9,7 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
_logger.info(">> Post-Migration 12.0.3.0.0")
|
||||
_logger.info("Populate invoicing partner field on contracts")
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
contracts = env["account.analytic.account"].search([])
|
||||
|
||||
@@ -8,8 +8,11 @@ from openupgradelib import openupgrade
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
cr.execute(
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
cr = env.cr
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
INSERT INTO contract_contract (
|
||||
id,
|
||||
@@ -24,7 +27,6 @@ def migrate(cr, version):
|
||||
code,
|
||||
group_id,
|
||||
contract_template_id,
|
||||
recurring_invoices,
|
||||
user_id,
|
||||
recurring_next_date,
|
||||
date_end,
|
||||
@@ -49,7 +51,6 @@ def migrate(cr, version):
|
||||
code,
|
||||
group_id,
|
||||
contract_template_id,
|
||||
recurring_invoices,
|
||||
user_id,
|
||||
recurring_next_date,
|
||||
date_end,
|
||||
@@ -62,10 +63,13 @@ def migrate(cr, version):
|
||||
write_uid,
|
||||
write_date
|
||||
FROM account_analytic_account
|
||||
WHERE recurring_invoices = TRUE
|
||||
WHERE id in (
|
||||
SELECT DISTINCT contract_id FROM account_analytic_invoice_line
|
||||
)
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
INSERT INTO contract_line (
|
||||
id,
|
||||
@@ -126,18 +130,21 @@ def migrate(cr, version):
|
||||
)
|
||||
openupgrade.rename_models(cr, [('account.analytic.invoice.line',
|
||||
'contract.line')])
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
DROP TABLE account_analytic_invoice_line
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
UPDATE account_invoice_line
|
||||
SET contract_line_id = contract_line_id_tmp
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
ALTER TABLE account_invoice_line
|
||||
DROP COLUMN contract_line_id_tmp
|
||||
|
||||
@@ -8,7 +8,16 @@ from openupgradelib import openupgrade
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
_logger.info(">> Pre-Migration 12.0.4.0.0")
|
||||
cr = env.cr
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
DROP TABLE IF EXISTS account_analytic_invoice_line_wizard
|
||||
"""
|
||||
)
|
||||
models_to_rename = [
|
||||
# Contract Line Wizard
|
||||
('account.analytic.invoice.line.wizard', 'contract.line.wizard'),
|
||||
@@ -25,8 +34,6 @@ def migrate(cr, version):
|
||||
('account.analytic.contract.line', 'contract.template.line'),
|
||||
]
|
||||
tables_to_rename = [
|
||||
# Contract Line Wizard
|
||||
('account_analytic_invoice_line_wizard', 'contract_line_wizard'),
|
||||
# Contract Template
|
||||
('account_analytic_contract', 'contract_template'),
|
||||
# Contract Template Line
|
||||
@@ -53,19 +60,22 @@ def migrate(cr, version):
|
||||
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
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
ALTER TABLE account_invoice_line
|
||||
ADD COLUMN contract_line_id_tmp INTEGER
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
UPDATE account_invoice_line
|
||||
SET contract_line_id_tmp = contract_line_id
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
UPDATE account_invoice_line SET contract_line_id = NULL
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user