From b137995193be0320aeb9f10946ca31cda6d371eb Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 27 Feb 2021 13:41:48 +0100 Subject: [PATCH] [OU-FIX] contract: Don't alter v12 recurrence mechanism + Transfer contract info from invoice We can't guarantee the homogeneity of the existing contracts, so we keep the line recurrence behavior. --- contract/__manifest__.py | 2 +- .../migrations/13.0.1.0.0/post-migration.py | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/contract/__manifest__.py b/contract/__manifest__.py index c06dce504..27a5530a0 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -11,7 +11,7 @@ { "name": "Recurring - Contracts Management", - "version": "13.0.2.3.5", + "version": "13.0.2.3.6", "category": "Contract Management", "license": "AGPL-3", "author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/contract/migrations/13.0.1.0.0/post-migration.py b/contract/migrations/13.0.1.0.0/post-migration.py index 23c29c718..11a817780 100644 --- a/contract/migrations/13.0.1.0.0/post-migration.py +++ b/contract/migrations/13.0.1.0.0/post-migration.py @@ -1,4 +1,4 @@ -# Copyright 2020 Tecnativa - Pedro M. Baeza +# Copyright 2020-2021 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade # pylint: disable=W7936 @@ -6,6 +6,28 @@ from openupgradelib import openupgrade # pylint: disable=W7936 @openupgrade.migrate() def migrate(env, version): + openupgrade.logged_query( + env.cr, + """ + UPDATE account_move am + SET old_contract_id = ai.old_contract_id + FROM account_invoice ai + WHERE ai.id = am.old_invoice_id + AND ai.old_contract_id IS NOT NULL""", + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE account_move_line aml + SET contract_line_id = ail.contract_line_id + FROM account_invoice_line ail + WHERE ail.id = aml.old_invoice_line_id + AND ail.contract_line_id IS NOT NULL""", + ) openupgrade.load_data( env.cr, "contract", "migrations/13.0.1.0.0/noupdate_changes.xml" ) + + # Don't alter line recurrence v12 behavior + contracts = env["contract.contract"].search([]) + contracts.write({"line_recurrence": True})