summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorolt@tinyerp.com <>2012-09-17 10:10:17 +0200
committerolt@tinyerp.com <>2012-09-17 10:10:17 +0200
commita0f23eb60b5cbd352bc5dbecd81bc2e098607df3 (patch)
tree88f306ece6c34e9329eb58e460c738184a7a9ad2
parentcd644106f30d303738fdd0a04b9b15e5e4a33bbf (diff)
[FIX] anonymization: raise a good descriptive error when the state is 'unstable'
bzr revid: olt@tinyerp.com-20120917081017-s15mm36ppvs4lfxc
-rw-r--r--addons/anonymization/anonymization.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/anonymization/anonymization.py b/addons/anonymization/anonymization.py
index 47e168a12b8..6b6db168a4f 100644
--- a/addons/anonymization/anonymization.py
+++ b/addons/anonymization/anonymization.py
@@ -64,11 +64,13 @@ class ir_model_fields_anonymization(osv.osv):
state = 'anonymized' # all fields are anonymized
else:
state = 'unstable' # fields are mixed: this should be fixed
+
return state
def _check_write(self, cr, uid, context=None):
# check that the field is created from the menu and not from an database update
# otherwise the database update can crash:
+
if context.get('manual'):
global_state = self._get_global_state(cr, uid, context=context)
if global_state == 'anonymized':
@@ -100,12 +102,16 @@ class ir_model_fields_anonymization(osv.osv):
# check field state: all should be clear before we can add a new field to anonymize:
self._check_write(cr, uid, context=context)
+ global_state = self._get_global_state(cr, uid, context=context)
+
if 'field_name' in vals and vals['field_name'] and 'model_name' in vals and vals['model_name']:
vals['model_id'], vals['field_id'] = self._get_model_and_field_ids(cr, uid, vals, context=context)
# check not existing fields:
if not vals.get('field_id'):
vals['state'] = 'not_existing'
+ else:
+ vals['state'] = global_state
res = super(ir_model_fields_anonymization, self).create(cr, uid, vals, context=context)
@@ -340,8 +346,9 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
# remove the placeholer:
eview.remove(placeholder)
else:
- # unstable ?
- raise
+ msg = "The database anonymization is currently in an unstable state. Some fields are anonymized," + \
+ " while some fields are not anonymized. You should try to solve this problem before trying to do anything else."
+ raise osv.except_osv('Error !', msg)
res['arch'] = etree.tostring(eview)