Odoo Help


Why my model inheritance does not work?

Tomas Parnarauskas
on 9/30/13, 7:25 AM 1,413 views

I've written new module that translates amount_to_text into Lithuanian language. I inherited ir.translation model which gets translation methods from module - base_translate_tools - https://apps.openerp.com:443/apps/base_translate_tools/. So I installed that module and as said inherited ir.translation using:

_name = `ir.translation`
_inherit = `ir.translation`

Then I've written methods to translate amount to text in Lithuanian language (if I would simply add these methods in tools.amount_to_text, it would translate, but then if I would update OpenERP to newer revision, I'd have to reapply it again).

All methods are similar to other languages, except some specifics in Lithuanian language. at the end of my module I added this:

_translate_funcs = {'co': 'self.amount_to_text_co', 'pe': 'self.amount_to_text_pe', 'es': 'self.amount_to_text_pe', 'en': 'self.amount_to_text_en', 'lt': 'self.amount_to_text_lt',}

To update translation module with amount_to_text_lt method. But it seems that model that I inherited from does not see it or my invoice amount_to_text method uses translations from base_translate_tools module, but not the one I created. I get this error in logs, when I try to open my custom invoice (invoice opens, just without amount to text being showed):

    File "/home/user/openerp/community-addons/base_translate_tools/ir_translation.py", line 220, in amount_to_text
        exec("res = %s(abs(nbr), currency)"%(self._translate_funcs[lang]))
      File "<string>", line 1, in <module>
AttributeError: 'ir.translation' object has no attribute 'amount_to_text_lt'

My custom invoice module uses this to get amount_to_text method:

class account_invoice(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(account_invoice, self).__init__(cr, uid, name, context=context)
            'time': time,
            'amount_to_text': self.pool.get('ir.translation').amount_to_text,

P.S. It translates in any language defined in base_translate_tools module, but does not translate into Language that I defined into module. Am I missing something?

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 9/30/13, 7:25 AM
Seen: 1413 times
Last updated: 3/16/15, 8:10 AM