Skip to content

Commit

Permalink
[OU-FIX] sale_loyalty: Remove script that removes constraint
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pilarvargas-tecnativa committed Jul 19, 2024
1 parent 2262c37 commit ff2ee1c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
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 ff2ee1c

Please sign in to comment.