From fd7a7207acde3bd4358f7444b988b5930ba0d381 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 21 Apr 2016 14:04:11 +0200 Subject: [PATCH] [FIX] orm: do not save empty translation as 'false' When writting a value on a translatable field in a different language than English, the submitted *raw* value was saved in the database. This could cause the following issues: - empty value (provided as `False` by the web client) saved as the string 'false' in the translations table - no encoding or sanitization convertion - ignore size parameter on the translatable field Process the submitted translation through symbol_set method to clean it before storing it blindly in the database. This allows to convert `False` into `''` for empty value and fixes #10862 --- openerp/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/models.py b/openerp/models.py index cc0a4979bef..93642ba49b5 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -3910,7 +3910,8 @@ class BaseModel(object): # Inserting value to DB context_wo_lang = dict(context, lang=None) self.write(cr, user, ids, {f: vals[f]}, context=context_wo_lang) - self.pool.get('ir.translation')._set_ids(cr, user, self._name+','+f, 'model', context['lang'], ids, vals[f], src_trans) + translation_value = self._columns[f]._symbol_set[1](vals[f]) + self.pool['ir.translation']._set_ids(cr, user, self._name+','+f, 'model', context['lang'], ids, translation_value, src_trans) # invalidate and mark new-style fields to recompute; do this before # setting other fields, because it can require the value of computed