Skip to content

Commit

Permalink
Merge pull request #4527 from Tecnativa/16.0-mig-website_sale_loyalty…
Browse files Browse the repository at this point in the history
…_delivery

[16.0][OU-ADD] website_sale_loyalty_delivery: Migration to version 16.0
  • Loading branch information
pedrobaeza authored Jul 20, 2024
2 parents 3061ff3 + ff2ee1c commit d21507c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
20 changes: 10 additions & 10 deletions docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down Expand Up @@ -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 | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down Expand Up @@ -680,9 +680,9 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| sale_coupon | | |
| |del| sale_coupon | Done |Renamed to sale_loyalty |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| sale_coupon_delivery | | |
| |del| sale_coupon_delivery | Done |Renamed to sale_loyalty_delivery |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_crm | Nothing to do | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand All @@ -692,9 +692,9 @@ 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 | | |
| |new| sale_loyalty_delivery | Done |Renamed from sale_coupon_delivery |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_management | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down Expand Up @@ -892,9 +892,9 @@ 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 | | |
| |del| website_sale_coupon_delivery | Done |Renamed to website_sale_loyalty_delivery |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| website_sale_delivery | Nothing to do |No DB layout changes. |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand All @@ -906,9 +906,9 @@ 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 | | |
| |new| website_sale_loyalty_delivery | Done |Renamed from website_sale_coupon_delivery |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |new| website_sale_picking | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
""",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d21507c

Please sign in to comment.