From 3ef5e63f62f0f84d6e92cb55eb112ab2f2924faa Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 8 Jan 2021 09:30:30 +0000 Subject: [FIX] odoo/fields.py: fix removing translations on writing '' cache_value could be empty string rather than None. I'm not sure why it was different before. STEPS: * install an app that adds menu Products (e.g. Sales) * activate second language and switch to it * create new product, set some value to field description ("Internal Notes"), save * click edit, remove description, save BEFORE: the value is not removed AFTER: value is empty, translations are removed closes odoo/odoo#64591 X-original-commit: 32465251e19efe63d2015b799b8de9b4e8db438f Signed-off-by: Ivan Yelizariev // IEL --- odoo/fields.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'odoo/fields.py') diff --git a/odoo/fields.py b/odoo/fields.py index 710663866d0..8e940a3a387 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1497,7 +1497,7 @@ class _String(Field): update_trans = True elif lang != 'en_US' and lang is not None: # update the translations only except if emptying - update_column = cache_value is None + update_column = not cache_value update_trans = True # else: lang = None @@ -1507,7 +1507,7 @@ class _String(Field): for rid in real_recs._ids: # cache_value is already in database format towrite[rid][self.name] = cache_value - if self.translate is True and cache_value is not None: + if self.translate is True and cache_value: tname = "%s,%s" % (records._name, self.name) records.env['ir.translation']._set_source(tname, real_recs._ids, value) if self.translate: @@ -1530,7 +1530,7 @@ class _String(Field): source_recs[self.name] = value source_value = value tname = "%s,%s" % (self.model_name, self.name) - if value is None: + if not value: records.env['ir.translation'].search([ ('name', '=', tname), ('type', '=', 'model'), -- cgit v1.2.3