Support derivative translations in reports

TranslateFactory must search throw all parents languages.

issue6012
review30751003
This commit is contained in:
Cédric Krier committed 2016-11-05 19:59:51 +01:00
1 parent f9c0457416
commit 16336ffeae
1 file changed
+16 -12
+16 -12
View File
@@ -19,6 +19,7 @@ from trytond.transaction import Transaction
from trytond.url import URLMixin
from trytond.rpc import RPC
from trytond.exceptions import UserError
from trytond.tools import get_parent_language
MIMETYPES = {
'odt': 'application/vnd.oasis.opendocument.text',
@@ -72,18 +73,21 @@ class TranslateFactory:
def __call__(self, text):
if self.language not in self.cache:
self.cache[self.language] = {}
translations = self.translation.search([
('lang', '=', self.language),
('type', '=', 'report'),
('name', '=', self.report_name),
('value', '!=', ''),
('value', '!=', None),
('fuzzy', '=', False),
('res_id', '=', -1),
])
for translation in translations:
self.cache[self.language][translation.src] = translation.value
cache = self.cache[self.language] = {}
code = self.language
while code:
translations = self.translation.search([
('lang', '=', code),
('type', '=', 'report'),
('name', '=', self.report_name),
('value', '!=', ''),
('value', '!=', None),
('fuzzy', '=', False),
('res_id', '=', -1),
])
for translation in translations:
cache.setdefault(translation.src, translation.value)
code = get_parent_language(code)
return self.cache[self.language].get(text, text)
def set_language(self, language):