forked from Techsystech/web
Add tr_sequence on res.lang to allow sorting languages in the translation dialog
parent
7fde1b35d5
commit
29fa333221
|
@ -18,7 +18,8 @@
|
|||
"web",
|
||||
],
|
||||
"data": [
|
||||
"view/web_translate.xml",
|
||||
"views/res_lang.xml",
|
||||
"views/web_translate.xml",
|
||||
],
|
||||
"qweb": [
|
||||
"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 = parent;
|
||||
this.view_type = parent.viewType || '';
|
||||
this.$view_form = null;
|
||||
this.$sidebar_form = null;
|
||||
this.translatable_field = options.field.fieldName;
|
||||
this.res_id = options.res_id;
|
||||
this.languages = null;
|
||||
this.languages_loaded = $.Deferred();
|
||||
(new data.DataSetSearch(this, 'res.lang', parent.searchView.dataset.get_context(),
|
||||
[['translatable', '=', '1']])).read_slice(['code', 'name'],
|
||||
{ sort: 'id' }).then(this.on_languages_loaded);
|
||||
this.lang_data = new data.DataSetSearch(
|
||||
this, 'res.lang', parent.searchView.dataset.get_context(),
|
||||
[['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 () {
|
||||
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