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':
# 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)
# 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)