[FIX] web: technical translations menu
The action "Technical Translations" was not retrieving the correct translations. Since 9.0, the translations names no longer contains the name of the model (in the form "field:<model>,<name>") but are records on ir.model.fields (in the form "model:ir.model.fields,field_description:<model>_<name>"). The translations of type selection are style a different type (type 'selection'). Create a method that will find the linked fields and retrieve the correct translations. Fixes tw:reis_pt/status/687419541199187969
This commit is contained in:
@@ -2067,8 +2067,7 @@ msgstr ""
|
||||
|
||||
#. module: web
|
||||
#. openerp-web
|
||||
#: code:addons/web/static/src/js/widgets/debug_manager.js:152
|
||||
#: code:addons/web/static/src/xml/base.xml:170
|
||||
#: code:addons/web/static/src/xml/base.xml:216
|
||||
#, python-format
|
||||
msgid "Technical Translation"
|
||||
msgstr ""
|
||||
|
||||
@@ -5,6 +5,7 @@ var core = require('web.core');
|
||||
var Dialog = require('web.Dialog');
|
||||
var formats = require('web.formats');
|
||||
var framework = require('web.framework');
|
||||
var Model = require('web.Model');
|
||||
var session = require('web.session');
|
||||
var SystrayMenu = require('web.SystrayMenu');
|
||||
var utils = require('web.utils');
|
||||
@@ -148,15 +149,9 @@ if (core.debug) {
|
||||
});
|
||||
},
|
||||
translate: function() {
|
||||
this.do_action({
|
||||
name: _t("Technical Translation"),
|
||||
res_model : 'ir.translation',
|
||||
domain : [['type', '!=', 'object'], '|', ['name', '=', this.dataset.model], ['name', 'ilike', this.dataset.model + ',']],
|
||||
views: [[false, 'list'], [false, 'form']],
|
||||
type : 'ir.actions.act_window',
|
||||
view_type : "list",
|
||||
view_mode : "list"
|
||||
});
|
||||
new Model("ir.translation")
|
||||
.call('get_technical_translations', [this.dataset.model])
|
||||
.then(this.do_action);
|
||||
},
|
||||
edit: function(params, evt) {
|
||||
this.do_action({
|
||||
|
||||
@@ -712,3 +712,29 @@ class ir_translation(osv.osv):
|
||||
_logger.info('module %s: loading extra translation file (%s) for language %s', module_name, lang_code, lang)
|
||||
tools.trans_load(cr, trans_extra_file, lang, verbose=False, module_name=module_name, context=context)
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def get_technical_translations(self, model_name):
|
||||
""" Find the translations for the fields of `model_name`
|
||||
|
||||
Find the technical translations for the fields of the model, including
|
||||
string, tooltip and available selections.
|
||||
|
||||
:return: action definition to open the list of available translations
|
||||
"""
|
||||
fields = self.env['ir.model.fields'].search([('model', '=', model_name)])
|
||||
view = self.env.ref("base.view_translation_tree", False)
|
||||
return {
|
||||
'name': _("Technical Translation"),
|
||||
'view_mode': 'tree',
|
||||
'views': [(view and view.id or False, "list")],
|
||||
'res_model': 'ir.translation',
|
||||
'type': 'ir.actions.act_window',
|
||||
'domain': ['|',
|
||||
'&',('type', '=', 'model'),
|
||||
'&',('res_id', 'in', fields.ids),
|
||||
('name', 'like', 'ir.model.fields,'),
|
||||
'&',('type', '=', 'selection'),
|
||||
('name', 'like', model_name+','),
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user