Beispiel #1
0
    def test_ods_success(self):
        ods_file_path = get_module_resource('base_import', 'tests', 'test.ods')
        file_content = open(ods_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.oasis.opendocument.spreadsheet'
        })

        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'],
            ['aux', '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'])
Beispiel #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.')
Beispiel #3
0
    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'],
        ])
 def test_crm_claim_message_2categories(self):
     self.fetchmail_server.claim_category_ids = [(4, self.category2.id)]
     self.assertEquals(len(self.fetchmail_server.claim_category_ids), 2)
     with open(get_module_resource(
         'crm_claim_school', 'tests', 'customer_request.eml'), 'rb') as \
             request_file:
         request_message = request_file.read()
     self.env['mail.thread'].with_context(
         fetchmail_server_id=self.fetchmail_server.id).message_process(
             'crm.claim', request_message)
     claim = self.env['crm.claim'].search(
         [('email_from', '=', 'Mr. John Right <*****@*****.**>')],
         limit=1)
     self.assertTrue(claim, 'Failed to create claim')
     self.assertFalse(claim.categ_id)
Beispiel #5
0
 def create_docker_instance(self, domain_name=None):
     modules = [module.technical_name for module in self.saas_module_ids]
     host_server, db_server = self.saas_contract_id.plan_id.server_id.get_server_details(
     )
     response = None
     self.database_name = domain_name.replace("https://",
                                              "").replace("http://", "")
     config_path = get_module_resource('eagle_saas_kit')
     response = saas.main(
         dict(db_template=self.saas_contract_id.db_template,
              db_name=self.database_name,
              modules=modules,
              config_path=config_path,
              host_domain=domain_name,
              host_server=host_server,
              db_server=db_server))
     return response
Beispiel #6
0
 def drop_db(self):
     for obj in self:
         if obj.state == "inactive":
             host_server, db_server = obj.saas_contract_id.plan_id.server_id.get_server_details(
             )
             _logger.info("HOST SERER %r   DB SERVER  %r" %
                          (host_server, db_server))
             response = client.main(obj.database_name,
                                    obj.containter_port,
                                    host_server,
                                    get_module_resource('eagle_saas_kit'),
                                    from_drop_db=True)
             if not response['db_drop']:
                 raise UserError(
                     "ERROR: Couldn't Drop Client Database. Please Try Again Later.\n\nOperation\tStatus\n\nDrop database: \t{}\n"
                     .format(response['db_drop']))
             else:
                 obj.is_drop_db = True
Beispiel #7
0
 def create_db_template(self):
     for obj in self:
         if not obj.db_template:
             raise UserError("Please select the DB template name first.")
         if re.match("^template_", obj.db_template):
             raise UserError(
                 "Couldn't Create DB. Please try again with some other Template Name!"
             )
         db_template_name = "template_{}".format(obj.db_template)
         modules = [module.technical_name for module in obj.saas_module_ids]
         config_path = get_module_resource('eagle_saas_kit')
         modules.append('wk_saas_tool')
         try:
             host_server, db_server = obj.server_id.get_server_details()
             response = saas.create_db_template(
                 db_template=db_template_name,
                 modules=modules,
                 config_path=config_path,
                 host_server=host_server,
                 db_server=db_server)
         except Exception as e:
             _logger.info("--------DB-TEMPLATE-CREATION-EXCEPTION-------%r",
                          e)
             raise UserError(e)
         else:
             if response:
                 if response.get('status', False):
                     obj.db_template = db_template_name
                     obj.state = 'confirm'
                     obj.container_id = response.get('container_id', False)
                 else:
                     msg = response.get('msg', False)
                     if msg:
                         raise UserError(msg)
                     else:
                         raise UserError(
                             "Unknown Error. Please try again later with some different Template Name"
                         )
             else:
                 raise UserError(
                     "No Response. Please try again later with some different Template Name"
                 )
Beispiel #8
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()
Beispiel #9
0
 def drop_container(self):
     for obj in self:
         if obj.state == "inactive":
             host_server, db_server = obj.saas_contract_id.plan_id.server_id.get_server_details(
             )
             _logger.info("HOST SERER %r   DB SERVER  %r" %
                          (host_server, db_server))
             response = client.main(obj.database_name,
                                    obj.containter_port,
                                    host_server,
                                    get_module_resource('eagle_saas_kit'),
                                    container_id=obj.container_id,
                                    db_server=db_server,
                                    from_drop_container=True)
             if not response['drop_container'] or not response[
                     'delete_nginx_vhost'] or not response[
                         'delete_data_dir']:
                 raise UserError(
                     "ERROR: Couldn't Drop Client Container. Please Try Again Later.\n\nOperation\tStatus\n\nDelete Domain Mapping: \t{}\nDelete Data Directory: \t{}"
                     .format(response['drop_container'],
                             response['delete_nginx_vhost']))
             else:
                 obj.is_drop_container = True
Beispiel #10
0
    def test_ubl_invoice_import(self):
        xml_file_path = get_module_resource('l10n_be_edi', 'test_xml_file',
                                            'efff_test.xml')
        xml_file = open(xml_file_path, 'rb').read()
        invoice = self.env['account.move'].with_context(
            default_type='in_invoice').create({})

        attachment_id = self.env['ir.attachment'].create({
            'name':
            'efff_test.xml',
            'datas':
            base64.encodestring(xml_file),
            'res_id':
            invoice.id,
            'res_model':
            'account.move',
        })

        invoice.message_post(attachment_ids=[attachment_id.id])

        self.assertEqual(invoice.amount_total, 666.50)
        self.assertEqual(invoice.amount_tax, 115.67)
        self.assertEqual(invoice.partner_id, self.partner_id)
Beispiel #11
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'purchase',
                        get_module_resource(module, *args), {}, 'init',
                        False, 'test', self.registry._assertion_report)
Beispiel #12
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()))