~jfb-tempo-consulting/unifield-wm/jfb-int

« back to all changes in this revision

Viewing changes to msf_profile/deleted_object.py

  • Committer: jf
  • Date: 2016-02-26 10:38:20 UTC
  • mfrom: (2740.12.1 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20160226103820-0c82s1nyb6ac0xh0
[IMP] Deleted objects: new field deleted_in_sync
lp:~fabien-morin/unifield-wm/deleted-object-request

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        'deletion_date': fields.datetime('Deletion Date', read_only=True),
42
42
        'user_id': fields.many2one('res.users', 'User who delete',
43
43
            read_only=True),
 
44
        'deleted_in_sync': fields.boolean(string='Deleted by sync',
 
45
            help='This object has been deleted during a synchronization'),
44
46
    }
45
47
 
46
48
deleted_object()
72
74
    def unlink(self, original_unlink, cr, uid, ids, context=None):
73
75
        """Create a delete_object in case the current object is not blacklisted
74
76
        to keep track of deleted objects"""
 
77
        if context is None:
 
78
            context = {}
75
79
        res = original_unlink(self, cr, uid, ids, context=context)
76
80
        if not res:
77
81
            return res
94
98
            # sync client not installed
95
99
            return res
96
100
        obj_sd_ref = model_obj.get_sd_ref(cr, uid, ids)
 
101
        is_sync_context = context.get('sync_update_execution', False) or context.get('sync_message_execution', False)
 
102
        deleted_obj_module = self.pool.get('deleted.object')
97
103
        for sub_ids in cr.split_for_in_conditions(ids):
98
104
            # keep a track of deleted object if there are not blacklisted
99
 
            # by creating a delete_object
 
105
            # by creating a deleted.object
100
106
            for obj_id in sub_ids:
101
107
                vals = {'model': self._name,
102
108
                        'deleted_obj_id': obj_id,
103
109
                        'deleted_obj_sd_ref': obj_sd_ref[obj_id],
104
110
                        'deletion_date': deletion_date,
105
 
                        'user_id': uid,}
106
 
                deleted_obj_module = self.pool.get('deleted.object')
 
111
                        'user_id': uid,
 
112
                        'deleted_in_sync': is_sync_context,}
107
113
                del_obj = deleted_obj_module.create(cr, uid, vals)
108
114
        return res
109
115