Skip to content

Commit 534cec0

Browse files
committed
[IMP] util/fields: skip convert if the column is missing
It helps for RR versions where we currently need to pre-check if the field is already created. closes #259 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 910d30c commit 534cec0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/util/fields.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,16 +980,17 @@ def _extract_data_as_attachment(cr, model, field, encoded=True, name_field=None,
980980

981981
def convert_field_to_translatable(cr, model, field):
982982
table = table_of_model(cr, model)
983-
if column_type(cr, table, field) == "jsonb":
983+
ctype = column_type(cr, table, field)
984+
if not ctype or ctype == "json":
984985
return
985986
alter_column_type(cr, table, field, "jsonb", "jsonb_build_object('en_US', {0})")
986987

987988
def convert_field_to_untranslatable(cr, model, field, type="varchar"):
988989
assert type in ("varchar", "text")
989990
table = table_of_model(cr, model)
990-
if column_type(cr, table, field) != "jsonb":
991+
ctype = column_type(cr, table, field)
992+
if not ctype or ctype != "jsonb":
991993
return
992-
993994
alter_column_type(cr, table, field, type, "{0}->>'en_US'")
994995

995996
else:

0 commit comments

Comments
 (0)