From 73b42c88c18edaf132994538336c675db357357a Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Fri, 29 Feb 2008 18:53:40 +0100 Subject: [PATCH 1/2] Improved field comparison at update. --- trytond/tools/convert.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/trytond/tools/convert.py b/trytond/tools/convert.py index 5563c23102..7e428cbc88 100644 --- a/trytond/tools/convert.py +++ b/trytond/tools/convert.py @@ -535,25 +535,22 @@ class TrytondXmlHandler(sax.handler.ContentHandler): if db_field == values[key]: continue - # we cannot update a field if it was changed by a user + # we cannot update a field if it was changed by a user... if key not in old_values: - default_value = object_ref._defaults.get( + expected_value = object_ref._defaults.get( key, lambda *a:None)(cursor, user) - if db_field != default_value: - logger = Logger() + else: + expected_value = old_values[key] - logger.notify_channel('init', LOG_WARNING, - "Field %s of %s@%s not updated (id: %s), because "\ - "it has changed since the last update"% \ - (key, db_id, model, fs_id)) - continue - - elif (old_values[key] and db_field) and \ - old_values[key] != db_field: + # ... and we consider that there is an update if the + # expected value differs from the actual value, _and_ + # if they are not false in a boolean context (ie None, + # False, {} or []) + if db_field != expected_value and (db_field or expected_value) : logger = Logger() logger.notify_channel('init', LOG_WARNING, "Field %s of %s@%s not updated (id: %s), because "\ - "it has changed since the last update."%\ + "it has changed since the last update"% \ (key, db_id, model, fs_id)) continue From f4a88c74a2ce1d1cf153827614a2c803de4610ee Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Fri, 29 Feb 2008 19:26:53 +0100 Subject: [PATCH 2/2] Removed extra comma --- trytond/ir/translation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/ir/translation.py b/trytond/ir/translation.py index 5b56f1a050..2fade9c6fb 100644 --- a/trytond/ir/translation.py +++ b/trytond/ir/translation.py @@ -31,7 +31,7 @@ class Translation(OSV, Cacheable): _description = __doc__ name = fields.Char('Field Name', size=128, required=True) res_id = fields.Integer('Resource ID') - lang = fields.Selection('get_language', string='Language', size=5), + lang = fields.Selection('get_language', string='Language', size=5) type = fields.Selection(TRANSLATION_TYPE, string='Type', size=16, required=True) src = fields.Text('Source')