[ADD] Add language from website
bzr revid: fme@openerp.com-20131009120904-c06nass3srpwqer4
This commit is contained in:
parent
87ad57b799
commit
5cfbcc3aff
|
@ -346,3 +346,28 @@ class res_partner(osv.osv):
|
|||
'q': '%s, %s %s, %s' % (partner.street, partner.city, partner.zip, partner.country_id and partner.country_id.name_get()[0][1] or ''),
|
||||
}
|
||||
return urlplus('https://maps.google.be/maps' , params)
|
||||
|
||||
class base_language_install(osv.osv):
|
||||
_inherit = "base.language.install"
|
||||
_columns = {
|
||||
'website_ids': fields.many2many('website', string='Websites to translate'),
|
||||
}
|
||||
|
||||
def lang_install(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
action = super(base_language_install, self).lang_install(cr, uid, ids, context)
|
||||
language_obj = self.browse(cr, uid, ids)[0]
|
||||
website_ids = [website.id for website in language_obj['website_ids']]
|
||||
lang_id = self.pool['res.lang'].search(cr, uid, [('code', '=', language_obj['lang'])])
|
||||
if website_ids and lang_id:
|
||||
data = {'language_ids': [(4, lang_id[0])]}
|
||||
self.pool['website'].write(cr, uid, website_ids, data)
|
||||
params = context.get('params', {})
|
||||
if 'url_return' in params:
|
||||
return {
|
||||
'url': params['url_return'].replace('[lang]', language_obj['lang']),
|
||||
'type': 'ir.actions.act_url',
|
||||
'target': 'self'
|
||||
}
|
||||
return action
|
||||
|
|
|
@ -84,7 +84,8 @@
|
|||
<li name="contactus"><a t-href="/page/website.contactus">Contact us</a></li>
|
||||
<li t-if="user_id.id == website.public_user.id"><a href="/admin">Sign in</a></li>
|
||||
<li t-if="user_id.id != website.public_user.id"><a href="/admin"><span t-field="user_id.name"/></a></li>
|
||||
<li t-if="request.multilang and len(website.language_ids) > 1" class="dropdown">
|
||||
<li t-if="request.multilang and
|
||||
(len(website.language_ids) > 1 or editable)" class="dropdown">
|
||||
<!-- TODO: use flags for language selection -->
|
||||
<t t-set="lang_selected" t-value="[lg for lg in website.language_ids if lg.code == lang]"/>
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
|
@ -98,6 +99,15 @@
|
|||
<t t-esc="lg.name"/>
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="editable" class="text-center">
|
||||
<t t-set="url_return" t-value="request.multilang and url_for(request.httprequest.path, '[lang]') or request.httprequest.path"/>
|
||||
<t t-if="request.httprequest.query_string">
|
||||
<t t-set="url_return" t-value="url_return + '?' + request.httprequest.query_string"/>
|
||||
</t>
|
||||
<a t-attf-href="/web#action=base.action_view_base_language_install&url_return=#{url_return}">
|
||||
Add a Language
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -55,9 +55,9 @@
|
|||
<field name="social_youtube" placeholder="http://www.youtube.com/channel/HCU842OHPPNrQ"/>
|
||||
<field name="social_github" placeholder="https://youraccount.github.io"/>
|
||||
</group>
|
||||
<group string="Others Info">
|
||||
<group string="Other Info">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="language_ids" widget="many2many_tags"/>
|
||||
<field name="language_ids" widget="many2many_checkboxes"/>
|
||||
<field name="default_lang_id" widget="selection"/>
|
||||
</group>
|
||||
</group>
|
||||
|
@ -65,5 +65,15 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_base_language_install" model="ir.ui.view">
|
||||
<field name="name">view_base_language_install.inherit</field>
|
||||
<field name="model">base.language.install</field>
|
||||
<field name="inherit_id" ref="base.view_base_language_install"/>
|
||||
<field name="arch" type="xml">
|
||||
<group states="init" position="inside">
|
||||
<field name="website_ids" widget="many2many_checkboxes"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue