Exemple #1
0
    def _last_time_education(self):
        for rec in self:
            if rec.last_education_from_month and rec.last_education_from_year:
                rec.last_time_education = intern_utils.date_time_in_jp(
                    None, rec.last_education_from_month,
                    rec.last_education_from_year)
            else:
                rec.last_time_education = ""
            if rec.last_education_from_year and rec.last_education_to_year:
                rec.last_time_education = rec.last_time_education + u'~ '

            if rec.last_education_to_month and rec.last_education_to_year:
                rec.last_time_education = rec.last_time_education + \
                                           intern_utils.date_time_in_jp(None,rec.last_education_to_month,rec.last_education_to_year)
Exemple #2
0
    def _last_time_education2(self):
        for rec in self:
            if rec.last_education_from_month2 and rec.last_education_from_year2:
                rec.last_time_education2 = intern_utils.date_time_in_jp(
                    None, rec.last_education_from_month2,
                    rec.last_education_from_year2)
            else:
                rec.last_time_education2 = ""
            if rec.last_education_from_year2 and rec.last_education_to_year2:
                rec.last_time_education2 = rec.last_time_education2 + u'~ '

            if rec.last_education_to_month2 and rec.last_education_to_year2:
                rec.last_time_education2 = rec.last_time_education2 + \
                                          intern_utils.date_time_in_jp(None, rec.last_education_to_month2,
                                                                       rec.last_education_to_year2)
Exemple #3
0
    def _time_employee5(self):
        for rec in self:
            if rec.time_employee5_from_year:
                rec.time_employee5 = intern_utils.date_time_in_jp(
                    None, rec.time_employee5_from_month,
                    rec.time_employee5_from_year)
            else:
                rec.time_employee5 = ""

            if rec.time_employee5_from_year and rec.time_employee5_to_year:
                rec.time_employee5 = rec.time_employee5 + u'~ '

            if rec.time_employee5_to_year:
                rec.time_employee5 = rec.time_employee5 + \
                                     intern_utils.date_time_in_jp(None, rec.time_employee5_to_month,
                                                                  rec.time_employee5_to_year)
Exemple #4
0
    def _time_start_at_pc(self):
        for rec in self:
            if rec.time_start_at_pc_from_year:
                rec.time_start_at_pc = intern_utils.date_time_in_jp(
                    None, rec.time_start_at_pc_from_month,
                    rec.time_start_at_pc_from_year)
            else:
                rec.time_start_at_pc = ""

            if rec.time_start_at_pc_from_year:
                rec.time_start_at_pc = rec.time_start_at_pc + u'~ 現在'
Exemple #5
0
    def createHeaderDocNew(self, gender=None):
        docs = self.env['intern.document'].search([('name', '=', "CV_HEAD")],
                                                  limit=1)
        logo = self.env['intern.document'].search([('name', '=', "Logo")],
                                                  limit=1)
        streamDoc = BytesIO(docs[0].attachment.decode("base64"))
        target_document = None
        tempFile1 = None
        lentmp = len(self.interns_exam_doc)
        if gender != None:
            lentmp = 0
            for intern in self.interns_exam_doc:
                if intern.gender == gender:
                    lentmp += 1

        if lentmp > 20:
            target_document = Document(streamDoc)
            tmp = lentmp / 20
            for i in range(1, tmp + 1):
                document = Document(streamDoc)
                for table in document.tables:
                    for row in table.rows:
                        for cell in row.cells:
                            if 'tbl_intern' in cell.text:
                                cell.text = cell.text.replace(
                                    'tbl_intern', 'tbl_intern%d' % i)
                                break
                # target_document.add_page_break()
                for element in document.element.body:
                    target_document.element.body.append(element)

            tempFile1 = NamedTemporaryFile(delete=False)
            target_document.save(tempFile1.name)
            tempFile1.flush()
            tempFile1.close()

        if docs:
            tpl = None
            if target_document is None:
                stream = BytesIO(docs[0].attachment.decode("base64"))
                tpl = DocxTemplate(stream)
            else:
                tpl = DocxTemplate(tempFile1.name)

            context = {}
            interns = self.interns_exam_doc.sorted(
                key=lambda x: x.sequence_exam)

            counter_index = 0
            for k in range(0, lentmp / 20 + 1):
                table_interns = []
                for i in range(20 * k, 20 * k + 20):
                    if i >= lentmp:
                        break
                    if gender == None:
                        intern = interns[i]
                    else:
                        while counter_index < len(interns):
                            if interns[counter_index].gender == gender:
                                intern = interns[counter_index]
                                counter_index += 1
                                break
                            counter_index += 1

                    info = {}
                    info['stt'] = str(i + 1)
                    info['htk'] = intern.name_without_signal.upper()
                    info['htn'] = intern.name_in_japan
                    if intern.gender == 'nu':
                        info['gt'] = u'女'
                    else:
                        info['gt'] = u'男'
                    info['ns'] = intern_utils.date_time_in_jp(
                        intern.day, intern.month, intern.year)
                    info['t'] = str(
                        intern_utils.get_age_jp(datetime.now(), intern.day,
                                                intern.month, intern.year))
                    info['nm'] = intern.blood_group

                    left = 1.5 - (10.0 - intern.vision_left) / 10.0
                    right = 1.5 - (10.0 - intern.vision_right) / 10.0
                    info['tlt'] = "%.1f" % (left)
                    info['tlp'] = "%.1f" % (right)
                    if intern.preferred_hand == '0':
                        info['tt'] = u'右'
                    elif intern.preferred_hand == '1':
                        info['tt'] = u'左'
                    else:
                        info['tt'] = u'両手'
                    info['cc'] = str(intern.height)
                    info['cn'] = str(intern.weight)
                    info['iq'] = "%s%%" % intern.iq_percentage
                    info['ktk'] = intern.check_kureperin
                    info['hn'] = intern.marital_status.name_in_jp
                    if intern.province:
                        info['pro'] = intern_utils.no_accent_vietnamese(
                            intern.province.name).upper()
                    info['bc'] = intern.certification.name_in_jp
                    table_interns.append(info)

                if k == 0:
                    context['tbl_intern'] = table_interns
                else:
                    context['tbl_intern%d' % k] = table_interns

            context['logo'] = InlineImage(
                tpl,
                BytesIO(logo[0].attachment.decode("base64")),
                width=Mm(35))
            if self.enterprise_doc:
                context['xn'] = self.enterprise_doc.name_jp
            context['nd'] = self.guild.name_in_jp
            context['now'] = intern_utils.date_time_in_jp(
                datetime.now().day,
                datetime.now().month,
                datetime.now().year)

            tpl.render(context)

            tempFile = NamedTemporaryFile(delete=False)
            tpl.save(tempFile)
            tempFile.flush()
            tempFile.close()

            if tempFile1 is not None:
                os.unlink(tempFile1.name)

            return tempFile
        if tempFile1 is not None:
            os.unlink(tempFile1.name)
        return None
Exemple #6
0
 def _date_sign_agreement(self):
     for rec in self:
         rec.date_sign_agreement = intern_utils.date_time_in_jp(
             rec.day_sign, rec.month_sign, rec.year_sign)
Exemple #7
0
 def _date_create(self):
     for rec in self:
         rec.date_create = intern_utils.date_time_in_jp(
             rec.date_create, rec.month_create, rec.year_create)