odoo-addon-openupgrade-scripts 16.0.1.0.3.306__py3-none-any.whl → 16.0.1.0.3.307__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.
@@ -137,6 +137,73 @@ def mail_channel_unset_wrong_group_public_id(env):
137
137
  )
138
138
 
139
139
 
140
+ def mail_channel_private_compatibility(env):
141
+ """In v15 you could set a private group that only members could access, now in v16
142
+ this is not possible.
143
+ Defining the group_public_id empty will make everyone can access, and leaving the
144
+ value that has group_public_id with 'base.group_user' by default is totally wrong.
145
+ In order to maintain the compatibility of the existing channels, two transformations
146
+ are necessary:
147
+ - If a channel is private, but had only one auto-subscription group (group_ids), those
148
+ group become the authorized one (group_public_id) of the channel, and it remains as such
149
+ as a channel, since at the end, the auto-subscription groups adds as members all the
150
+ users of those groups, acting in the same way.
151
+ - If the list of members was manual, then the channel becomes a 'Direct Messages'
152
+ (channel_type='group'), keeping the channel name and authorized members.
153
+ """
154
+ env.cr.execute(
155
+ """
156
+ SELECT
157
+ c.id,
158
+ c.name,
159
+ (
160
+ SELECT COUNT(res_groups_id)
161
+ FROM mail_channel_res_groups_rel
162
+ WHERE mail_channel_id = c.id
163
+ ) AS total_groups,
164
+ (
165
+ SELECT res_groups_id
166
+ FROM mail_channel_res_groups_rel
167
+ WHERE mail_channel_id = c.id
168
+ LIMIT 1
169
+ ) AS auto_subscribe_group_0
170
+ FROM mail_channel AS c
171
+ WHERE c.channel_type = 'channel' AND c.public = 'private'
172
+ """
173
+ )
174
+ for channel_id, _name, total_groups, auto_subscribe_group_0 in env.cr.fetchall():
175
+ if total_groups == 1:
176
+ openupgrade.logged_query(
177
+ env.cr,
178
+ """
179
+ UPDATE mail_channel
180
+ SET group_public_id = %s
181
+ WHERE id = %s
182
+ """,
183
+ (auto_subscribe_group_0, channel_id),
184
+ )
185
+ else:
186
+ # Remove the auto-subscription groups linked also to avoid
187
+ # _constraint_group_id_channel()
188
+ openupgrade.logged_query(
189
+ env.cr,
190
+ """
191
+ DELETE FROM mail_channel_res_groups_rel
192
+ WHERE mail_channel_id= %s
193
+ """,
194
+ (channel_id,),
195
+ )
196
+ openupgrade.logged_query(
197
+ env.cr,
198
+ """
199
+ UPDATE mail_channel
200
+ SET channel_type = 'group', group_public_id = NULL
201
+ WHERE id = %s
202
+ """,
203
+ (channel_id,),
204
+ )
205
+
206
+
140
207
  def scheduled_date_set_empty_strings_to_null(env):
141
208
  openupgrade.logged_query(
142
209
  env.cr,
@@ -161,3 +228,4 @@ def migrate(env, version):
161
228
  ir_act_server_rename_state_email(env)
162
229
  mail_channel_channel_type_required(env)
163
230
  scheduled_date_set_empty_strings_to_null(env)
231
+ mail_channel_private_compatibility(env)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: odoo-addon-openupgrade_scripts
3
- Version: 16.0.1.0.3.306
3
+ Version: 16.0.1.0.3.307
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)
@@ -361,7 +361,7 @@ odoo/addons/openupgrade_scripts/scripts/lunch/16.0.1.0/upgrade_analysis_work.txt
361
361
  odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/end-migration.py,sha256=aX9Xy1GJatSTyUgalaUkJ8OjZILAqJ2SI6KPXJAXXvg,2223
362
362
  odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/noupdate_changes.xml,sha256=8b74tz5LRJrf76AuyOTRIl4w3NvwHe9YivwafOnoBdU,1439
363
363
  odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/post-migration.py,sha256=npwS2ylEgDiqM-CY-XzYe1o2tkXCCo3lR_qNhQPCzKM,262
364
- odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/pre-migration.py,sha256=8Ca4PL5QlpLEvvNhCnKFbm-CTN_lOfKou9puegiUZgg,4699
364
+ odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/pre-migration.py,sha256=7xPNXcG-JIjOSMGLx-OZ0HIlr7raBM2niPZx6RCQf6I,7322
365
365
  odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/upgrade_analysis.txt,sha256=ev0yHLx23bmYinSh58rE9PJeF6PTwQHIThk9So-4uag,9744
366
366
  odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/upgrade_analysis_work.txt,sha256=igoXVrhgdF0vOlWxPgZeI91uFhJsH5OvUxHHl6hMA7E,11295
367
367
  odoo/addons/openupgrade_scripts/scripts/mail/16.0.1.10/tests/data.py,sha256=GU_Vcq1F4DWujCx3joNM4MvKAHSFt2b3vhwpbN7oYGo,332
@@ -723,7 +723,7 @@ odoo/addons/openupgrade_scripts/scripts/website_twitter/16.0.1.0/upgrade_analysi
723
723
  odoo/addons/openupgrade_scripts/static/description/banner.png,sha256=KTIBu4gfxeZVw9zjs_fivTgFEOeaAorlBxajmCA1p6k,26859
724
724
  odoo/addons/openupgrade_scripts/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
725
725
  odoo/addons/openupgrade_scripts/static/description/index.html,sha256=IOWtZdzr_jN_Dja8HYIfzIxrO8NE5pFgazKJtPsLKw0,12678
726
- odoo_addon_openupgrade_scripts-16.0.1.0.3.306.dist-info/METADATA,sha256=xzqLeEfcIJhFpZCesRhivODzZjzK3lEr9VIxnnKrYFI,3790
727
- odoo_addon_openupgrade_scripts-16.0.1.0.3.306.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
728
- odoo_addon_openupgrade_scripts-16.0.1.0.3.306.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
729
- odoo_addon_openupgrade_scripts-16.0.1.0.3.306.dist-info/RECORD,,
726
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.307.dist-info/METADATA,sha256=RHNmy7CLaEJfWmxG1MgHH2IVAujcNl7oPpcwRvoFAIc,3790
727
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.307.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
728
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.307.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
729
+ odoo_addon_openupgrade_scripts-16.0.1.0.3.307.dist-info/RECORD,,