3
0
Fork 0

Add tr_sequence on res.lang to allow sorting languages in the translation dialog

13.0
Akim Juillerat 2019-08-16 11:14:55 +02:00 committed by fshah
parent 9191903bcc
commit 61e3767b2d
7 changed files with 37 additions and 6 deletions

View File

@ -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",

View File

@ -0,0 +1,2 @@
from . import base
from . import res_lang

View File

@ -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,
)

View File

@ -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;

View File

@ -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>