Ejemplo n.º 1
0
    def setUpClass(cls):
        super(TestChannelAccessRights, cls).setUpClass()
        Channel = cls.env['mail.channel'].with_context(cls._test_context)

        cls.user_public = mail_new_test_user(cls.env,
                                             login='******',
                                             groups='base.group_public',
                                             name='Bert Tartignole')
        cls.user_portal = mail_new_test_user(cls.env,
                                             login='******',
                                             groups='base.group_portal',
                                             name='Chell Gladys')

        # Pigs: base group for tests
        cls.group_pigs = Channel.create({
            'name':
            'Pigs',
            'public':
            'groups',
            'group_public_id':
            cls.env.ref('base.group_user').id
        })
        # Jobs: public group
        cls.group_public = Channel.create({
            'name': 'Jobs',
            'description': 'NotFalse',
            'public': 'public'
        })
        # Private: private group
        cls.group_private = Channel.create({
            'name': 'Private',
            'public': 'private'
        })
Ejemplo n.º 2
0
    def setUpClass(cls):
        super(TestMailResend, cls).setUpClass()
        cls.test_record = cls.env['mail.test.simple'].with_context(
            cls._test_context).create({
                'name': 'Test',
                'email_from': '*****@*****.**'
            })

        #Two users
        cls.user1 = mail_new_test_user(cls.env,
                                       login='******',
                                       groups='base.group_public',
                                       name='Employee 1',
                                       email='e1')  # invalid email
        cls.user2 = mail_new_test_user(cls.env,
                                       login='******',
                                       groups='base.group_portal',
                                       name='Employee 2',
                                       email='*****@*****.**')
        #Two partner
        cls.partner1 = cls.env['res.partner'].with_context(
            cls._test_context).create({
                'name': 'Partner 1',
                'email': 'p1'  # invalid email
            })
        cls.partner2 = cls.env['res.partner'].with_context(
            cls._test_context).create({
                'name': 'Partner 2',
                'email': '*****@*****.**'
            })

        @api.model
        def send_email(self, message, *args, **kwargs):
            assert '@' in message['To'], self.NO_VALID_RECIPIENT
            return message['Message-Id']

        cls.bus_update_failure = []

        def sendone(self, channel, message):
            if 'type' in message and message['type'] == 'mail_failure':
                cls.bus_update_failure.append((channel, message))

        cls.env['ir.mail_server']._patch_method('send_email', send_email)
        cls.env['bus.bus']._patch_method('sendone', sendone)
        cls.partners = cls.env['res.partner'].concat(cls.user1.partner_id,
                                                     cls.user2.partner_id,
                                                     cls.partner1,
                                                     cls.partner2)
        cls.invalid_email_partners = cls.env['res.partner'].concat(
            cls.user1.partner_id, cls.partner1)
Ejemplo n.º 3
0
    def setUp(self):
        super().setUp()
        self.model = self.env[self.model_name]

        mail_new_test_user(self.env, login='******', password='******')
        self.authenticate('fof', '123456789')

        self.worksheet = {}  # mock worksheet

        self.default_params = {
            'domain': [],
            'fields': [{'name': field.name, 'label': field.string} for field in self.model._fields.values()],
            'groupby': [],
            'ids': False,
            'import_compat': False,
            'model': self.model._name,
        }
Ejemplo n.º 4
0
 def setUpClass(cls):
     super(MassSMSBaseFunctionalTest, cls).setUpClass()
     cls.user_marketing = mail_new_test_user(
         cls.env,
         login='******',
         groups='base.group_user,mass_mailing.group_mass_mailing_user',
         name='Martial Marketing',
         signature='--\nMartial')
Ejemplo n.º 5
0
    def setUp(self):
        super(TestMassMailPerformanceBase, self).setUp()

        self.user_employee = mail_new_test_user(self.env,
                                                login='******',
                                                groups='base.group_user',
                                                name='Ernest Employee',
                                                notification_type='inbox')

        self.user_marketing = mail_new_test_user(
            self.env,
            login='******',
            groups='base.group_user,mass_mailing.group_mass_mailing_user',
            name='Martial Marketing',
            signature='--\nMartial')

        # patch registry to simulate a ready environment
        self.patch(self.env.registry, 'ready', True)
Ejemplo n.º 6
0
    def setUp(self):
        super(TestHrCommon, self).setUp()

        self.res_users_hr_officer = mail_new_test_user(
            self.env,
            login='******',
            groups='base.group_user,hr.group_hr_user',
            name='HR Officer',
            email='*****@*****.**')
Ejemplo n.º 7
0
    def setUp(self):
        super(TestBLAccessRights, self).setUp()
        self.bl_rec = self.env['mail.blacklist'].create([
            {
                'email': 'Not A Stark <*****@*****.**>'
            },
        ])

        self.user_portal = mail_new_test_user(self.env,
                                              login='******',
                                              groups='base.group_portal')

        self.bl_previous = self.env['mail.blacklist'].search([])
Ejemplo n.º 8
0
    def setUpClass(cls):
        super(MassMailingCase, cls).setUpClass()

        # be sure for some common data
        cls.user_employee.write({
            'login': '******',
        })

        cls.user_marketing = mail_new_test_user(
            cls.env,
            login='******',
            groups='base.group_user,mass_mailing.group_mass_mailing_user',
            name='Martial Marketing',
            signature='--\nMartial')
Ejemplo n.º 9
0
    def test_body_responsive(self):
        """ Testing mail mailing responsive mail body """
        test_user = mail_new_test_user(
            self.env,
            login='******',
            groups=
            'mass_mailing.group_mass_mailing_user,base.group_partner_manager'  # TDE FIXME: check if really necessary for mass mailing
        )

        test_record = self.env['res.partner'].create(
            {'name': 'Mass Mail Partner'})
        mass_mail_record = self.env['mailing.mailing'].with_user(
            test_user).create({
                'name':
                'Test',
                'subject':
                'Test',
                'state':
                'draft',
                'mailing_model_id':
                self.env.ref('base.model_res_partner').id,
            })

        composer = self.env['mail.compose.message'].with_user(
            test_user).with_context({
                'default_composition_mode': 'mass_mail',
                'default_model': 'res.partner',
                'default_res_id': test_record.id,
            }).create({
                'subject': 'Mass Mail Responsive',
                'body': 'I am Responsive body',
                'mass_mailing_id': mass_mail_record.id
            })

        mail_values = composer.get_mail_values([test_record.id])
        body_html = str(mail_values[test_record.id]['body_html'])

        self.assertIn('<!DOCTYPE html>', body_html)
        self.assertIn('<head>', body_html)
        self.assertIn('viewport', body_html)
        self.assertIn('@media', body_html)
        self.assertIn('I am Responsive body', body_html)
Ejemplo n.º 10
0
    def test_message_compose_portal_ok(self):
        portal_user = mail_new_test_user(self.env,
                                         login='******',
                                         groups='base.group_portal',
                                         name='Chell Gladys')

        with patch.object(MailTestSimple,
                          'check_access_rights',
                          return_value=True):
            ComposerPortal = self.env['mail.compose.message'].with_user(
                portal_user)

            ComposerPortal.with_context({
                'default_composition_mode': 'comment',
                'default_model': self.test_record._name,
                'default_res_id': self.test_record.id,
            }).create({
                'subject': 'Subject',
                'body': '<p>Body text</p>',
                'partner_ids': []
            }).send_mail()

            self.assertEqual(self.test_record.message_ids[0].body,
                             '<p>Body text</p>')
            self.assertEqual(self.test_record.message_ids[0].author_id,
                             portal_user.partner_id)

            ComposerPortal.with_context({
                'default_composition_mode':
                'comment',
                'default_parent_id':
                self.test_record.message_ids.ids[0],
            }).create({
                'subject': 'Subject',
                'body': '<p>Body text 2</p>'
            }).send_mail()

            self.assertEqual(self.test_record.message_ids[0].body,
                             '<p>Body text 2</p>')
            self.assertEqual(self.test_record.message_ids[0].author_id,
                             portal_user.partner_id)
Ejemplo n.º 11
0
    def setUp(self):
        super(TestHrHolidaysBase, self).setUp()

        # Test users to use through the various tests
        self.user_hruser = mail_new_test_user(
            self.env,
            login='******',
            groups='base.group_user,hr_holidays.group_hr_holidays_user')
        self.user_hruser_id = self.user_hruser.id

        self.user_hrmanager = mail_new_test_user(
            self.env,
            login='******',
            groups='base.group_user,hr_holidays.group_hr_holidays_manager')
        self.user_hrmanager_id = self.user_hrmanager.id

        self.user_employee = mail_new_test_user(self.env,
                                                login='******',
                                                groups='base.group_user')
        self.user_employee_id = self.user_employee.id

        # Hr Data
        Department = self.env['hr.department'].with_context(
            tracking_disable=True)

        self.hr_dept = Department.create({
            'name': 'Human Resources',
        })
        self.rd_dept = Department.create({
            'name': 'Research and devlopment',
        })

        self.employee_emp = self.env['hr.employee'].create({
            'name':
            'David Employee',
            'user_id':
            self.user_employee_id,
            'department_id':
            self.rd_dept.id,
        })
        self.employee_emp_id = self.employee_emp.id

        self.employee_hruser = self.env['hr.employee'].create({
            'name':
            'Armande HrUser',
            'user_id':
            self.user_hruser_id,
            'department_id':
            self.rd_dept.id,
        })
        self.employee_hruser_id = self.employee_hruser.id

        self.employee_hrmanager = self.env['hr.employee'].create({
            'name':
            'Bastien HrManager',
            'user_id':
            self.user_hrmanager_id,
            'department_id':
            self.hr_dept.id,
            'parent_id':
            self.employee_hruser_id,
        })
        self.employee_hrmanager_id = self.employee_hrmanager.id

        self.rd_dept.write({'manager_id': self.employee_hruser_id})