def pre_init_hook_for_submodules(cr, model, field):
 env = api.Environment(cr, SUPERUSER_ID, {})
 with cr.savepoint():
  table = env[model]._table
  column_exists = table_has_column(cr, table, field)
  if column_exists:
   extract_query = ("\n                SELECT id, '%(model)s', '%(model)s,' || id, 'db', %(field)s\n                FROM %(table)s\n                WHERE %(field)s IS NOT NULL\n            " % {'table': table, 'field': field, 'model': model})
   image_field = 'file_db_store'
  else:
   extract_query = ("\n                SELECT\n                    res_id,\n                    res_model,\n                    CONCAT_WS(',', res_model, res_id),\n                    'filestore',\n                    id\n                FROM ir_attachment\n                WHERE res_field='%(field)s' AND res_model='%(model)s'\n            " % {'model': model, 'field': field})
   image_field = 'attachment_id'
  cr.execute(('\n                INSERT INTO base_multi_image_image (\n                    owner_id,\n                    owner_model,\n                    owner_ref_id,\n                    storage,\n                    %s\n                )\n                %s\n            ' % (image_field, extract_query)))

def pre_init_hook_for_submodules ( cr , model , field ) : env = api . Environment ( cr , SUPERUSER_ID , { } ) with cr . savepoint ( ) : table = env [ model ] . _table column_exists = table_has_column ( cr , table , field ) if column_exists : extract_query = ( "\n                SELECT id, '%(model)s', '%(model)s,' || id, 'db', %(field)s\n                FROM %(table)s\n                WHERE %(field)s IS NOT NULL\n            " % { 'table' : table , 'field' : field , 'model' : model } ) image_field = 'file_db_store' else : extract_query = ( "\n                SELECT\n                    res_id,\n                    res_model,\n                    CONCAT_WS(',', res_model, res_id),\n                    'filestore',\n                    id\n                FROM ir_attachment\n                WHERE res_field='%(field)s' AND res_model='%(model)s'\n            " % { 'model' : model , 'field' : field } ) image_field = 'attachment_id' cr . execute ( ( '\n                INSERT INTO base_multi_image_image (\n                    owner_id,\n                    owner_model,\n                    owner_ref_id,\n                    storage,\n                    %s\n                )\n                %s\n            ' % ( image_field , extract_query ) ) )
moves images from single to multi mode .