Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How solve Odoo ORM cache issue than call tools.trans_export() in a for loop?

By
int_tow
on 1/25/16, 7:49 AM 505 views

I want export individual de.po files for all installed modules in my odoo database. The exported po files are incorrect if tools.trans_export() is called more than once in a for loop. (for instance the translation of "HTTP routing" of web_editor module) I suppose this is an orm cache problem.

My code

        from subprocess import call

        prod_info_obj = self.pool.get('ir.module.module')
        prod_info_ids = prod_info_obj.search(cr, uid, [('state','=','installed')])
        if prod_info_ids:
            the_modules = prod_info_obj.browse(cr, uid, prod_info_ids, context)

        the_path = '/home/test/po_export/'
        x = 0

        for a_module in the_modules:
            if x>-1:
           # if "web_editor" == a_module.name: 
                with contextlib.closing(cStringIO.StringIO()) as buf:
                    # parameter modul als [] liste nötig, jedes modul einzeln sonst alles in einer po datei 
                    tools.trans_export('de_DE', [a_module.name], buf, 'po', cr)
                    #out = base64.encodestring(buf.getvalue())
                    out = buf.getvalue()
                call("mkdir -p " + the_path + a_module.name, shell=True)
                f = open(the_path + a_module.name + '/de.po', 'w')
                f.write(out)
                f.close
                x=x+1

what do you mean with incorrect? what problem did you saw?

Axel Mendoza
on 1/25/16, 11:42 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/25/16, 7:49 AM
Seen: 505 times
Last updated: 1/25/16, 9:46 AM