From 6447b8682f52661c6315ca0fe83045501112effa Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Wed, 17 Jul 2024 13:26:54 +0200 Subject: [PATCH 1/6] [OU-ADD] website_sale_loyalty_delivery: Migration to version 16.0 TT49821 --- docsource/modules150-160.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 4ced534d58b..856f2ae125c 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -894,7 +894,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| website_sale_coupon | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |del| website_sale_coupon_delivery | | | +| |del| website_sale_coupon_delivery | Done |Renamed to website_sale_loyalty_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ | website_sale_delivery | Nothing to do |No DB layout changes. | +-------------------------------------------------+----------------------+-------------------------------------------------+ @@ -908,7 +908,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |new| website_sale_loyalty | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |new| website_sale_loyalty_delivery | | | +| |new| website_sale_loyalty_delivery | Done |Renamed from website_sale_coupon_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ | |new| website_sale_picking | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ From c8ed8370d480172fad8ec41e951be42c9b3e3c6e Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Thu, 18 Jul 2024 10:23:54 +0200 Subject: [PATCH 2/6] [OU-IMP] sale_loyalty_delivery: Adding information to the module coverage table --- docsource/modules150-160.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 856f2ae125c..5721fb3e9c2 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -682,7 +682,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| sale_coupon | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |del| sale_coupon_delivery | | | +| |del| sale_coupon_delivery | Done |Renamed to sale_loyalty_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ | sale_crm | Nothing to do | | +-------------------------------------------------+----------------------+-------------------------------------------------+ @@ -694,7 +694,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |new| sale_loyalty | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |new| sale_loyalty_delivery | | | +| |new| sale_loyalty_delivery | Done |Renamed from sale_coupon_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ | sale_management | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ From 8dc6bafd43ebcfe662d4e4588a0bb44240f1016c Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Thu, 18 Jul 2024 10:28:26 +0200 Subject: [PATCH 3/6] [OU-IMP] loyalty: Adding information to the module coverage table --- docsource/modules150-160.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 5721fb3e9c2..9c8e35f93e2 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -100,7 +100,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | contacts | Nothing to do |No DB layout changes. | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |del| coupon | | | +| |del| coupon | Done |Renamed to loyalty | +-------------------------------------------------+----------------------+-------------------------------------------------+ | crm | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ @@ -454,7 +454,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | link_tracker | Nothing to do |No DB layout changes. | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |new| loyalty | | | +| |new| loyalty | Done |Renamed from coupon | +-------------------------------------------------+----------------------+-------------------------------------------------+ | |new| loyalty_delivery | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ From f8eb983ec72805d59d04c2a8fa45725072664011 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Thu, 18 Jul 2024 10:30:15 +0200 Subject: [PATCH 4/6] [OU-IMP] sale_loyalty: Adding information to the module coverage table --- docsource/modules150-160.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 9c8e35f93e2..7d089f81c2b 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -680,7 +680,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | sale | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |del| sale_coupon | | | +| |del| sale_coupon | Done |Renamed to sale_loyalty | +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| sale_coupon_delivery | Done |Renamed to sale_loyalty_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ @@ -692,7 +692,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| sale_gift_card | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |new| sale_loyalty | | | +| |new| sale_loyalty | Done |Renamed from sale_coupon | +-------------------------------------------------+----------------------+-------------------------------------------------+ | |new| sale_loyalty_delivery | Done |Renamed from sale_coupon_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ From 2262c37538202416256eb552bde71599b941946d Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Thu, 18 Jul 2024 10:33:03 +0200 Subject: [PATCH 5/6] [OU-IMP] website_sale_loyalty: Adding information to the module coverage table --- docsource/modules150-160.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 7d089f81c2b..b3299e630af 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -892,7 +892,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | website_sale_comparison_wishlist | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |del| website_sale_coupon | | | +| |del| website_sale_coupon | Done |Renamed to website_sale_loyalty | +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| website_sale_coupon_delivery | Done |Renamed to website_sale_loyalty_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ @@ -906,7 +906,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| website_sale_gift_card | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| |new| website_sale_loyalty | | | +| |new| website_sale_loyalty | Done |Renamed from website_sale_coupon | +-------------------------------------------------+----------------------+-------------------------------------------------+ | |new| website_sale_loyalty_delivery | Done |Renamed from website_sale_coupon_delivery | +-------------------------------------------------+----------------------+-------------------------------------------------+ From ff2ee1c13c9b2e7bde1261f03de8a7b1e7a8ed2e Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Thu, 18 Jul 2024 11:23:18 +0200 Subject: [PATCH 6/6] [OU-FIX] sale_loyalty: Remove script that removes constraint This script is not necessary since both the table and the constraint are new in v16, it is only necessary to apply this restriction to the data dump in the new table by adding a condition that contemplates it. --- .../sale_loyalty/16.0.1.0/post-migration.py | 22 +++++++++++-------- .../sale_loyalty/16.0.1.0/pre-migration.py | 8 ------- .../16.0.1.0/upgrade_analysis_work.txt | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/post-migration.py b/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/post-migration.py index 2d66c16ff69..14abd4bcb23 100644 --- a/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/post-migration.py +++ b/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/post-migration.py @@ -80,15 +80,19 @@ def _generate_sale_order_coupon_points(env): coupon_id, order_id, points, create_uid, write_uid, create_date, write_date ) SELECT - id AS coupon_id, - order_id, - points, - create_uid, - write_uid, - create_date, - write_date - FROM loyalty_card - WHERE order_id IS NOT NULL; + lc.id AS coupon_id, + lc.order_id, + lc.points, + lc.create_uid, + lc.write_uid, + lc.create_date, + lc.write_date + FROM loyalty_card lc + LEFT JOIN sale_order_coupon_points socp + ON lc.order_id = socp.order_id + AND lc.id = socp.coupon_id + WHERE lc.order_id IS NOT NULL + AND socp.id IS NULL """, ) diff --git a/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/pre-migration.py index 7f4d126d71d..e742e224a4c 100644 --- a/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/pre-migration.py +++ b/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/pre-migration.py @@ -138,13 +138,6 @@ def update_sale_order_line_data(env): ) -def delete_sql_constraints(env): - # Delete constraints to recreate it - openupgrade.delete_sql_constraint_safely( - env, "sale_loyalty", "sale_order_coupon_points", "order_coupon_unique" - ) - - def update_template_keys(env): """Update template keys of the merged sale_gift_card module in loyalty_sale""" openupgrade.logged_query( @@ -178,5 +171,4 @@ def migrate(env, version): openupgrade.rename_xmlids(env.cr, _xmlids_renames) update_loyalty_program_data(env) update_sale_order_line_data(env) - delete_sql_constraints(env) update_template_keys(env) diff --git a/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/upgrade_analysis_work.txt index 028049ff17c..25525ef4fb3 100644 --- a/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/upgrade_analysis_work.txt @@ -91,7 +91,7 @@ DEL ir.model.access: sale_gift_card.access_gift_card_sales # NOTHING TO DO NEW ir.model.constraint: sale_loyalty.constraint_sale_order_coupon_points_order_coupon_unique -# DONE pre-migration: safely delete constraint to recreate it +# NOTHING TO DO DEL ir.rule: sale_coupon.sale_coupon_apply_code_rule (noupdate) # DONE: post-migration: safely deleted xmlid