From 55dd375c84d4bf8099d7b6848c69cb1805323349 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 29 Mar 2019 13:43:02 +0000 Subject: [PATCH] [FIX] tools: ensure 0 res_id are handled if an POEntry has an occurrence with a 0 res_id >>> entry.occurrences.append(("selection:report.paper,format", 0)) >>> str(entry) #: selection:report.paperformat,format ... Use the string '0' to bypass this --- odoo/tools/translate.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index 555b14fea9a..160cce4f6e4 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -571,7 +571,7 @@ class PoFileReader: 'src': source, 'value': translation, 'comments': comments, - 'res_id': line_number, + 'res_id': int(line_number), 'module': module, } continue @@ -586,7 +586,7 @@ class PoFileReader: 'src': source, 'value': translation, 'comments': comments, - 'res_id': line_number, + 'res_id': int(line_number), 'module': module, } continue @@ -600,7 +600,7 @@ class PoFileReader: 'src': source, 'value': translation, 'comments': comments, - 'res_id': line_number, + 'res_id': int(line_number), 'module': module, } continue @@ -697,9 +697,10 @@ class PoFileWriter: for typy, name, res_id in tnrs: if typy == 'code': code = True - if isinstance(res_id, int): + if isinstance(res_id, int) or res_id.isdigit(): # second term of occurrence must be a digit - entry.occurrences.append((u"%s:%s" % (typy, name), res_id)) + # occurrence line at 0 are discarded when rendered to string + entry.occurrences.append((u"%s:%s" % (typy, name), str(res_id))) else: entry.occurrences.append((u"%s:%s:%s" % (typy, name, res_id), '')) if code: