Skip to content

Commit

Permalink
[ADD] base_automation: Migration scripts
Browse files Browse the repository at this point in the history
Co-Authored-By: Pedro M. Baeza <[email protected]>
  • Loading branch information
RaulOForgeFlow and pedrobaeza committed Jun 6, 2021
1 parent b5a4a68 commit 659a35e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|base_address_extended | |
+--------------------------------------------+-------------------------------------------------+
|base_automation | |
|base_automation | Done |
+--------------------------------------------+-------------------------------------------------+
| |del| base_gengo | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def fill_base_automation_ir_model_fields_rel(env):
openupgrade.logged_query(
env.cr,
"""
WITH q1 AS (
SELECT ba.id, unnest(
string_to_array(ba.on_change_fields, ',')
) AS field, ias.model_id
FROM base_automation ba
JOIN ir_act_server ias ON ba.action_server_id = ias.id
WHERE ba.on_change_fields is not null
)
INSERT INTO base_automation_onchange_fields_rel
(base_automation_id, ir_model_fields_id)
SELECT q1.id, imf.id
FROM ir_model_fields AS imf
JOIN q1 ON imf.name = q1.field
WHERE imf.model_id = q1.model_id
""",
)


@openupgrade.migrate()
def migrate(env, version):
fill_base_automation_ir_model_fields_rel(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---Models in module 'base_automation'---
model base.automation.lead.test (moved to test_base_automation)
model base.automation.line.test (moved to test_base_automation)
# NOTHING TO DO: Lead test and line test moved to new module test_base_automation to define the models

---Fields in module 'base_automation'---
base_automation / base.automation / on_change_fields (char) : DEL
base_automation / base.automation / on_change_field_ids (many2many): NEW relation: ir.model.fields
# DONE: post-migration: filled m2m relation table
# Field name changed as now uses a m2m relation instead of char with the list of fields that trigger on_change

base_automation / base.automation.lead.test / __last_update (datetime) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / _order : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / active (boolean) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / date_action_last (datetime) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / deadline (boolean) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / display_name (char) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / employee (boolean) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / is_assigned_to_admin (boolean): module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / line_ids (one2many) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / name (char) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / partner_id (many2one) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / priority (boolean) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / state (selection) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.lead.test / user_id (many2one) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.line.test / __last_update (datetime) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.line.test / _order : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.line.test / display_name (char) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.line.test / lead_id (many2one) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.line.test / name (char) : module is now 'test_base_automation' ('base_automation')
base_automation / base.automation.line.test / user_id (many2one) : module is now 'test_base_automation' ('base_automation')
# NOTHING TO DO

---XML records in module 'base_automation'---
DEL ir.model.access: base_automation.access_base_automation
DEL ir.model.access: base_automation.access_base_automation_lead_test [renamed to test_base_automation module]
DEL ir.model.access: base_automation.access_base_automation_line_test [renamed to test_base_automation module]
# NOTHING TO DO

0 comments on commit 659a35e

Please sign in to comment.