Odoo Help


Two languages in a invoice

Steven Bliek
on 4/24/14, 5:00 AM 2,053 views

Hi there,

I would like to use two languages in one report (invoice). Not for every line, but only for the product name.

I know I have to use setLang but somehow I can't get it to work correctly. The whole report is made up in the language of the client [[ setLang(o.partner_id.lang) ]]. But we would like to have the name of the product in English and Chinese.

This is (a little part of) what I have till now.

  <para style="terp_default_9">[[ setLang('zh_CN') ]] [[ format(l.product_id.name) ]]</para>
  <para style="terp_default_9">[[ setLang('en_US') ]] [[ format(l.product_id.name) ]]</para>

I will send a big hug to the one who is able to help me ;-)

On 5/21/14, 8:35 AM

def translation(self,name,lang=''zh_CN'',source_type=''):

    if source_type:
        query = "select value from ir_translation where lang='"+lang+"' and type='"+source_type+"' and src='"+name+"'"
        query = "select value from ir_translation where lang='"+lang+"' and src='"+name+"'"
    cr = self.cr
    res_trans = cr.fetchone()
    res = res_trans and res_trans[0] or name
    return res
def __init__(self, cr, uid, name, context):

    super(contract, self).__init__(cr, uid, name, context)
    self.cr = cr # re initialize cr
            'time': time,
            'translate': self.translation

  <para style="terp_default_9">[[ translate(format(l.product_id.name)) ]]</para>


  <para style="terp_default_9">[[translate(format(l.product_id.name),'en_US') ]]</para>


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

1 follower(s)


Asked: 4/24/14, 5:00 AM
Seen: 2053 times
Last updated: 7/4/17, 4:59 AM