Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] repair #2721

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/repair/migrations/13.0.1.0/openupgrade_analysis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ NEW ir.ui.view: repair.view_repair_graph
NEW ir.ui.view: repair.view_repair_pivot
NEW ir.ui.view: repair.view_repair_tag_form
NEW ir.ui.view: repair.view_repair_tag_search
NEW ir.ui.view: repair.view_repair_tag_tree
NEW ir.ui.view: repair.view_repair_tag_tree
33 changes: 33 additions & 0 deletions addons/repair/migrations/13.0.1.0/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---Models in module 'repair'---
new model repair.tags
# NOTHING TO DO
---Fields in module 'repair'---
repair / account.move / repair_ids (one2many) : NEW relation: repair.order
repair / account.move.line / repair_fee_ids (one2many) : NEW relation: repair.fee
repair / account.move.line / repair_line_ids (one2many) : NEW relation: repair.line
# NOTHING TO DO
repair / repair.fee / invoice_line_id (many2one) : relation is now 'account.move.line' ('account.invoice.line') [nothing to do]
repair / repair.line / invoice_line_id (many2one) : relation is now 'account.move.line' ('account.invoice.line') [nothing to do]
repair / repair.order / invoice_id (many2one) : relation is now 'account.move' ('account.invoice') [nothing to do]
# DONE: post-migration: refilled many2one tables
repair / repair.order / tag_ids (many2many) : NEW relation: repair.tags
victoralmau marked this conversation as resolved.
Show resolved Hide resolved
# NOTHING TO DO
repair / repair.order / user_id (many2one) : NEW relation: res.users, hasdefault
# DONE: Set all records with create_uid
repair / repair.tags / color (integer) : NEW
repair / repair.tags / name (char) : NEW required
# NOTHING TO DO
---XML records in module 'repair'---
NEW ir.actions.act_window: repair.action_repair_order_graph
NEW ir.actions.act_window: repair.action_repair_order_tag
NEW ir.model.access: repair.access_repair_tag_user
NEW ir.ui.menu: repair.repair_menu
NEW ir.ui.menu: repair.repair_menu_config
NEW ir.ui.menu: repair.repair_menu_reporting
NEW ir.ui.menu: repair.repair_menu_tag
NEW ir.ui.view: repair.view_repair_graph
NEW ir.ui.view: repair.view_repair_pivot
NEW ir.ui.view: repair.view_repair_tag_form
NEW ir.ui.view: repair.view_repair_tag_search
NEW ir.ui.view: repair.view_repair_tag_tree
# NOTHING TO DO
63 changes: 63 additions & 0 deletions addons/repair/migrations/13.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from psycopg2 import sql
from openupgradelib import openupgrade


def update_repair_fee_invoice_relation(env):
openupgrade.logged_query(
env.cr, sql.SQL(
"""UPDATE repair_fee rf
SET invoice_line_id = aml.id
FROM account_move_line aml
WHERE rf.{} = aml.old_invoice_line_id"""
).format(
sql.Identifier(openupgrade.get_legacy_name("invoice_line_id"))
),
)


def update_repair_line_invoice_relation(env):
openupgrade.logged_query(
env.cr, sql.SQL(
"""UPDATE repair_line rl
SET invoice_line_id = aml.id
FROM account_move_line aml
WHERE rl.{} = aml.old_invoice_line_id"""
).format(
sql.Identifier(openupgrade.get_legacy_name("invoice_line_id"))
),
)


def update_repair_order_invoice_relation(env):
openupgrade.logged_query(
env.cr, sql.SQL(
"""UPDATE repair_order ro
SET invoice_id = am.id
FROM account_move am
WHERE ro.{} = am.old_invoice_id"""
).format(
sql.Identifier(openupgrade.get_legacy_name("invoice_id"))
),
)


def update_repair_order_user_id(env):
openupgrade.logged_query(
env.cr, """
UPDATE repair_order
victoralmau marked this conversation as resolved.
Show resolved Hide resolved
SET user_id = create_uid""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(
env.cr, "repair",
"migrations/13.0.1.0/noupdate_changes.xml"
)
update_repair_fee_invoice_relation(env)
update_repair_line_invoice_relation(env)
update_repair_order_invoice_relation(env)
update_repair_order_user_id(env)
15 changes: 15 additions & 0 deletions addons/repair/migrations/13.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


_rename_columns = {
"repair_fee": [('invoice_line_id', None)],
"repair_line": [('invoice_line_id', None)],
"repair_order": [('invoice_id', None)],
}


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, _rename_columns)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules120-130.rst
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ missing in the new release are marked with |del|.
+----------------------------------------------+-------------------------------------------------+
|rating | Nothing to do |
+----------------------------------------------+-------------------------------------------------+
|repair | |
|repair | Done |
+----------------------------------------------+-------------------------------------------------+
|resource | Done |
+----------------------------------------------+-------------------------------------------------+
Expand Down