'This method is called from odoo/addons/base/base_data.xml to load
some language and set it as the default for every partners. The
language is set via tools.config by the RPC \'create\' method on the
\'db\' object. This is a fragile solution and something else should be
found.'

@api.model
def install_lang(self):

    lang_code = (tools.config.get('load_language') or 'en_US').split(',')[0]
    lang = self.search([('code', '=', lang_code)])
    if (not lang):
        self.load_lang(lang_code)
    IrValues = self.env['ir.values']
    default_value = IrValues.get_defaults('res.partner', condition=False)
    if (not default_value):
        IrValues.set_default('res.partner', 'lang', lang_code, condition=False)
        partner = self.env.user.company_id.partner_id
        if (not partner.lang):
            partner.write({'lang': lang_code})
    return True
