forked from Techsystech/web
Add tr_sequence on res.lang to allow sorting languages in the translation dialog
parent
9191903bcc
commit
61e3767b2d
|
@ -18,7 +18,8 @@
|
||||||
"web",
|
"web",
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
"view/web_translate.xml",
|
"views/res_lang.xml",
|
||||||
|
"views/web_translate.xml",
|
||||||
],
|
],
|
||||||
"qweb": [
|
"qweb": [
|
||||||
"static/src/xml/base.xml",
|
"static/src/xml/base.xml",
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
from . import base
|
||||||
|
from . import res_lang
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Copyright 2019 Camptocamp SA
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class ResLang(models.Model):
|
||||||
|
|
||||||
|
_inherit = 'res.lang'
|
||||||
|
|
||||||
|
tr_sequence = fields.Integer(
|
||||||
|
string='Translation sequence',
|
||||||
|
help='Defines the order of language to appear in translation dialog',
|
||||||
|
default=10,
|
||||||
|
)
|
|
@ -29,15 +29,16 @@ var translateDialog = Dialog.extend({
|
||||||
this.view_language = session.user_context.lang;
|
this.view_language = session.user_context.lang;
|
||||||
this.view = parent;
|
this.view = parent;
|
||||||
this.view_type = parent.viewType || '';
|
this.view_type = parent.viewType || '';
|
||||||
this.$view_form = null;
|
|
||||||
this.$sidebar_form = null;
|
|
||||||
this.translatable_field = options.field.fieldName;
|
this.translatable_field = options.field.fieldName;
|
||||||
this.res_id = options.res_id;
|
this.res_id = options.res_id;
|
||||||
this.languages = null;
|
this.languages = null;
|
||||||
this.languages_loaded = $.Deferred();
|
this.languages_loaded = $.Deferred();
|
||||||
(new data.DataSetSearch(this, 'res.lang', parent.searchView.dataset.get_context(),
|
this.lang_data = new data.DataSetSearch(
|
||||||
[['translatable', '=', '1']])).read_slice(['code', 'name'],
|
this, 'res.lang', parent.searchView.dataset.get_context(),
|
||||||
{ sort: 'id' }).then(this.on_languages_loaded);
|
[['translatable', '=', '1']]
|
||||||
|
);
|
||||||
|
this.lang_data.set_sort(['tr_sequence asc','id asc']);
|
||||||
|
this.lang_data.read_slice(['code', 'name']).then(this.on_languages_loaded);
|
||||||
},
|
},
|
||||||
willStart: function () {
|
willStart: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="res_lang_form" model="ir.ui.view">
|
||||||
|
<field name="name">res.lang.form.inherit</field>
|
||||||
|
<field name="inherit_id" ref="base.res_lang_form" />
|
||||||
|
<field name="model">res.lang</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="translatable" position="after">
|
||||||
|
<field name="tr_sequence" attrs="{'invisible': [('translatable', '!=', True)]}" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue