@@ -156,17 +156,19 @@ def translation2jsonb_all_missing(cr):
156
156
157
157
:return: Converted fields.
158
158
"""
159
+ if not util .version_gte ("16.0" ):
160
+ raise UpgradeError ("JSONB translations are only available from Odoo 16" )
159
161
_env = env (cr )
160
162
fields = []
161
163
cr .execute (
162
164
"""
163
- SELECT STRING_TO_ARRAY(name, ','), ARRAY_AGG(DISTINCT lang)
164
- FROM _ir_translation
165
- WHERE
166
- type IN ('model', 'model_terms')
167
- AND name LIKE '%,%'
168
- AND lang != 'en_US'
169
- GROUP BY name
165
+ SELECT STRING_TO_ARRAY(name, ','),
166
+ ARRAY_AGG(DISTINCT lang)
167
+ FROM _ir_translation
168
+ WHERE type IN ('model', 'model_terms')
169
+ AND name LIKE '%,%'
170
+ AND lang != 'en_US'
171
+ GROUP BY name
170
172
"""
171
173
)
172
174
for (mname , fname ), langs in cr .fetchall ():
@@ -186,10 +188,8 @@ def translation2jsonb_all_missing(cr):
186
188
continue
187
189
# Check if the field is already converted
188
190
cr .execute (
189
- sql .SQL ("SELECT 1 FROM {} WHERE {} ?| %s LIMIT 1" ).format (
190
- sql .Identifier (model ._table ), sql .Identifier (fname )
191
- ),
192
- (langs ,),
191
+ format_query (cr , "SELECT 1 FROM {} WHERE {} ?| %s LIMIT 1" , model ._table , fname ),
192
+ [langs ],
193
193
)
194
194
if not cr .rowcount :
195
195
fields .append (field )
@@ -205,6 +205,8 @@ def translation2jsonb(cr, *fields):
205
205
:param odoo.fields.Field fields: Fields to convert.
206
206
:return: Converted fields.
207
207
"""
208
+ if not util .version_gte ("16.0" ):
209
+ ...
208
210
all_cleanup_queries = []
209
211
for field in fields :
210
212
_logger .info ("Migrating translations for field %s in model %s" , field .name , field .model_name )
0 commit comments