~pau-tecnoba/school-base-openerp-module/pau

« back to all changes in this revision

Viewing changes to school_attendance/wizards/school_annotations_by_classe.py

  • Committer: Pere Erro
  • Date: 2012-09-11 10:25:55 UTC
  • Revision ID: pereerro@terra.es-20120911102555-ub0y5jq7p9te97ij
[FIX] Bug #1048613 fixed
[IMP] New wizard to tutorize students

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
class school_annotations_by_classe(osv.osv_memory):
46
46
    _name = 'school.annotations_by_classe'
47
47
 
 
48
    wiz_datas = {}
 
49
    
48
50
    _columns = {
49
51
        'classe_id' : fields.many2one('school.classe', string='Classe', required=True,),
50
52
        'date_from' : fields.date('Date from', required=True,),
76
78
        if not context:
77
79
            context = {}
78
80
            
79
 
        part_ids = context.get('participation_ids', [])
80
 
        seance_ids = context.get('seance_ids', [])
 
81
        part_ids = context.get('wiz_participation_ids', [])
 
82
        seance_ids = context.get('wiz_seance_ids', [])
81
83
        
82
84
        for part in  self.pool.get('groups.participation').browse(cr, uid, part_ids):
83
85
            key2 = prefix2 + str(part.participant.id)
108
110
        if view.name != 'school.annotations_by_classe.form2':
109
111
            return res
110
112
        
111
 
        part_ids = context.get('participation_ids', [])
112
 
        seance_ids = context.get('seance_ids', [])
 
113
        part_ids = context.get('wiz_participation_ids', [])
 
114
        seance_ids = context.get('wiz_seance_ids', [])
113
115
        
114
116
        view_xml = etree.XML(res['arch'])
115
117
        
152
154
                args += [('teachers.teacher_id.teacher_user_id','=',uid)]
153
155
            seance_ids = self.pool.get('school.seance').search(cr, uid, args)
154
156
            group_set = set()
155
 
            for seance in self.pool.get('school.seance').browse(cr, uid, seance_ids):
 
157
            for seance in self.pool.get('school.seance').browse(cr, uid, seance_ids, context={'withoutBlank': False,}):
156
158
                group_set.add(seance.group_id)
157
159
            for group in group_set:
158
160
                part_set.update([    (x.participation_id.id, x.participation_id.participant.id)
166
168
        actw_ids = actw_obj.search(cr, uid, [('name','=','Annotations by classe : Form'),
167
169
                                  ('res_model','=','school.annotations_by_classe')])
168
170
        ret = actw_obj.read(cr, uid, actw_ids, [], context=context)[0]
169
 
        ret['context'] = {'seance_ids' : seance_ids,
170
 
                          'participation_ids' : [x[0] for x in part_list], 
 
171
        ret['context'] = {'wiz_seance_ids' : seance_ids,
 
172
                          'wiz_participation_ids' : [x[0] for x in part_list], 
171
173
                          'only_own_iwl' : item.only_own_iwl,} 
172
174
        ret['res_id'] = res_id
173
175
#            'nodestroy': True,
254
256
        for key,value in vals.items():
255
257
            if begins_by(key, prefix):
256
258
                for wiz_id in ids:
257
 
                    self.datas[wiz_id][key] = value
 
259
                    self.wiz_datas[wiz_id][key] = value
258
260
        return ret
259
261
 
260
262
    def add_annotation(self, cr, uid, key, anno_type_id, context=None):
286
288
            data = self.read(cr, uid, [item.id], [], context=context)[0]
287
289
            for key,value in data.items():
288
290
                if  begins_by(key, prefix) and\
289
 
                    key in self.datas[item.id] and\
290
 
                    value != self.datas[item.id][key]:
 
291
                    key in self.wiz_datas[item.id] and\
 
292
                    value != self.wiz_datas[item.id][key]:
291
293
                    # annotation to remove
292
294
                    for c in value:
293
 
                        if c not in (self.datas[item.id].get(key, '') or ''):
 
295
                        if c not in (self.wiz_datas[item.id].get(key, '') or ''):
294
296
                            anno_type_id = self.search_annotation(cr, uid, letter_state=c, to_remove=True,)
295
297
                            self.add_annotation(cr, uid, key, anno_type_id)
296
 
                    for c in (self.datas[item.id].get(key, '') or ''):
 
298
                    for c in (self.wiz_datas[item.id].get(key, '') or ''):
297
299
                        if c not in value:
298
300
                            anno_type_id = self.search_annotation(cr, uid, letter_state=c, to_add=True,)
299
301
                            self.add_annotation(cr, uid, key, anno_type_id)