odoo-addon-openupgrade-scripts 16.0.1.0.3.280__py3-none-any.whl → 16.0.1.0.3.289__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,6 +74,7 @@ merged_modules = {
74
74
  "pad_project": "project",
75
75
  "pos_coupon": "pos_loyalty",
76
76
  "pos_gift_card": "pos_loyalty",
77
+ "project_account": "project",
77
78
  "sale_gift_card": "sale_loyalty",
78
79
  "sale_project_account": "sale_project",
79
80
  "website_sale_delivery_giftcard": "website_sale_loyalty_delivery",
@@ -87,6 +88,8 @@ merged_modules = {
87
88
  "account_invoice_report_due_list": "account",
88
89
  # OCA/e-commerce
89
90
  "website_sale_require_login": "website_sale",
91
+ # OCA/partner-contact
92
+ "partner_company_group": "base_partner_company_group",
90
93
  # OCA/pos
91
94
  "pos_margin_account_invoice_margin": "point_of_sale",
92
95
  "pos_order_line_no_unlink": "point_of_sale",
@@ -624,7 +624,6 @@ def merge_gift_card_to_loyalty_card(env):
624
624
  WHERE lp.create_uid = gc.create_uid
625
625
  AND lp.create_date = gc.create_date
626
626
  AND lp.company_id = gc.company_id
627
- AND lp.currency_id = gc.currency_id
628
627
  AND lp.program_type = 'gift_card'
629
628
  )
630
629
  """,
@@ -653,7 +652,7 @@ def merge_gift_card_to_loyalty_card(env):
653
652
  create_uid,
654
653
  write_uid,
655
654
  code,
656
- expiration_date AS expired_date,
655
+ expired_date AS expiration_date,
657
656
  create_date,
658
657
  write_date,
659
658
  initial_amount AS points
@@ -661,6 +660,20 @@ def merge_gift_card_to_loyalty_card(env):
661
660
  """,
662
661
  )
663
662
  # Create records in loyalty_reward based on gift_card data
663
+ openupgrade.add_fields(
664
+ env,
665
+ [
666
+ (
667
+ "discount_product_domain",
668
+ "loyalty.reward",
669
+ "loyalty_reward",
670
+ "char",
671
+ False,
672
+ "loyalty",
673
+ "[]",
674
+ )
675
+ ],
676
+ )
664
677
  openupgrade.logged_query(
665
678
  env.cr,
666
679
  """
@@ -710,15 +723,15 @@ def merge_gift_card_to_loyalty_card(env):
710
723
  openupgrade.logged_query(
711
724
  env.cr,
712
725
  """
713
- INSERT INTO loyalty_rrule (
726
+ INSERT INTO loyalty_rule (
714
727
  program_id,
715
728
  company_id,
716
- minimun_qty,
729
+ minimum_qty,
717
730
  create_uid,
718
731
  write_uid,
719
732
  product_domain,
720
733
  reward_point_mode,
721
- minimun_amount_tax_mode,
734
+ minimum_amount_tax_mode,
722
735
  mode,
723
736
  active,
724
737
  reward_point_split,
@@ -762,7 +775,7 @@ def merge_gift_card_to_loyalty_card(env):
762
775
  JOIN gift_card gc ON gc.id = sol.gift_card_id
763
776
  WHERE gc.program_id = lc.program_id
764
777
  ) IS NOT NULL
765
- THEN lc.initial_amount - (
778
+ THEN gc.initial_amount - (
766
779
  SELECT SUM(ABS(sol.price_unit))
767
780
  FROM sale_order_line sol
768
781
  JOIN gift_card gc ON gc.id = sol.gift_card_id
@@ -793,4 +806,30 @@ def migrate(env, version):
793
806
  check_and_install_module_if_applicable(env)
794
807
  delete_sql_constraints(env)
795
808
  update_template_keys(env)
809
+
810
+ # Set default values
811
+ if not openupgrade.column_exists(env.cr, "loyalty_card", "expiration_date"):
812
+ openupgrade.add_fields(
813
+ env,
814
+ [
815
+ (
816
+ "expiration_date",
817
+ "loyalty.card",
818
+ "loyalty_card",
819
+ "date",
820
+ "date",
821
+ "loyalty",
822
+ False,
823
+ )
824
+ ],
825
+ )
826
+ openupgrade.logged_query(
827
+ env.cr,
828
+ """
829
+ UPDATE loyalty_card lc
830
+ SET expiration_date = lc.create_date + interval '1' day * lp.validity_duration
831
+ from loyalty_program lp
832
+ where lp.id = lc.program_id and lp.validity_duration > 0
833
+ """,
834
+ )
796
835
  merge_gift_card_to_loyalty_card(env)
@@ -0,0 +1,47 @@
1
+ # Copyright 2023 Tecnativa - Pilar Vargas
2
+ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
+ from openupgradelib import openupgrade
4
+
5
+ _deleted_xml_records = [
6
+ "sale_loyalty.sale_coupon_apply_code_rule",
7
+ ]
8
+
9
+
10
+ def convert_applied_coupons_from_sale_order_to_many2many(env):
11
+ openupgrade.logged_query(
12
+ env.cr,
13
+ """
14
+ INSERT INTO loyalty_card_sale_order_rel (sale_order_id, loyalty_card_id)
15
+ SELECT sales_order_id, id
16
+ FROM loyalty_card
17
+ WHERE sales_order_id IS NOT NULL
18
+ """,
19
+ )
20
+
21
+
22
+ def fill_code_enabled_rule_ids_from_sale_order(env):
23
+ """This field relates the id of a rule to the id of
24
+ a sales order to which it has been applied, provided that the rule belongs to an
25
+ applicable promotion with code."""
26
+ openupgrade.logged_query(
27
+ env.cr,
28
+ """
29
+ INSERT INTO loyalty_rule_sale_order_rel (sale_order_id, loyalty_rule_id)
30
+ SELECT lc.order_id, lr.id
31
+ FROM loyalty_card lc
32
+ JOIN loyalty_rule lr ON lc.program_id = lr.program_id
33
+ JOIN loyalty_program lp ON lr.program_id = lp.id
34
+ WHERE lr.mode = 'with_code'
35
+ """,
36
+ )
37
+
38
+
39
+ @openupgrade.migrate()
40
+ def migrate(env, version):
41
+ openupgrade.load_data(env.cr, "sale_loyalty", "16.0.1.0/noupdate_changes.xml")
42
+ openupgrade.delete_records_safely_by_xml_id(
43
+ env,
44
+ _deleted_xml_records,
45
+ )
46
+ convert_applied_coupons_from_sale_order_to_many2many(env)
47
+ fill_code_enabled_rule_ids_from_sale_order(env)
@@ -0,0 +1,255 @@
1
+ # Copyright 2023 Tecnativa - Pilar Vargas
2
+
3
+ import random
4
+
5
+ from openupgradelib import openupgrade
6
+
7
+ _xmlids_renames = [
8
+ (
9
+ "sale_loyalty.sale_coupon_apply_code_action",
10
+ "sale_loyalty.sale_loyalty_coupon_wizard_action",
11
+ ),
12
+ (
13
+ "sale_loyalty.menu_coupon_type_config",
14
+ "sale_loyalty.menu_discount_loyalty_type_config",
15
+ ),
16
+ (
17
+ "sale_loyalty.menu_promotion_type_config",
18
+ "sale_loyalty.menu_gift_ewallet_type_config",
19
+ ),
20
+ (
21
+ "sale_loyalty.sale_coupon_view_form",
22
+ "sale_loyalty.loyalty_card_view_form_inherit_sale_loyalty",
23
+ ),
24
+ (
25
+ "sale_loyalty.sale_coupon_apply_code_view_form",
26
+ "sale_loyalty.sale_loyalty_coupon_wizard_view_form",
27
+ ),
28
+ (
29
+ "sale_loyalty.sale_order_view_form",
30
+ "sale_loyalty.sale_order_view_form_inherit_sale_loyalty",
31
+ ),
32
+ ]
33
+
34
+
35
+ def _generate_random_reward_code():
36
+ """This function, _generate_random_reward_code, provides a random reward code. It is
37
+ used to create unique codes that identify rewards within the sale_loyalty module."""
38
+ return str(random.getrandbits(32))
39
+
40
+
41
+ def generate_sale_order_coupon_points(env):
42
+ openupgrade.logged_query(
43
+ env.cr,
44
+ """
45
+ CREATE TABLE IF NOT EXISTS sale_order_coupon_points (
46
+ coupon_id INT,
47
+ order_id INT,
48
+ points FLOAT,
49
+ create_uid INT,
50
+ write_uid INT,
51
+ create_date DATE,
52
+ write_date DATE
53
+ )
54
+ """,
55
+ )
56
+ openupgrade.logged_query(
57
+ env.cr,
58
+ """
59
+ INSERT INTO sale_order_coupon_points (
60
+ coupon_id, order_id, points, create_uid, write_uid, create_date, write_date
61
+ )
62
+ SELECT
63
+ id AS coupon_id,
64
+ order_id,
65
+ points,
66
+ create_uid,
67
+ write_uid,
68
+ create_date,
69
+ write_date
70
+ FROM loyalty_card
71
+ WHERE order_id IS NOT NULL;
72
+ """,
73
+ )
74
+
75
+
76
+ def update_loyalty_program_data(env):
77
+ # Set sale_ok default values
78
+ if not openupgrade.column_exists(env.cr, "loyalty_program", "sale_ok"):
79
+ openupgrade.add_fields(
80
+ env,
81
+ [
82
+ (
83
+ "sale_ok",
84
+ "loyalty.program",
85
+ "loyalty_program",
86
+ "boolean",
87
+ "bool",
88
+ "sale_loyalty",
89
+ True,
90
+ )
91
+ ],
92
+ )
93
+
94
+
95
+ def update_sale_order_line_data(env):
96
+ # Fill reward_id field
97
+ openupgrade.logged_query(
98
+ env.cr,
99
+ """
100
+ ALTER TABLE sale_order_line
101
+ ADD COLUMN IF NOT EXISTS reward_id INT
102
+ """,
103
+ )
104
+ openupgrade.logged_query(
105
+ env.cr,
106
+ """
107
+ UPDATE sale_order_line sol
108
+ SET reward_id = lr.id
109
+ FROM loyalty_reward lr
110
+ WHERE sol.product_id = lr.discount_line_product_id
111
+ """,
112
+ )
113
+ # Fill coupon_id field(env):
114
+ openupgrade.logged_query(
115
+ env.cr,
116
+ """
117
+ ALTER TABLE sale_order_line
118
+ ADD COLUMN IF NOT EXISTS coupon_id INT
119
+ """,
120
+ )
121
+ openupgrade.logged_query(
122
+ env.cr,
123
+ """
124
+ UPDATE sale_order_line
125
+ SET coupon_id = loyalty_card.id
126
+ FROM loyalty_card
127
+ WHERE sale_order_line.order_id = loyalty_card.sales_order_id
128
+ """,
129
+ )
130
+ # Fill reward_identifier_code
131
+ openupgrade.logged_query(
132
+ env.cr,
133
+ """
134
+ ALTER TABLE sale_order_line
135
+ ADD COLUMN IF NOT EXISTS reward_identifier_code VARCHAR
136
+ """,
137
+ )
138
+ env.cr.execute(
139
+ """
140
+ SELECT id
141
+ FROM sale_order_line
142
+ WHERE reward_id IS NOT NULL
143
+ """
144
+ )
145
+ order_lines = env.cr.fetchall()
146
+ # Update each order line with a unique reward code
147
+ for line in order_lines:
148
+ reward_code = _generate_random_reward_code()
149
+ env.cr.execute(
150
+ """
151
+ UPDATE sale_order_line
152
+ SET reward_identifier_code = %s
153
+ WHERE id = %s
154
+ """,
155
+ (reward_code, line[0]),
156
+ )
157
+ # Fill points_cost field
158
+ openupgrade.logged_query(
159
+ env.cr,
160
+ """
161
+ ALTER TABLE sale_order_line
162
+ ADD COLUMN IF NOT EXISTS points_cost FLOAT
163
+ """,
164
+ )
165
+ openupgrade.logged_query(
166
+ env.cr,
167
+ """
168
+ UPDATE sale_order_line
169
+ SET points_cost = ABS(untaxed_amount_to_invoice)
170
+ WHERE reward_id IS NOT NULL
171
+ AND untaxed_amount_to_invoice < 0
172
+ """,
173
+ )
174
+
175
+
176
+ def delete_sql_constraints(env):
177
+ # Delete constraints to recreate it
178
+ openupgrade.delete_sql_constraint_safely(
179
+ env, "sale_loyalty", "sale_order_coupon_points", "order_coupon_unique"
180
+ )
181
+
182
+
183
+ def update_template_keys(env):
184
+ """Update template keys of the merged sale_gift_card module in loyalty_sale"""
185
+ openupgrade.logged_query(
186
+ env.cr,
187
+ """
188
+ UPDATE ir_ui_view
189
+ SET key = 'sale_loyalty.used_gift_card'
190
+ WHERE key = 'sale_gift_card.used_gift_card'
191
+ """,
192
+ )
193
+ openupgrade.logged_query(
194
+ env.cr,
195
+ """
196
+ UPDATE ir_ui_view
197
+ SET key = 'sale_loyalty.sale_purchased_gift_card'
198
+ WHERE key = 'sale_gift_card.sale_purchased_gift_card'
199
+ """,
200
+ )
201
+ openupgrade.logged_query(
202
+ env.cr,
203
+ """
204
+ UPDATE ir_ui_view
205
+ SET key = 'sale_loyalty.sale_orde_portal_content_inherit'
206
+ WHERE key = 'sale_gift_card.sale_orde_portal_content_inherit'
207
+ """,
208
+ )
209
+
210
+
211
+ def merge_sale_gift_card_to_sale_loyalty_card(env):
212
+ # Update the coupon_id column in the sale_order_line table with the ID of the
213
+ # loyalty_card table based on certain criteria and relationships established between
214
+ # the loyalty_card, loyalty_reward and gift_card tables
215
+ # program_id is added to the gift_card table in the loyalty migration script.
216
+ if not openupgrade.table_exists(env.cr, "gift_card"):
217
+ return
218
+ openupgrade.logged_query(
219
+ env.cr,
220
+ """
221
+ UPDATE sale_order_line AS sol
222
+ SET coupon_id = lc.id
223
+ FROM loyalty_card AS lc
224
+ JOIN loyalty_reward AS lr ON lc.program_id = lr.program_id
225
+ JOIN gift_card AS gc ON lc.program_id = gc.program_id
226
+ WHERE sol.reward_id = lr.id
227
+ AND lr.program_id = lc.program_id
228
+ AND lc.program_id = gc.program_id
229
+ AND sol.gift_card_id = gc.id
230
+ AND sol.reward_id IS NOT NULL
231
+ """,
232
+ )
233
+ # Values corresponding to the order_id and coupon_id columns of the sale_order_line
234
+ # table where reward_id is not null and gift_card_id is not null
235
+ openupgrade.logged_query(
236
+ env.cr,
237
+ """
238
+ INSERT INTO loyalty_card_sale_order_rel (sale_order_id, loyalty_card_id)
239
+ SELECT sol.order_id, sol.coupon_id
240
+ FROM sale_order_line AS sol
241
+ WHERE sol.reward_id IS NOT NULL
242
+ AND sol.gift_card_id IS NOT NULL
243
+ """,
244
+ )
245
+
246
+
247
+ @openupgrade.migrate()
248
+ def migrate(env, version):
249
+ openupgrade.rename_xmlids(env.cr, _xmlids_renames)
250
+ generate_sale_order_coupon_points(env)
251
+ update_loyalty_program_data(env)
252
+ update_sale_order_line_data(env)
253
+ delete_sql_constraints(env)
254
+ update_template_keys(env)
255
+ merge_sale_gift_card_to_sale_loyalty_card(env)
@@ -0,0 +1,136 @@
1
+ ---Models in module 'sale_loyalty'---
2
+ obsolete model sale.coupon.apply.code (renamed to sale.loyalty.coupon.wizard) [transient]
3
+ new model sale.loyalty.coupon.wizard (renamed from sale.coupon.apply.code) [transient]
4
+ new model sale.loyalty.reward.wizard [transient]
5
+ # NOTHING TO DO: transient model
6
+
7
+ new model sale.order.coupon.points
8
+ # NOTHING TO DO: New model
9
+
10
+ ---Fields in module 'sale_loyalty'---
11
+ sale_coupon / coupon.coupon / sales_order_id (many2one) : DEL relation: sale.order
12
+ # NOTHING TO DO
13
+
14
+ sale_coupon / sale.order / applied_coupon_ids (one2many) : relation is now 'loyalty.card' ('coupon.coupon') [nothing to do]
15
+ sale_coupon / sale.order / applied_coupon_ids (one2many) : table is now 'loyalty_card_sale_order_rel' ('False')
16
+ sale_coupon / sale.order / applied_coupon_ids (one2many) : type is now 'many2many' ('one2many')
17
+ # DONE pre-migration: convert to many2many
18
+
19
+ sale_coupon / sale.order / code_promo_program_id (many2one): DEL relation: coupon.program
20
+ sale_coupon / sale.order / generated_coupon_ids (one2many): DEL relation: coupon.coupon
21
+ sale_coupon / sale.order / no_code_promo_program_ids (many2many): DEL relation: coupon.program
22
+ # NOTHING TO DO
23
+
24
+ sale_coupon / sale.order.line / is_reward_line (boolean) : not stored anymore
25
+ sale_coupon / sale.order.line / is_reward_line (boolean) : now a function
26
+ # NOTHING TO DO
27
+
28
+ sale_gift_card / gift.card / buy_line_id (many2one) : DEL relation: sale.order.line
29
+ sale_gift_card / gift.card / redeem_line_ids (one2many) : DEL relation: sale.order.line
30
+ # NOTHING TO DO
31
+
32
+ sale_gift_card / sale.order.line / generated_gift_card_ids (one2many): DEL relation: gift.card
33
+ sale_gift_card / sale.order.line / gift_card_id (many2one) : DEL relation: gift.card
34
+ # NOTHING TO DO
35
+
36
+ sale_loyalty / loyalty.program / sale_ok (boolean) : NEW hasdefault: default
37
+ # DONE pre-migration: set default value
38
+
39
+ sale_loyalty / sale.order / code_enabled_rule_ids (many2many): NEW relation: loyalty.rule
40
+ # DONE pre-migration: create relational table and fill
41
+
42
+ sale_loyalty / sale.order / coupon_point_ids (one2many) : NEW relation: sale.order.coupon.points
43
+ sale_loyalty / sale.order.coupon.points / coupon_id (many2one) : NEW relation: loyalty.card, required
44
+ sale_loyalty / sale.order.coupon.points / order_id (many2one) : NEW relation: sale.order, required
45
+ sale_loyalty / sale.order.coupon.points / points (float) : NEW required
46
+ # DONE: pre-migration: create table and fill value
47
+
48
+ sale_loyalty / sale.order.line / coupon_id (many2one) : NEW relation: loyalty.card
49
+ sale_loyalty / sale.order.line / points_cost (float) : NEW
50
+ sale_loyalty / sale.order.line / reward_id (many2one) : NEW relation: loyalty.reward
51
+ sale_loyalty / sale.order.line / reward_identifier_code (char) : NEW
52
+ # DONE pre-migration: fill in data
53
+
54
+ ---XML records in module 'sale_loyalty'---
55
+ DEL ir.actions.act_window: sale_coupon.sale_coupon_apply_code_action
56
+ NEW ir.actions.act_window: sale_loyalty.sale_loyalty_coupon_wizard_action
57
+ # DONE pre-migration: rename xmlid
58
+
59
+ NEW ir.actions.act_window: sale_loyalty.sale_loyalty_reward_wizard_action
60
+ DEL ir.actions.act_window: sale_coupon.sale_order_action
61
+ DEL ir.actions.act_window: sale_gift_card.gift_card_sale_order_action
62
+ # NOTHING TO DO
63
+
64
+ NEW ir.model.access: sale_loyalty.access_applicability_manager [renamed from sale_coupon module]
65
+ NEW ir.model.access: sale_loyalty.access_applicability_salesman [renamed from sale_coupon module]
66
+ NEW ir.model.access: sale_loyalty.access_communication_manager
67
+ NEW ir.model.access: sale_loyalty.access_communication_salesman
68
+ NEW ir.model.access: sale_loyalty.access_coupon_manager [renamed from sale_coupon module]
69
+ NEW ir.model.access: sale_loyalty.access_coupon_salesman [renamed from sale_coupon module]
70
+ NEW ir.model.access: sale_loyalty.access_program_manager [renamed from sale_coupon module]
71
+ NEW ir.model.access: sale_loyalty.access_program_salesman [renamed from sale_coupon module]
72
+ NEW ir.model.access: sale_loyalty.access_reward_manager [renamed from sale_coupon module]
73
+ NEW ir.model.access: sale_loyalty.access_reward_salesman [renamed from sale_coupon module]
74
+ NEW ir.model.access: sale_loyalty.access_sale_coupon_apply_code [renamed from sale_coupon module]
75
+ NEW ir.model.access: sale_loyalty.access_sale_coupon_apply_code_line
76
+ NEW ir.model.access: sale_loyalty.access_sale_coupon_generate
77
+ NEW ir.model.access: sale_loyalty.access_sale_order_coupon_points_manager
78
+ NEW ir.model.access: sale_loyalty.access_sale_order_coupon_points_salesman
79
+ DEL ir.model.access: sale_coupon.access_applicability_manager [renamed to sale_loyalty module]
80
+ DEL ir.model.access: sale_coupon.access_applicability_salesman [renamed to sale_loyalty module]
81
+ DEL ir.model.access: sale_coupon.access_coupon_manager [renamed to sale_loyalty module]
82
+ DEL ir.model.access: sale_coupon.access_coupon_salesman [renamed to sale_loyalty module]
83
+ DEL ir.model.access: sale_coupon.access_program_manager [renamed to sale_loyalty module]
84
+ DEL ir.model.access: sale_coupon.access_program_salesman [renamed to sale_loyalty module]
85
+ DEL ir.model.access: sale_coupon.access_reward_manager [renamed to sale_loyalty module]
86
+ DEL ir.model.access: sale_coupon.access_reward_salesman [renamed to sale_loyalty module]
87
+ DEL ir.model.access: sale_coupon.access_sale_coupon_apply_code [renamed to sale_loyalty module]
88
+ DEL ir.model.access: sale_coupon.access_sale_coupon_generate [renamed to pos_loyalty module]
89
+ DEL ir.model.access: sale_gift_card.access_gift_card_manager
90
+ DEL ir.model.access: sale_gift_card.access_gift_card_sales
91
+ # NOTHING TO DO
92
+
93
+ NEW ir.model.constraint: sale_loyalty.constraint_sale_order_coupon_points_order_coupon_unique
94
+ # DONE pre-migration: safely delete constraint to recreate it
95
+
96
+ DEL ir.rule: sale_coupon.sale_coupon_apply_code_rule (noupdate)
97
+ # DONE: post-migration: safely deleted xmlid
98
+
99
+ NEW ir.ui.menu: sale_loyalty.menu_discount_loyalty_type_config
100
+ NEW ir.ui.menu: sale_loyalty.menu_gift_ewallet_type_config
101
+ DEL ir.ui.menu: sale_coupon.menu_coupon_type_config
102
+ DEL ir.ui.menu: sale_coupon.menu_promotion_type_config
103
+ # DONE pre-migration: rename xmlid
104
+
105
+ NEW ir.ui.view: sale_loyalty.loyalty_card_view_form_inherit_sale_loyalty
106
+ DEL ir.ui.view: sale_coupon.sale_coupon_view_form
107
+ NEW ir.ui.view: sale_loyalty.sale_loyalty_coupon_wizard_view_form
108
+ DEL ir.ui.view: sale_coupon.sale_coupon_apply_code_view_form
109
+ NEW ir.ui.view: sale_loyalty.sale_order_view_form_inherit_sale_loyalty
110
+ DEL ir.ui.view: sale_coupon.sale_order_view_form
111
+ # DONE pre-migration: rename xmlid
112
+
113
+ NEW ir.ui.view: sale_loyalty.loyalty_program_view_form_inherit_sale_loyalty
114
+ NEW ir.ui.view: sale_loyalty.sale_loyalty_reward_wizard_view_form
115
+ NEW ir.ui.view: sale_loyalty.sale_order_portal_content_inherit
116
+ NEW ir.ui.view: sale_loyalty.sale_purchased_gift_card
117
+ NEW ir.ui.view: sale_loyalty.used_gift_card
118
+ DEL ir.ui.view: sale_coupon.res_config_settings_view_form
119
+ DEL ir.ui.view: sale_coupon.sale_coupon_program_view_coupon_program_form
120
+ DEL ir.ui.view: sale_coupon.sale_coupon_program_view_promo_program_form
121
+ DEL ir.ui.view: sale_coupon.sale_coupon_view_coupon_program_kanban
122
+ DEL ir.ui.view: sale_coupon.sale_coupon_view_tree
123
+ DEL ir.ui.view: sale_gift_card.sale_gift_card_view_form
124
+ DEL ir.ui.view: sale_gift_card.sale_order_view_extend_gift_card_form
125
+ # NOTHING TO DO
126
+
127
+ DEL ir.ui.view: sale_gift_card.used_gift_card
128
+ DEL ir.ui.view: sale_gift_card.sale_purchased_gift_card
129
+ DEL ir.ui.view: sale_gift_card.sale_order_portal_content_inherit
130
+ # DONE pre-migration: update template keys
131
+
132
+ DEL mail.template: sale_coupon.mail_template_sale_coupon (noupdate)
133
+ # NOTHING TO DO: renamed in loyalty module
134
+
135
+ DEL mail.template: sale_gift_card.mail_template_gift_card [renamed to loyalty module]
136
+ # NOTHING TO DO
@@ -0,0 +1,38 @@
1
+ # Copyright 2024 Tecnativa - Pilar Vargas
2
+ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
+ from openupgradelib import openupgrade
4
+
5
+ _column_copy = {
6
+ "loyalty_reward": [
7
+ ("reward_type", None, None),
8
+ ],
9
+ }
10
+
11
+
12
+ def check_for_free_shipping_promotions(env):
13
+ """
14
+ Since the values of the selection reward_type field only change in the
15
+ sale_loyalty_delivery module, a copy of the column will only be made in case there
16
+ is a free delivery promotion. In case of such a promotion, a copy of the column will
17
+ be made to preserve the data and the relevant data will be modified.
18
+ """
19
+ env.cr.execute(
20
+ """
21
+ SELECT 1 FROM loyalty_reward WHERE reward_type = 'free_shipping'
22
+ """,
23
+ )
24
+ has_free_shipping = env.cr.rowcount
25
+ if has_free_shipping:
26
+ openupgrade.copy_columns(env.cr, _column_copy)
27
+ openupgrade.map_values(
28
+ env.cr,
29
+ openupgrade.get_legacy_name("reward_type"),
30
+ "reward_type",
31
+ [("free_shipping", "shipping")],
32
+ table="loyalty_reward",
33
+ )
34
+
35
+
36
+ @openupgrade.migrate()
37
+ def migrate(env, version):
38
+ check_for_free_shipping_promotions(env)
@@ -0,0 +1,103 @@
1
+ # Copyright 2023 Tecnativa - Pilar Vargas
2
+ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
+ from openupgradelib import openupgrade
4
+
5
+ _xmlids_renames = [
6
+ (
7
+ "website_sale_loyalty.coupon_view_tree",
8
+ "website_sale_loyalty.loyalty_card_view_tree_inherit_website_sale_loyalty",
9
+ ),
10
+ (
11
+ "website_sale_loyalty.res_config_settings_view_form",
12
+ "website_sale_loyalty.res_config_settings_view_form_inherit_website_sale_loyalty",
13
+ ),
14
+ (
15
+ "website_sale_loyalty.menu_promotion_type_config",
16
+ "website_sale_loyalty.menu_discount_loyalty_type_config",
17
+ ),
18
+ (
19
+ "website_sale_loyalty.menu_coupon_type_config",
20
+ "website_sale_loyalty.menu_gift_ewallet_type_config",
21
+ ),
22
+ ]
23
+ _key_updates = [
24
+ ("website_sale_coupon.cart_discount", "website_sale_loyalty.cart_discount"),
25
+ ("website_sale_coupon.cart_summary", "website_sale_loyalty.cart_summary"),
26
+ ("website_sale_coupon.layout", "website_sale_loyalty.layout"),
27
+ ("website_sale_coupon.sale_coupon_result", "website_sale_loyalty.modify_code_form"),
28
+ (
29
+ "website_sale_coupon.website_sale_coupon_cart_hide_qty",
30
+ "website_sale_loyalty.website_sale_coupon_cart_hide_qty",
31
+ ),
32
+ (
33
+ "website_sale_coupon.reduction_coupon_code",
34
+ "website_sale_loyalty.reduction_coupon_code",
35
+ ),
36
+ (
37
+ "website_sale_gift_card.cart_line_product_no_link",
38
+ "website_sale_loyalty.cart_line_product_no_link",
39
+ ),
40
+ (
41
+ "website_sale_gift_card.cart_summary_inherit_website_gift_card_sale",
42
+ "website_sale_loyalty.cart_summary_inherit_website_gift_card_sale",
43
+ ),
44
+ (
45
+ "website_sale_gift_card.website_sale_purchased_gift_card",
46
+ "website_sale_loyalty.website_sale_purchased_gift_card",
47
+ ),
48
+ ]
49
+
50
+
51
+ def update_loyalty_program_data(env):
52
+ openupgrade.logged_query(
53
+ env.cr,
54
+ """
55
+ ALTER TABLE loyalty_program
56
+ ADD COLUMN IF NOT EXISTS ecommerce_ok BOOLEAN
57
+ """,
58
+ )
59
+ # By default ecommerce_ok is true
60
+ openupgrade.logged_query(
61
+ env.cr,
62
+ """
63
+ UPDATE loyalty_program
64
+ SET ecommerce_ok = true
65
+ """,
66
+ )
67
+
68
+
69
+ def update_loyalty_rule_data(env):
70
+ openupgrade.logged_query(
71
+ env.cr,
72
+ """
73
+ ALTER TABLE loyalty_rule
74
+ ADD COLUMN IF NOT EXISTS website_id INT
75
+ """,
76
+ )
77
+ # Default is NULL (all websites) except for records coming from the merger of
78
+ # website_sale_gift_card into website_sale_loyalty which may have a website defined.
79
+ openupgrade.logged_query(
80
+ env.cr,
81
+ """
82
+ UPDATE loyalty_rule AS lr
83
+ SET website_id = gc.website_id
84
+ FROM gift_card AS gc
85
+ WHERE lr.program_id = gc.program_id
86
+ """,
87
+ )
88
+
89
+
90
+ def update_template_keys(env, _key_updates):
91
+ for old_key, new_key in _key_updates:
92
+ openupgrade.logged_query(
93
+ env.cr,
94
+ "UPDATE ir_ui_view SET key = %s WHERE key = %s",
95
+ (new_key, old_key),
96
+ )
97
+
98
+
99
+ @openupgrade.migrate()
100
+ def migrate(env, version):
101
+ update_loyalty_program_data(env)
102
+ update_template_keys(env, _key_updates)
103
+ openupgrade.rename_xmlids(env.cr, _xmlids_renames)
@@ -0,0 +1,64 @@
1
+ ---Models in module 'website_sale_loyalty'---
2
+ ---Fields in module 'website_sale_loyalty'---
3
+ website_sale_gift_card / gift.card / website_id (many2one) : DEL relation: website
4
+ website_sale_loyalty / loyalty.program / ecommerce_ok (boolean) : NEW hasdefault: default
5
+ website_sale_loyalty / loyalty.rule / website_id (many2one) : NEW relation: website, isrelated: related, stored
6
+ # DONE pre-migration: fill in field data
7
+
8
+ website_sale_loyalty / sale.order / disabled_auto_rewards (many2many): NEW relation: loyalty.reward
9
+ # NOTHING TO DO
10
+
11
+ ---XML records in module 'website_sale_loyalty'---
12
+ NEW ir.model.access: website_sale_loyalty.access_coupon_share_manager
13
+ DEL ir.model.access: website_sale_coupon.access_coupon_share
14
+ # NOTHING TO DO
15
+
16
+ NEW ir.ui.menu: website_sale_loyalty.menu_discount_loyalty_type_config
17
+ DEL ir.ui.menu: website_sale_coupon.menu_promotion_type_config
18
+ NEW ir.ui.menu: website_sale_loyalty.menu_gift_ewallet_type_config
19
+ DEL ir.ui.menu: website_sale_coupon.menu_coupon_type_config
20
+ # DONE pre-migration: rename xmlids
21
+
22
+ NEW ir.ui.menu: website_sale_loyalty.menu_loyalty
23
+ DEL ir.ui.menu: website_sale_gift_card.website_product_gift_card_menu
24
+ # NOTHING TO DO
25
+
26
+ NEW ir.ui.view: website_sale_loyalty.cart_discount
27
+ NEW ir.ui.view: website_sale_loyalty.cart_summary
28
+ NEW ir.ui.view: website_sale_loyalty.layout
29
+ NEW ir.ui.view: website_sale_loyalty.modify_code_form
30
+ NEW ir.ui.view: website_sale_loyalty.website_sale_coupon_cart_hide_qty
31
+ NEW ir.ui.view: website_sale_loyalty.reduction_coupon_code
32
+ NEW ir.ui.view: website_sale_loyalty.cart_line_product_no_link
33
+ NEW ir.ui.view: website_sale_loyalty.cart_summary_inherit_website_gift_card_sale
34
+ NEW ir.ui.view: website_sale_loyalty.website_sale_purchased_gift_card
35
+ DEL ir.ui.view: website_sale_coupon.cart_discount
36
+ DEL ir.ui.view: website_sale_coupon.cart_summary
37
+ DEL ir.ui.view: website_sale_coupon.layout
38
+ DEL ir.ui.view: website_sale_coupon.reduction_coupon_code
39
+ DEL ir.ui.view: website_sale_coupon.sale_coupon_result
40
+ DEL ir.ui.view: website_sale_coupon.website_sale_coupon_cart_hide_qty
41
+ DEL ir.ui.view: website_sale_gift_card.cart_line_product_no_link
42
+ DEL ir.ui.view: website_sale_gift_card.cart_summary_inherit_website_gift_card_sale
43
+ DEL ir.ui.view: website_sale_gift_card.website_sale_purchased_gift_card
44
+ # DONE pre-migration: update template keys
45
+
46
+ NEW ir.ui.view: website_sale_loyalty.loyalty_card_view_tree_inherit_website_sale_loyalty
47
+ NEW ir.ui.view: website_sale_loyalty.res_config_settings_view_form_inherit_website_sale_loyalty
48
+ DEL ir.ui.view: website_sale_coupon.coupon_view_tree
49
+ DEL ir.ui.view: website_sale_coupon.res_config_settings_view_form
50
+ # DONE pre-migration: rename xmlids
51
+
52
+ NEW ir.ui.view: website_sale_loyalty.coupon_share_view_form
53
+ NEW ir.ui.view: website_sale_loyalty.loyalty_program_view_form_inherit_website_sale_loyalty
54
+ NEW ir.ui.view: website_sale_loyalty.loyalty_program_view_tree_inherit_website_sale_loyalty
55
+ NEW ir.ui.view: website_sale_loyalty.sale_coupon_result
56
+ NEW ir.ui.view: website_sale_loyalty.snippet_options
57
+ DEL ir.ui.view: website_sale_coupon.coupon_share_view_form
58
+ DEL ir.ui.view: website_sale_coupon.sale_coupon_program_view_form_common_website
59
+ DEL ir.ui.view: website_sale_coupon.sale_coupon_program_view_tree_website
60
+ DEL ir.ui.view: website_sale_gift_card.add_gift_card
61
+ DEL ir.ui.view: website_sale_gift_card.gift_card_view_form
62
+ DEL ir.ui.view: website_sale_gift_card.gift_card_view_search
63
+ DEL ir.ui.view: website_sale_gift_card.pay_with_gift_card_form
64
+ # NOTHING TO DO
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: odoo-addon-openupgrade_scripts
3
- Version: 16.0.1.0.3.280
3
+ Version: 16.0.1.0.3.289
4
4
  Summary: Module that contains all the migrations analysis and scripts for migrate Odoo SA modules.
5
5
  Home-page: https://github.com/OCA/OpenUpgrade
6
6
  Author: Odoo Community Association (OCA)
@@ -1,7 +1,7 @@
1
1
  odoo/addons/openupgrade_scripts/README.rst,sha256=tNIgN-fE7UT1K-zMaK80ewZZOUaxzqYgufpYk2PHckU,3185
2
2
  odoo/addons/openupgrade_scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  odoo/addons/openupgrade_scripts/__manifest__.py,sha256=pE4R-JQdRitStZ2m2AN39foAoEfLWmwuL9nhHP1i3r8,614
4
- odoo/addons/openupgrade_scripts/apriori.py,sha256=Jp-XBW1C8sro2a94JguevXgqh2jp3tjbUh4CsvLpSSs,5607
4
+ odoo/addons/openupgrade_scripts/apriori.py,sha256=AIYCBWUoV0lRrH__wqtEtOSinhSFLRWEAAYlOb9he1s,5726
5
5
  odoo/addons/openupgrade_scripts/readme/CONFIGURE.rst,sha256=cy1swpDkuqi9-6q8L1M1QD058QyfBvAE2PN_mmdxvwI,255
6
6
  odoo/addons/openupgrade_scripts/readme/DESCRIPTION.rst,sha256=ckrM5YlY8awluPWIV7WOBynTOG_QKOjXrCsXD_RhmyU,86
7
7
  odoo/addons/openupgrade_scripts/readme/INSTALL.rst,sha256=tXbOmw3QIhO1KLIziMpXzuuY0tOhI8IGT2ktCArwfGM,115
@@ -352,7 +352,7 @@ odoo/addons/openupgrade_scripts/scripts/l10n_vn/16.0.2.0.1/upgrade_analysis.txt,
352
352
  odoo/addons/openupgrade_scripts/scripts/l10n_za/16.0.1.0/upgrade_analysis.txt,sha256=-rQO3Wi0H1nDy8cjmJOl_yo6IgOxMhm6f4FHP31Qs4g,1739
353
353
  odoo/addons/openupgrade_scripts/scripts/link_tracker/16.0.1.1/upgrade_analysis.txt,sha256=Ph-CuEBHU1WnRHswlXmC4YvE1LOo-0EpydbqIJ4VBSU,159
354
354
  odoo/addons/openupgrade_scripts/scripts/loyalty/16.0.1.0/post-migration.py,sha256=XP28cFyPCipISepMu7e2nrSp--vPvoJARj5fr8M86ig,1963
355
- odoo/addons/openupgrade_scripts/scripts/loyalty/16.0.1.0/pre-migration.py,sha256=lgNThpg84E_fWkQdaC9qW2DuEUsDMvSyOXCZT6PaeFE,23021
355
+ odoo/addons/openupgrade_scripts/scripts/loyalty/16.0.1.0/pre-migration.py,sha256=P3qrMNAVByN0ezDDXsmhwk9M4J6wySWfZYmYGcKEZpQ,24055
356
356
  odoo/addons/openupgrade_scripts/scripts/loyalty/16.0.1.0/upgrade_analysis.txt,sha256=N2waWK_WAcEsvrjG2mgGAVb4WLl76tVH7oU880Ei2mk,14561
357
357
  odoo/addons/openupgrade_scripts/scripts/loyalty/16.0.1.0/upgrade_analysis_work.txt,sha256=CW3VLkf5gsTyuA_YHUeqxDKSyuXn5x5MBuMz8FYOuKY,11368
358
358
  odoo/addons/openupgrade_scripts/scripts/loyalty_delivery/16.0.1.0/upgrade_analysis.txt,sha256=8TnNXqdMPDyxBHuN4C6DaxijUWSLag4XVe15HbTg4BI,419
@@ -541,7 +541,11 @@ odoo/addons/openupgrade_scripts/scripts/sale_expense/16.0.1.0/upgrade_analysis.t
541
541
  odoo/addons/openupgrade_scripts/scripts/sale_expense/16.0.1.0/upgrade_analysis_work.txt,sha256=DmrK92lmPdYQB-pJP0_8i9ozThLVJogDTDBcyZ6WXFU,587
542
542
  odoo/addons/openupgrade_scripts/scripts/sale_expense_margin/16.0.1.0/upgrade_analysis.txt,sha256=gabpy2-wJy26_KlOM7Uz_e08g2b0cOLYN-J-beuCyrQ,246
543
543
  odoo/addons/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/noupdate_changes.xml,sha256=zw3hSulldqaK5T1tq4zS6yBkJYZDAJLkd19r2uNgBKM,298
544
+ odoo/addons/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/post-migration.py,sha256=1gAPGADAmiWI5NuDGE2jpjgF2BjDiKQ8hNDvgoqPkfU,1508
545
+ odoo/addons/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/pre-migration.py,sha256=TF4i0ilzK1ThtLXsepbzSJZhQx-SdfuUeTCzaBdR3ZQ,7270
544
546
  odoo/addons/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/upgrade_analysis.txt,sha256=VWql2XMcz2AZ1FHQSCzNY8l9Zy11El0CbNOjAT3UEzk,7202
547
+ odoo/addons/openupgrade_scripts/scripts/sale_loyalty/16.0.1.0/upgrade_analysis_work.txt,sha256=wf_RFWboON8nx71Gj7PfmFHONbzbYNc868SsSDsYFE4,7950
548
+ odoo/addons/openupgrade_scripts/scripts/sale_loyalty_delivery/16.0.1.0/pre-migration.py,sha256=ZZyj0sWEVwjqRZp9qUjuIKloekIKuvR_HiuSFKrGcAs,1192
545
549
  odoo/addons/openupgrade_scripts/scripts/sale_management/16.0.1.0/noupdate_changes.xml,sha256=Rgdg_QBdM_ThLWLyCbtjjzWTP0Uvsr3dWIZ2yBWjWBY,1288
546
550
  odoo/addons/openupgrade_scripts/scripts/sale_management/16.0.1.0/post-migration.py,sha256=kD1YbnzClCxEXmnqwbQ7lcDaTYX7fmAeDc-bV82qAWU,280
547
551
  odoo/addons/openupgrade_scripts/scripts/sale_management/16.0.1.0/upgrade_analysis.txt,sha256=qtzBsyh6j5baE5egu7PAULT1wA9gTef7Q_QA4EEArFA,215
@@ -692,6 +696,8 @@ odoo/addons/openupgrade_scripts/scripts/website_sale_delivery/16.0.1.0/upgrade_a
692
696
  odoo/addons/openupgrade_scripts/scripts/website_sale_delivery_mondialrelay/16.0.0.1/upgrade_analysis.txt,sha256=BCxNxJ48VdYt5bV337TfePuo0MN-uhhRUqYwC-bPp0c,433
693
697
  odoo/addons/openupgrade_scripts/scripts/website_sale_digital/16.0.0.1/upgrade_analysis.txt,sha256=ow2g8lrO5k51Ec1gCFTG5_8D9pnfJAzxeVyk5au2qiA,183
694
698
  odoo/addons/openupgrade_scripts/scripts/website_sale_digital/16.0.0.1/upgrade_analysis_work.txt,sha256=9xGa08jnG6Dce9tsHCeCKpNn_IkfOqd7pRLQLXyWZZg,199
699
+ odoo/addons/openupgrade_scripts/scripts/website_sale_loyalty/16.0.1.0/pre-migration.py,sha256=B8UqYnXRc4q_sngrz4q4xaphQhMVoujZs3CFokvB1M4,3204
700
+ odoo/addons/openupgrade_scripts/scripts/website_sale_loyalty/16.0.1.0/upgrade_analysis work.txt,sha256=CjFFJqIdgiYbY9LWvyjEhFJurr7ElIX2qAgp_2vxH1s,3535
695
701
  odoo/addons/openupgrade_scripts/scripts/website_sale_loyalty/16.0.1.0/upgrade_analysis.txt,sha256=M753BVZ9F-ZP039qyWr2V8SMeehrt8iizS0T-cwNVmU,3308
696
702
  odoo/addons/openupgrade_scripts/scripts/website_sale_picking/16.0.1.0/upgrade_analysis.txt,sha256=TUeJygEuVPq6CRW7o-1WlNj-ytg3qMwvIrn1GSLjJK4,1075
697
703
  odoo/addons/openupgrade_scripts/scripts/website_sale_product_configurator/16.0.0.1/upgrade_analysis.txt,sha256=AoU15nW3TnH5g6D1uusr9M5j0rUdG0rsHxfwTgML3D4,350
@@ -714,7 +720,7 @@ odoo/addons/openupgrade_scripts/scripts/website_twitter/16.0.1.0/upgrade_analysi
714
720
  odoo/addons/openupgrade_scripts/static/description/banner.png,sha256=KTIBu4gfxeZVw9zjs_fivTgFEOeaAorlBxajmCA1p6k,26859
715
721
  odoo/addons/openupgrade_scripts/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
716
722
  odoo/addons/openupgrade_scripts/static/description/index.html,sha256=IOWtZdzr_jN_Dja8HYIfzIxrO8NE5pFgazKJtPsLKw0,12678
717
- odoo_addon_openupgrade_scripts-16.0.1.0.3.280.dist-info/METADATA,sha256=k1b7o8KT70Kb6RP472AbUdU6anJIBEjUy22NpZQficY,3790
718
- odoo_addon_openupgrade_scripts-16.0.1.0.3.280.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
719
- odoo_addon_openupgrade_scripts-16.0.1.0.3.280.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
720
- odoo_addon_openupgrade_scripts-16.0.1.0.3.280.dist-info/RECORD,,
723
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.289.dist-info/METADATA,sha256=Kos6vQDOVNNV2ECXtluFgkVJXyHA-UZ3cSdR_h88Odo,3790
724
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.289.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
725
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.289.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
726
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.289.dist-info/RECORD,,