Skip to content

Commit 87c3e7e

Browse files
committed
[FIX] util.convert_field_to_translatable
Make the function idempotent. It was silently break the translations. ``` ❯ psql -d test-19 -c 'select name from res_country where id=1;' ┌──────────────────────┐ │ name │ ├──────────────────────┤ │ {"en_US": "Andorra"} │ └──────────────────────┘ (1 row) Time: 1.353 ms ❯ ./odoo-bin shell --upgrade-path ../../upgrade-util/src -d test-19 --log-handler=:CRITICAL env: <odoo.orm.environments.Environment object at 0x1134feda0> odoo: <module 'odoo' (<_frozen_importlib_external._NamespaceLoader object at 0x10e171060>)> openerp: <module 'odoo' (<_frozen_importlib_external._NamespaceLoader object at 0x10e171060>)> self: res.users(1,) In [1]: from odoo.upgrade import util In [2]: util.convert_field_to_translatable(env.cr, "res.country", "name") In [3]: env.cr.commit() In [4]: Do you really want to exit ([y]/n)? ^D ❯ psql -d test-19 -c 'select name from res_country where id=1;' ┌─────────────────────────────────┐ │ name │ ├─────────────────────────────────┤ │ {"en_US": {"en_US": "Andorra"}} │ └─────────────────────────────────┘ (1 row) Time: 1.360 ms ❯ ``` closes #329 Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
1 parent c985898 commit 87c3e7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/util/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ def _extract_data_as_attachment(cr, model, field, encoded=True, name_field=None,
10811081
def convert_field_to_translatable(cr, model, field):
10821082
table = table_of_model(cr, model)
10831083
ctype = column_type(cr, table, field)
1084-
if not ctype or ctype == "json":
1084+
if not ctype or ctype == "jsonb":
10851085
return
10861086
alter_column_type(cr, table, field, "jsonb", "jsonb_build_object('en_US', {0})")
10871087

0 commit comments

Comments
 (0)