'Transfer the data from the temp table to ir.translation'

def finish(self):

    cr = self._cr
    if self._debug:
        cr.execute(('SELECT    count(*)    FROM    %s' % self._table))
        count = cr.fetchone()[0]
        _logger.debug('ir.translation.cursor:    We    have    %d    entries    to    process', count)
    cr.execute(('    UPDATE    %s    AS    ti\n                                                                                                        SET    res_id    =    imd.res_id,\n                                                                                                                        noupdate    =    imd.noupdate\n                                                                                            FROM    ir_model_data    AS    imd\n                                                                                            WHERE    ti.res_id    IS    NULL\n                                                                                            AND    ti.module    IS    NOT    NULL    AND    ti.imd_name    IS    NOT    NULL\n                                                                                            AND    ti.module    =    imd.module    AND    ti.imd_name    =    imd.name\n                                                                                            AND    ti.imd_model    =    imd.model;    ' % self._table))
    if self._debug:
        cr.execute(('    SELECT    module,    imd_name,    imd_model    FROM    %s\n                                                                                                            WHERE    res_id    IS    NULL    AND    module    IS    NOT    NULL    ' % self._table))
        for row in cr.fetchall():
            _logger.info('ir.translation.cursor:    missing    res_id    for    %s.%s    <%s>    ', *row)
    cr.execute(('DELETE    FROM    %s    WHERE    res_id    IS    NULL    AND    module    IS    NOT    NULL' % self._table))
    env = api.Environment(cr, SUPERUSER_ID, {})
    src_relevant_fields = []
    for model in env:
        for (field_name, field) in env[model]._fields.items():
            if (hasattr(field, 'translate') and callable(field.translate)):
                src_relevant_fields.append(('%s,%s' % (model, field_name)))
    find_expr = "\n                                                                irt.lang    =    ti.lang\n                                                AND    irt.type    =    ti.type\n                                                AND    irt.name    =    ti.name\n                                                AND    (\n                                                                                (ti.type    =    'model'    AND    ti.res_id    =    irt.res_id    AND    ti.name    IN    %s    AND    irt.src    =    ti.src)\n                                                                    OR    (ti.type    =    'model'    AND    ti.res_id    =    irt.res_id    AND    ti.name    NOT    IN    %s)\n                                                                    OR    (ti.type    =    'view'    AND    (irt.res_id    IS    NULL    OR    ti.res_id    =    irt.res_id)    AND    irt.src    =    ti.src)\n                                                                    OR    (ti.type    =    'field')\n                                                                    OR    (ti.type    =    'help')\n                                                                    OR    (ti.type    NOT    IN    ('model',    'view',    'field',    'help')    AND    irt.src    =    ti.src)\n                                                )\n                                "
    if self._overwrite:
        cr.execute(("    UPDATE    ONLY    %s    AS    irt\n                                                                                                            SET    value    =    ti.value,\n                                                                                                                            src    =    ti.src,\n                                                                                                                            state    =    'translated'\n                                                                                                            FROM    %s    AS    ti\n                                                                                                        WHERE    %s\n                                                                                                                AND    ti.value    IS    NOT    NULL\n                                                                                                                AND    ti.value    !=    ''\n                                                                                                                AND    noupdate    IS    NOT    TRUE\n                                                                                            " % (self._model_table, self._table, find_expr)), (tuple(src_relevant_fields), tuple(src_relevant_fields)))
    cr.execute(('    INSERT    INTO    %s(name,    lang,    res_id,    src,    type,    value,    module,    state,    comments)\n                                                                                            SELECT    name,    lang,    res_id,    src,    type,    value,    module,    state,    comments\n                                                                                            FROM    %s    AS    ti\n                                                                                            WHERE    NOT    EXISTS(SELECT    1    FROM    ONLY    %s    AS    irt    WHERE    %s);\n                                                                            ' % (self._model_table, self._table, self._model_table, find_expr)), (tuple(src_relevant_fields), tuple(src_relevant_fields)))
    if self._debug:
        cr.execute(('SELECT    COUNT(*)    FROM    ONLY    %s' % self._model_table))
        total = cr.fetchone()[0]
        cr.execute(('SELECT    COUNT(*)    FROM    ONLY    %s    AS    irt,    %s    AS    ti    WHERE    %s' % (self._model_table, self._table, find_expr)), (tuple(src_relevant_fields), tuple(src_relevant_fields)))
        count = cr.fetchone()[0]
        _logger.debug('ir.translation.cursor:    %d    entries    now    in    ir.translation,    %d    common    entries    with    tmp', total, count)
    cr.execute(('DROP    TABLE    %s' % self._table))
    return True
