コード例 #1
0
ファイル: test_base_import.py プロジェクト: yasr3mr96/actpy
    def test_xlsx_success(self):
        xlsx_file_path = get_module_resource('base_import', 'tests',
                                             'test.xlsx')
        file_content = open(xlsx_file_path, 'rb').read()
        import_wizard = self.env['base_import.import'].create({
            'res_model':
            'base_import.tests.models.preview',
            'file':
            file_content,
            'file_type':
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        })

        result = import_wizard.parse_preview({
            'headers': True,
        })
        self.assertIsNone(result.get('error'))
        self.assertEqual(result['matches'], {
            0: ['name'],
            1: ['somevalue'],
            2: None
        })
        self.assertEqual(result['headers'], ['name', 'Some Value', 'Counter'])
        self.assertItemsEqual(result['fields'], [
            ID_FIELD,
            {
                'id': 'name',
                'name': 'name',
                'string': 'Name',
                'required': False,
                'fields': [],
                'type': 'char'
            },
            {
                'id': 'somevalue',
                'name': 'somevalue',
                'string': 'Some Value',
                'required': True,
                'fields': [],
                'type': 'integer'
            },
            {
                'id': 'othervalue',
                'name': 'othervalue',
                'string': 'Other Variable',
                'required': False,
                'fields': [],
                'type': 'integer'
            },
        ])
        self.assertEqual(result['preview'], [
            ['foo', '1', '2'],
            ['bar', '3', '4'],
            ['qux', '5', '6'],
        ])
        # Ensure we only have the response fields we expect
        self.assertItemsEqual(list(result), [
            'matches', 'headers', 'fields', 'preview', 'headers_type',
            'options', 'advanced_mode', 'debug'
        ])
コード例 #2
0
    def test_00_recruitment_process(self):
        """ Test recruitment process """

        # Create a new HR Recruitment Officer
        self.res_users_hr_recruitment_officer = self.env['res.users'].create({
            'company_id':
            self.env.ref('base.main_company').id,
            'name':
            'HR Recruitment Officer',
            'login':
            "******",
            'email':
            "*****@*****.**",
            'groups_id':
            [(6, 0,
              [self.env.ref('hr_recruitment.group_hr_recruitment_user').id])]
        })

        # An applicant is interested in the job position. So he sends a resume by email.
        # In Order to test process of Recruitment so giving HR officer's rights
        with open(get_module_resource('hr_recruitment', 'tests', 'resume.eml'),
                  'rb') as request_file:
            request_message = request_file.read()
        self.env['mail.thread'].sudo(
            self.res_users_hr_recruitment_officer.id).message_process(
                'hr.applicant',
                request_message,
                custom_values={"job_id": self.env.ref('hr.job_developer').id})

        # After getting the mail, I check the details of the new applicant.
        applicant = self.env['hr.applicant'].search(
            [('email_from', '=',
              'Mr. Richard Anderson <*****@*****.**>')],
            limit=1)
        self.assertTrue(applicant,
                        "Applicant is not created after getting the mail")
        resume_ids = self.env['ir.attachment'].search([
            ('datas_fname', '=', 'resume.pdf'),
            ('res_model', '=', self.env['hr.applicant']._name),
            ('res_id', '=', applicant.id)
        ])
        self.assertEquals(
            applicant.name,
            'Application for the post of Jr.application Programmer.',
            'Applicant name does not match.')
        self.assertEquals(
            applicant.stage_id, self.env.ref('hr_recruitment.stage_job1'),
            "Stage should be 'Initial qualification' and is '%s'." %
            (applicant.stage_id.name))
        self.assertTrue(resume_ids, 'Resume is not attached.')
        # I assign the Job position to the applicant
        applicant.write({'job_id': self.env.ref('hr.job_developer').id})
        # I schedule meeting with applicant for interview.
        applicant_meeting = applicant.action_makeMeeting()
        self.assertEquals(
            applicant_meeting['context']['default_name'],
            'Application for the post of Jr.application Programmer.',
            'Applicant name does not match.')
コード例 #3
0
    def test_crm_lead_message(self):
        # Give the access rights of Salesman to communicate with customer
        # Customer interested in our product, so he sends request by email to get more details.
        # Mail script will fetch his request from mail server. Then I process that mail after read EML file.
        request_file = open(
            get_module_resource('crm', 'tests', 'customer_request.eml'), 'rb')
        request_message = request_file.read()
        self.env['mail.thread'].sudo(self.crm_salesman).message_process(
            'crm.lead', request_message)

        # After getting the mail, I check details of new lead of that customer
        lead = self.env['crm.lead'].sudo(self.crm_salesman).search(
            [('email_from', '=', 'Mr. John Right <*****@*****.**>')],
            limit=1)
        self.assertTrue(lead.ids, 'Fail to create merge opportunity wizard')
        self.assertFalse(lead.partner_id, 'Customer should be a new one')
        self.assertEqual(lead.name,
                         'Fournir votre devis avec le meilleur prix.',
                         'Subject does not match')

        # I reply his request with welcome message.
        # TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
        lead = self.env['crm.lead'].search(
            [('email_from', '=', 'Mr. John Right <*****@*****.**>')],
            limit=1)
        mail = self.env['mail.compose.message'].with_context(
            active_model='crm.lead', active_id=lead.id
        ).create({
            'body':
            "Merci de votre intérêt pour notre produit, nous vous contacterons bientôt. Bien à vous",
            'email_from': '*****@*****.**'
        })
        try:
            mail.send_mail()
        except:
            pass

        # Now, I convert him into customer and put him into regular customer list
        lead = self.env['crm.lead'].search(
            [('email_from', '=', 'Mr. John Right <*****@*****.**>')],
            limit=1)
        lead.handle_partner_assignation()
コード例 #4
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'hr_payroll_account',
                        get_module_resource(module, *args), {}, 'init',
                        False, 'test', self.registry._assertion_report)
コード例 #5
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'report_intrastat',
                        get_module_resource(module, *args), {}, 'init',
                        False, 'test', self.registry._assertion_report)
コード例 #6
0
 def _default_image(self):
     image_path = get_module_resource('hr', 'static/src/img',
                                      'default_image.png')
     return tools.image_resize_image_big(
         base64.b64encode(open(image_path, 'rb').read()))