Exemple #1
0
    def print_document(self, record_ids, data=None):
        """ Print a document, do not return the document file """
        document, doc_format = self.with_context(
            must_skip_send_to_printer=True).render_qweb_pdf(record_ids,
                                                            data=data)
        behaviour = self.behaviour()
        printer = behaviour.pop('printer', None)

        if not printer:
            raise exceptions.Warning(
                _('No printer configured to print this report.'))
        # TODO should we use doc_format instead of report_type
        return printer.print_document(self,
                                      document,
                                      doc_format=self.report_type,
                                      **behaviour)
Exemple #2
0
 def button_upload(self):
     lines = _read_binary_file(self.file)
     relation_obj = self.env['education.level.workday_type'].with_context(
         active_test=False)
     academic_year_obj = self.env['education.academic_year'].with_context(
         active_test=False)
     workday_type_obj = self.env['education.workday_type'].with_context(
         active_test=False)
     level_obj = self.env['education.level'].with_context(active_test=False)
     if not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 academic_year_code = _format_info(line[0:9])
                 academic_year = academic_year_obj.search([
                     ('name', '=', academic_year_code)
                 ])
                 if not academic_year:
                     academic_year = academic_year_obj.create({
                         'name':
                         academic_year_code,
                     })
                 workday_type = workday_type_obj.search([
                     ('education_code', '=', _format_info(line[9:18]))
                 ])
                 levels = level_obj.search([('education_code', '=',
                                             _format_info(line[18:22]))])
                 for level in levels:
                     vals = {
                         'academic_year_id': academic_year.id,
                         'workday_type_id': workday_type.id,
                         'level_id': level.id,
                         'dedicated_working_day': _format_info(line[22:27]),
                         'school_working_day': _format_info(line[27:32])
                     }
                     relations = relation_obj.search([
                         ('academic_year_id', '=', academic_year.id),
                         ('workday_type_id', '=', workday_type.id),
                         ('level_id', '=', level.id)
                     ])
                     if relations:
                         relations.write(vals)
                     else:
                         relation_obj.create(vals)
     action = self.env.ref('education.action_education_level')
     return action.read()[0]
 def button_upload(self):
     lines = _read_binary_file(self.file)
     course_obj = self.env['education.course'].with_context(
         active_test=False)
     level_obj = self.env['education.level'].with_context(active_test=False)
     plan_obj = self.env['education.plan'].with_context(active_test=False)
     field_obj = self.env['education.field'].with_context(active_test=False)
     shift_obj = self.env['education.shift'].with_context(active_test=False)
     if not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 education_code = _format_info(line[24:28])
                 plan = plan_obj.search([('education_code', '=',
                                          _format_info(line[4:8]))])
                 level = level_obj.search([
                     ('education_code', '=', _format_info(line[12:16])),
                     ('plan_id', '=', plan.id),
                 ])
                 field = field_obj.search([('education_code', '=',
                                            _format_info(line[16:20]))])
                 shift = shift_obj.search([('education_code', '=',
                                            _format_info(line[20:24]))])
                 vals = {
                     'education_code': education_code,
                     'plan_id': plan.id,
                     'level_id': level.id,
                     'field_id': field.id,
                     'shift_id': shift.id,
                     'description': _format_info(line[28:78]),
                     'description_eu': _format_info(line[78:128]),
                 }
                 courses = course_obj.search([('education_code', '=',
                                               education_code),
                                              ('plan_id', '=', plan.id),
                                              ('level_id', '=', level.id),
                                              ('field_id', '=', field.id),
                                              ('shift_id', '=', shift.id)])
                 if courses:
                     courses.write(vals)
                 else:
                     course_obj.create(vals)
     action = self.env.ref('education.action_education_course')
     return action.read()[0]
Exemple #4
0
 def button_upload(self):
     lines = _read_binary_file(self.file)
     plan_obj = self.env['education.plan'].with_context(active_test=False)
     level_obj = self.env['education.level'].with_context(active_test=False)
     course_obj = self.env['education.course'].with_context(
         active_test=False)
     subject_obj = self.env['education.subject'].with_context(
         active_test=False)
     relation_obj = self.env['education.level.course.subject'].with_context(
         active_test=False)
     if not lines and not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 plan = plan_obj.search([('education_code', '=',
                                          _format_info(line[4:8]))])
                 level = level_obj.search([('education_code', '=',
                                            _format_info(line[0:4])),
                                           ('plan_id', '=', plan.id)])
                 courses = course_obj.search([('education_code', '=',
                                               _format_info(line[8:12])),
                                              ('level_id', '=', level.id),
                                              ('plan_id', '=', plan.id)])
                 subject = subject_obj.search([('education_code', '=',
                                                _format_info(line[12:20]))])
                 for course in courses:
                     vals = {
                         'level_id': level.id,
                         'plan_id': plan.id,
                         'course_id': course.id,
                         'subject_id': subject.id,
                     }
                     relations = relation_obj.search([
                         ('level_id', '=', level.id),
                         ('plan_id', '=', plan.id),
                         ('course_id', '=', course.id),
                         ('subject_id', '=', subject.id)
                     ])
                     if not relations:
                         relation_obj.create(vals)
     action = self.env.ref('education.action_education_subject')
     return action.read()[0]
 def button_upload(self):
     normal_lines = _read_binary_file(self.file_normal)
     other_lines = _read_binary_file(self.file_other)
     position_obj = self.env['education.position'].with_context(
         active_test=False)
     if not normal_lines and not other_lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in normal_lines:
             if len(line) > 0:
                 education_code = _format_info(line[0:3])
                 vals = {
                     'education_code': education_code,
                     'description': _format_info(line[3:103]),
                     'description_eu': _format_info(line[103:203]),
                     'type': 'normal',
                 }
                 positions = position_obj.search([('education_code', '=',
                                                   education_code),
                                                  ('type', '=', 'normal')])
                 if positions:
                     positions.write(vals)
                 else:
                     position_obj.create(vals)
         for line in other_lines:
             if len(line) > 0:
                 education_code = _format_info(line[0:3])
                 vals = {
                     'education_code': education_code,
                     'description': _format_info(line[3:103]),
                     'description_eu': _format_info(line[103:203]),
                     'type': 'other',
                 }
                 positions = position_obj.search([('education_code', '=',
                                                   education_code),
                                                  ('type', '=', 'other')])
                 if positions:
                     positions.write(vals)
                 else:
                     position_obj.create(vals)
     action = self.env.ref('education.action_education_position')
     return action.read()[0]
Exemple #6
0
 def create_parent_user(self):
     template = self.env.ref('openeagleedu_parent.parent_template_user')
     users_res = self.env['res.users']
     for record in self:
         if not record.name.email:
             raise exceptions.Warning(_('Update parent email id first.'))
         if not record.name.user_id:
             groups_id = template and template.groups_id or False
             user_ids = [
                 x.user_id.id for x in record.student_ids if x.user_id
             ]
             user_id = users_res.create({
                 'name': record.name.name,
                 'partner_id': record.name.id,
                 'login': record.name.email,
                 'is_parent': True,
                 'tz': self._context.get('tz'),
                 'groups_id': groups_id,
                 'child_ids': [(6, 0, user_ids)]
             })
             record.name.user_id = user_id
Exemple #7
0
 def button_upload(self):
     lines = _read_binary_file(self.file)
     field_obj = self.env['education.field'].with_context(active_test=False)
     if not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 education_code = _format_info(line[0:4])
                 vals = {
                     'education_code': education_code,
                     'description': _format_info(line[4:54]),
                     'description_eu': _format_info(line[54:104]),
                 }
                 fields = field_obj.search([('education_code', '=',
                                             education_code)])
                 if fields:
                     fields.write(vals)
                 else:
                     field_obj.create(vals)
     action = self.env.ref('education.action_education_field')
     return action.read()[0]
 def button_upload(self):
     lines = _read_binary_file(self.file)
     schedule_obj = self.env['education.schedule'].with_context(
         active_test=False)
     partner_obj = self.env['res.partner'].with_context(active_test=False)
     academic_year_obj = self.env['education.academic_year'].with_context(
         active_test=False)
     idtype_obj = self.env['education.idtype'].with_context(
         active_test=False)
     employee_obj = self.env['hr.employee'].with_context(active_test=False)
     task_type_obj = self.env['education.task_type'].with_context(
         active_test=False)
     classroom_obj = self.env['education.classroom'].with_context(
         active_test=False)
     subject_obj = self.env['education.subject'].with_context(
         active_test=False)
     language_obj = self.env['education.language'].with_context(
         active_test=False)
     group_obj = self.env['education.schedule.group'].with_context(
         active_test=False)
     edu_group_obj = self.env['education.group'].with_context(
         active_test=False)
     dayofweek_dict = dict(map(reversed, EDUCATION_DAYOFWEEK_CODE.items()))
     if not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 line_type = _format_info(line[:1])
                 if line_type == '1':
                     center_code = _format_info(line[3:9])
                     center = partner_obj.search([
                         ('education_code', '=', center_code),
                         ('educational_category', '=', 'school'),
                     ],
                                                 limit=1)
                     year = _format_info(line[9:13])
                     academic_year = academic_year_obj.search([
                         ('name', 'ilike', '{}-'.format(year)),
                     ],
                                                              limit=1)
                 if line_type == '2':
                     if not center or not academic_year:
                         break
                     doc_type = _format_info(line[1:5])
                     idtype = idtype_obj.search([
                         ('education_code', '=', doc_type),
                     ],
                                                limit=1)
                     doc = _format_info(line[5:20])
                     teacher = employee_obj.search([
                         ('edu_idtype_id', '=', idtype.id),
                         ('identification_id', '=', doc),
                     ],
                                                   limit=1)
                     session_number = int(_format_info(line[20:22]))
                     dayofweek = dayofweek_dict.get(
                         int(_format_info(line[22:23])))
                     task_type = task_type_obj.search([
                         ('education_code', '=', _format_info(line[23:27])),
                     ])
                     hour_from = _convert_time_str_to_float(
                         _format_info(line[27:32]))
                     hour_to = _convert_time_str_to_float(
                         _format_info(line[32:37]))
                     classroom = classroom_obj.search([
                         ('center_id', '=', center.id),
                         ('education_code', '=', _format_info(line[37:45]))
                     ])
                     schedule = schedule_obj.search([
                         ('center_id', '=', center.id),
                         ('academic_year_id', '=', academic_year.id),
                         ('session_number', '=', session_number),
                         ('dayofweek', '=', dayofweek),
                         ('teacher_id', '=', teacher.id),
                     ])
                     vals = {
                         'center_id': center.id,
                         'academic_year_id': academic_year.id,
                         'session_number': session_number,
                         'dayofweek': dayofweek,
                         'teacher_id': teacher.id,
                         'hour_from': hour_from,
                         'hour_to': hour_to,
                         'task_type_id': task_type.id,
                         'classroom_id': classroom.id,
                     }
                     if task_type.type == 'L':
                         subject = subject_obj.search([
                             ('education_code', '=',
                              _format_info(line[45:53])),
                         ])
                         subject_type = _format_info(line[53:54])
                         language = language_obj.search([
                             ('education_code', '=',
                              _format_info(line[54:56])),
                         ])
                         vals.update({
                             'subject_id': subject.id,
                             'subject_type': subject_type,
                             'language_id': language.id,
                         })
                     # elif task_type.type == 'N':
                     #     activity_type = _format_info(line[45:48])
                     #     level = _format_info(line[48:52])
                     #     plan = _format_info(line[52:56])
                     if schedule:
                         schedule.write(vals)
                     else:
                         schedule = schedule_obj.create(vals)
                 if line_type == '3':
                     group_code = _format_info(line[1:9])
                     imp_group = edu_group_obj.search([
                         ('education_code', '=', group_code),
                         ('center_id', '=', center.id),
                         ('academic_year_id', '=', academic_year.id),
                     ])
                     if schedule and imp_group:
                         schedule.write({
                             'group_ids': [(4, imp_group.id)],
                         })
                     group_code2 = _format_info(line[67:76])
                     off_group = edu_group_obj.search([
                         ('education_code', '=', group_code2),
                         ('center_id', '=', center.id),
                         ('academic_year_id', '=', academic_year.id),
                     ])
                     session_number = int(_format_info(line[9:13]))
                     student_count = int(_format_info(line[13:17]))
                     alias = _format_info(line[17:67])
                     if imp_group and off_group:
                         vals = {
                             'schedule_id': schedule.id,
                             'group_id': imp_group.id,
                             'session_number': session_number,
                             'student_count': student_count,
                             'group_alias': alias,
                             'parent_group_id': off_group.id,
                         }
                         group = group_obj.search([
                             ('schedule_id', '=', schedule.id),
                             ('group_id', '=', imp_group.id),
                         ])
                         if group:
                             group.write(vals)
                         else:
                             group_obj.create(vals)
     action = self.env.ref('education.action_education_schedule')
     return action.read()[0]
Exemple #9
0
 def write(self, vals):
     if self.env.user.child_ids:
         raise exceptions.Warning(
             _('Invalid Action!\n Parent can not edit \
         Subject Registration!'))
     return super(OpSubjectRegistration, self).write(vals)
 def button_upload(self):
     lines = _read_binary_file(self.file)
     partner_obj = self.env['res.partner']
     academic_year_obj = self.env['education.academic_year'].with_context(
         active_test=False)
     group_obj = self.env['education.group'].with_context(active_test=False)
     plan_obj = self.env['education.plan'].with_context(active_test=False)
     level_obj = self.env['education.level'].with_context(active_test=False)
     field_obj = self.env['education.field'].with_context(active_test=False)
     shift_obj = self.env['education.shift'].with_context(active_test=False)
     course_obj = self.env['education.course'].with_context(
         active_test=False)
     model_obj = self.env['education.model'].with_context(active_test=False)
     group_type_obj = self.env['education.group_type'].with_context(
         active_test=False)
     calendar_obj = self.env['resource.calendar']
     classroom_obj = self.env['education.classroom'].with_context(
         active_test=False)
     idtype_obj = self.env['education.idtype'].with_context(
         active_test=False)
     group_teacher_obj = self.env['education.group.teacher'].with_context(
         active_test=False)
     group_session_obj = self.env['education.group.session'].with_context(
         active_test=False)
     employee_obj = self.env['hr.employee'].with_context(active_test=False)
     dayofweek_dict = dict(map(reversed, EDUCATION_DAYOFWEEK_CODE.items()))
     if not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 line_type = _format_info(line[:1])
                 if line_type == '1':
                     center_code = _format_info(line[3:9])
                     partner = partner_obj.search([
                         ('education_code', '=', center_code),
                         ('educational_category', '=', 'school'),
                     ])
                     year = _format_info(line[9:13])
                     academic_year = academic_year_obj.search([
                         ('name', 'ilike', '{}-'.format(year)),
                     ])
                     if not partner:
                         raise exceptions.Warning(
                             _('Education center not found'))
                 if line_type == '2' and partner:
                     group_code = _format_info(line[1:9])
                     plan = plan_obj.search([
                         ('education_code', '=', _format_info(line[59:63])),
                     ])
                     level = level_obj.search([('education_code', '=',
                                                _format_info(line[63:67])),
                                               ('plan_id', '=', plan.id)])
                     field = field_obj.search([
                         ('education_code', '=', _format_info(line[67:71])),
                     ])
                     shift = shift_obj.search([
                         ('education_code', '=', _format_info(line[71:75])),
                     ],
                                              limit=1)
                     course = course_obj.search([
                         ('education_code', '=', _format_info(line[75:79])),
                         ('plan_id', '=', plan.id),
                         ('level_id', '=', level.id),
                         ('field_id', '=', field.id),
                         ('shift_id', '=', shift.id),
                     ],
                                                limit=1)
                     classroom = classroom_obj.search([
                         ('education_code', '=', _format_info(
                             line[539:547])),
                         ('center_id', '=', partner.id),
                     ],
                                                      limit=1)
                     model = model_obj.search([
                         ('education_code', '=', _format_info(line[79:83])),
                     ],
                                              limit=1)
                     group_type = group_type_obj.search([
                         ('education_code', '=', _format_info(line[83:87])),
                     ],
                                                        limit=1)
                     calendar = calendar_obj.search([
                         ('education_code', '=', _format_info(line[87:95])),
                         ('center_id', '=', partner.id),
                     ])
                     vals = {
                         'center_id': partner.id,
                         'academic_year_id': academic_year.id,
                         'education_code': group_code,
                         'description': _format_info(line[9:59]),
                         'plan_id': plan.id,
                         'level_id': level.id,
                         'field_id': field.id,
                         'shift_id': shift.id,
                         'course_id': course.id,
                         'model_id': model.id,
                         'group_type_id': group_type.id,
                         'calendar_id': calendar.id,
                         'comments': _format_info(line[289:539]),
                         'classroom_id': classroom.id,
                     }
                     group = group_obj.search(
                         [('education_code', '=', group_code),
                          ('center_id', '=', partner.id)],
                         limit=1)
                     if group:
                         group.write(vals)
                     else:
                         group = group_obj.create(vals)
                     start = 95
                     for i in range(1, 11):
                         end = start + 4
                         doc_type = _format_info(line[start:end])
                         idtype = idtype_obj.search([
                             ('education_code', '=', doc_type),
                         ],
                                                    limit=1)
                         start = end + 15
                         doc = _format_info(line[end:start])
                         teacher = employee_obj.search([
                             ('edu_idtype_id', '=', idtype.id),
                             ('identification_id', '=', doc),
                         ],
                                                       limit=1)
                         teacher_vals = {
                             'group_id': group.id,
                             'sequence': i,
                             'employee_id': teacher.id,
                         }
                         teachers = group_teacher_obj.search([
                             ('group_id', '=', group.id),
                             ('sequence', '=', i)
                         ])
                         if teachers:
                             teachers.write(teacher_vals)
                         else:
                             group_teacher_obj.create(teacher_vals)
                 if line_type == '3':
                     session_number = int(_format_info(line[9:11]))
                     dayofweek = dayofweek_dict.get(
                         int(_format_info(line[11:12])))
                     session = group_session_obj.search([
                         ('group_id', '=', group.id),
                         ('session_number', '=', session_number),
                         ('dayofweek', '=', dayofweek),
                     ],
                                                        limit=1)
                     session_vals = {
                         'group_id':
                         group.id,
                         'session_number':
                         session_number,
                         'dayofweek':
                         dayofweek,
                         'hour_from':
                         _convert_time_str_to_float(
                             _format_info(line[12:17])),
                         'hour_to':
                         _convert_time_str_to_float(
                             _format_info(line[17:22])),
                         'recess':
                         _format_info(line[22:23]) == '1',
                     }
                     if session:
                         session.write(session_vals)
                     else:
                         group_session_obj.create(session_vals)
     action = self.env.ref('education.action_education_group')
     return action.read()[0]
Exemple #11
0
 def write(self, vals):
     if self.env.user.child_ids:
         raise exceptions.Warning(
             _('Invalid Action!\n Parent can not edit \
         Media Purchase Requests!'))
     return super(OpMediaPurchase, self).write(vals)
 def button_upload(self):
     lines = _read_binary_file(self.file)
     partner_obj = self.env['res.partner'].with_context(active_test=False)
     employee_obj = self.env['hr.employee'].with_context(active_test=False)
     hr_contract_obj = self.env['hr.contract'].with_context(
         active_test=False)
     department_obj = self.env['hr.department'].with_context(
         active_test=False)
     user_obj = self.env['res.users'].with_context(active_test=False)
     academic_year_obj = self.env['education.academic_year'].with_context(
         active_test=False)
     idtype_obj = self.env['education.idtype'].with_context(
         active_test=False)
     position_obj = self.env['education.position'].with_context(
         active_test=False)
     designation_obj = self.env['education.designation_level'].with_context(
         active_test=False)
     workday_type_obj = self.env['education.workday_type'].with_context(
         active_test=False)
     contract_type_obj = self.env['education.contract_type'].with_context(
         active_test=False)
     workreason_obj = self.env['education.work_reason'].with_context(
         active_test=False)
     if not lines:
         raise exceptions.Warning(_('Empty file.'))
     else:
         for line in lines:
             if len(line) > 0:
                 line_type = _format_info(line[:1])
                 if line_type == '1':
                     center_code = _format_info(line[3:9])
                     center = partner_obj.search([
                         ('education_code', '=', center_code),
                         ('educational_category', '=', 'school'),
                     ])
                     year = _format_info(line[9:13])
                     academic_year = academic_year_obj.search([
                         ('name', 'ilike', '{}-'.format(year)),
                     ])
                 if line_type == '2':
                     op_type = _format_info(line[1:2])
                     id_type = idtype_obj.search([
                         ('education_code', '=', _format_info(line[2:6]))
                     ])
                     id_number = _format_info(line[6:21])
                     employee = employee_obj.search([
                         ('edu_idtype_id', '=', id_type.id),
                         ('identification_id', '=', id_number),
                     ])
                     user = (employee.user_id or user_obj.search(
                         [('vat', 'ilike', id_number),
                          ('edu_idtype_id', '=', id_type.id)]))
                     contract = hr_contract_obj.search([
                         ('employee_id', '=', employee.id),
                         ('ed_center_id', '=', center.id),
                         ('ed_academic_year_id', '=', academic_year.id),
                         ('state', 'not in', ['close', 'cancel'])
                     ])
                     if op_type == 'M':
                         # MODIFICACIÓN o ALTA
                         lastname = _format_info(line[21:71])
                         lastname2 = _format_info(line[71:121])
                         firstname = _format_info(line[121:151])
                         fullname = partner_obj._get_computed_name(
                             lastname, firstname, lastname2)
                         position1 = position_obj.search([
                             ('type', '=', 'normal'),
                             ('education_code', '=',
                              _format_info(line[151:154])),
                         ])
                         position2 = position_obj.search([
                             ('type', '=', 'normal'),
                             ('education_code', '=',
                              _format_info(line[154:157])),
                         ])
                         position3 = position_obj.search([
                             ('type', '=', 'other'),
                             ('education_code', '=',
                              _format_info(line[157:160])),
                         ])
                         department_name = _format_info(line[160:310])
                         department = department_obj.search([
                             ('name', '=', department_name)
                         ])
                         if not department:
                             department_obj.create({
                                 'name': department_name,
                             })
                         dcode = '0{}'.format(_format_info(line[310:312]))
                         designation = designation_obj.search([
                             ('education_code', '=', dcode),
                         ])
                         wcode = '00000{}'.format(
                             _format_info(line[312:316]))
                         workday_type = workday_type_obj.search([
                             ('education_code', '=', wcode),
                         ])
                         work_hours = _convert_time_str_to_float(
                             _format_info(line[316:321]))
                         class_hours = _convert_time_str_to_float(
                             _format_info(line[321:326]))
                         age = _format_info(line[326:327]) == '1'
                         health = _format_info(line[327:328]) == '1'
                         notes = _format_info(line[328:578])
                         workreason = workreason_obj.search([
                             ('education_code', '=',
                              _format_info(line[578:582]))
                         ])
                         date_str = _format_info(line[582:590])
                         if date_str != '':
                             date_start = datetime.strptime(
                                 date_str, '%d%m%Y')
                         else:
                             date_start = fields.Datetime.now()
                         date_start = fields.Datetime.to_string(date_start)
                         contract_type = contract_type_obj.search([
                             ('education_code', '=',
                              _format_info(line[590:594])),
                         ])
                         contract_hours = _convert_time_str_to_float(
                             _format_info(line[594:599]))
                         vals = {
                             'name': fullname,
                             'department_id': department.id,
                         }
                         if not user:
                             vals.update({
                                 'login': id_number,
                                 'vat': id_number,
                                 'edu_idtype_id': id_type.id,
                                 'lastname': lastname,
                                 'lastname2': lastname2,
                                 'firstname': firstname,
                             })
                             user = user_obj.create(vals)
                         if not employee:
                             vals.update({
                                 'edu_idtype_id': id_type.id,
                                 'identification_id': id_number,
                                 'user_id': user.id,
                                 'gender': False,
                                 'marital': False,
                             })
                             employee = employee_obj.create(vals)
                         else:
                             if not employee.user_id:
                                 vals.update({'user_id': user.id})
                             employee.write(vals)
                         contract_vals = {
                             'name':
                             '[{}] {}'.format(academic_year.display_name,
                                              employee.display_name),
                             'employee_id':
                             employee.id,
                             'department_id':
                             department.id,
                             'ed_center_id':
                             center.id,
                             'ed_academic_year_id':
                             academic_year.id,
                             'date_start':
                             date_start,
                             'ed_position_id':
                             position1.id,
                             'ed_position2_id':
                             position2.id,
                             'ed_otherposition_id':
                             position3.id,
                             'ed_designation_id':
                             designation.id,
                             'ed_workday_type_id':
                             workday_type.id,
                             'ed_contract_hours':
                             contract_hours,
                             'ed_work_reason_id':
                             workreason.id,
                             'ed_contract_type_id':
                             contract_type.id,
                             'ed_reduction_age':
                             age,
                             'ed_reduction_health':
                             health,
                             'ed_work_hours':
                             work_hours,
                             'ed_class_hours':
                             class_hours,
                             'notes':
                             notes,
                             'wage':
                             0.0,
                         }
                         if not contract:
                             hr_contract_obj.create(contract_vals)
                         else:
                             contract.write(contract_vals)
                     if op_type == 'B':
                         # BAJA
                         if contract:
                             # termination_code = _format_info(line[21:24])
                             date_end = \
                                 fields.Datetime.to_string(
                                     datetime.strptime(
                                         _format_info(line[24:32]),
                                         '%d%m%Y'))
                             contract.write({
                                 'date_end': date_end,
                             })
     action = self.env.ref('hr.open_view_employee_list_my')
     return action.read()[0]