Merge lp:~openerp-dev/openobject-addons/7.0-opw-595521-rgo into lp:openobject-addons/7.0

Proposed by Ravi Gohil (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-595521-rgo
Merge into: lp:openobject-addons/7.0
Diff against target: 42 lines (+9/-2)
1 file modified
anonymization/anonymization.py (+9/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-595521-rgo
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+184541@code.launchpad.net

Description of the change

Hi,

If anonymization was done on few fields of any custom module, and at the time of reverse anonymization process, if that particular module isn't placed in addons directory(probably reason: the custom module code is not migrated and is not supported with current version yet), then the fields of such models will not going to be unanonymized. So, the state of such fields should not be changed from "Anonymized" to "Clear".

Currently, it changes the state of such fields to "Clear" state and shows the database in stable state, where in-fact, it isn't.

This branch fixes this issue, kindly review it.

Thanks.

To post a comment you must log in.

Unmerged revisions

9423. By Ravi Gohil (OpenERP)

[FIX] anonymization: In the reverse anonymization process, the fields, which are still in anonymized state, are marked as Clear and wrongly shows the database in stable state. (Maintenance: 595521)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'anonymization/anonymization.py'
2--- anonymization/anonymization.py 2013-06-07 11:38:29 +0000
3+++ anonymization/anonymization.py 2013-09-09 11:25:48 +0000
4@@ -509,6 +509,7 @@
5 """Set the 'clear' state to defined fields"""
6 ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization')
7 anonymization_history_model = self.pool.get('ir.model.fields.anonymization.history')
8+ unknown_models = []
9
10 # create a new history record:
11 vals = {
12@@ -544,7 +545,10 @@
13
14 for line in data:
15 queries = []
16- table_name = self.pool.get(line['model_id'])._table if self.pool.get(line['model_id']) else None
17+ if self.pool.get(line['model_id']):
18+ table_name = self.pool.get(line['model_id'])._table
19+ else:
20+ unknown_models.append(line['model_id'])
21
22 # check if custom sql exists:
23 key = (line['model_id'], line['field_id'])
24@@ -574,7 +578,7 @@
25
26 # update the anonymization fields:
27 ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization')
28- field_ids = ir_model_fields_anonymization_model.search(cr, uid, [('state', '<>', 'not_existing')], context=context)
29+ field_ids = ir_model_fields_anonymization_model.search(cr, uid, [('model_name', 'not in', unknown_models), ('state', '<>', 'not_existing')], context=context)
30 values = {
31 'state': 'clear',
32 }
33@@ -583,6 +587,9 @@
34 # add a result message in the wizard:
35 msg = '\n'.join(["Successfully reversed the anonymization.",
36 "",
37+ ]) if not unknown_models else \
38+ '\n'.join(["Reverse anonymization was unsuccessful for few fields!",
39+ "",
40 ])
41
42 self.write(cr, uid, ids, {'msg': msg})