예제 #1
0
    def setUp(self):
        super().setUp()
        self.model = self.env[self.model_name]

        mail_new_test_user(self.env,
                           login='******',
                           password='******',
                           groups='base.group_user,base.group_allow_export')
        self.session = 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,
        }
예제 #2
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')

        # setup mail gateway
        self.alias_domain = 'example.com'
        self.alias_catchall = 'catchall.test'
        self.alias_bounce = 'bounce.test'
        self.default_from = 'notifications'
        self.env['ir.config_parameter'].set_param('mail.bounce.alias', self.alias_bounce)
        self.env['ir.config_parameter'].set_param('mail.catchall.domain', self.alias_domain)
        self.env['ir.config_parameter'].set_param('mail.catchall.alias', self.alias_catchall)
        self.env['ir.config_parameter'].set_param('mail.default.from', self.default_from)

        # patch registry to simulate a ready environment
        self.patch(self.env.registry, 'ready', True)
예제 #3
0
    def setUpClass(cls):
        super(TestAccessRating, cls).setUpClass()

        cls.user_manager_partner = mail_new_test_user(
            cls.env,
            name='Jean Admin',
            login='******',
            email='*****@*****.**',
            groups='base.group_partner_manager,base.group_system')

        cls.user_emp = mail_new_test_user(cls.env,
                                          name='Eglantine Employee',
                                          login='******',
                                          email='*****@*****.**',
                                          groups='base.group_user')

        cls.user_portal = mail_new_test_user(cls.env,
                                             name='Patrick Portal',
                                             login='******',
                                             email='*****@*****.**',
                                             groups='base.group_portal')

        cls.user_public = mail_new_test_user(cls.env,
                                             name='Pauline Public',
                                             login='******',
                                             email='*****@*****.**',
                                             groups='base.group_public')

        cls.partner_to_rate = cls.env['res.partner'].with_user(
            cls.user_manager_partner).create({"name": "Partner to Rate :("})
예제 #4
0
    def setUp(self):
        super(TestWebsiteEventAccess, self).setUp()

        self.events = self.env['event.event'].create([{
            'name': 'Event 0 - Sitemap test',
            'website_published': True,
            'date_begin': datetime.today() - timedelta(days=1),
            'date_end': datetime.today() + timedelta(days=1),
        }, {
            'name': 'Event 1 - Sitemap test',
            'website_published': True,
            'date_begin': datetime.today() - timedelta(days=1),
            'date_end': datetime.today() + timedelta(days=1),
        }, {
            'name': 'Event 2 - Sitemap test',
            'date_begin': datetime.today() - timedelta(days=1),
            'date_end': datetime.today() + timedelta(days=1),
        }])

        self.event_manager = mail_new_test_user(
            self.env, name='Gandalf le blanc', login='******', password='******', email='*****@*****.**',
            groups='event.group_event_manager,base.group_user'
        )

        self.event_user = mail_new_test_user(
            self.env, name='Frodon Sacquet', login='******', password='******', email='*****@*****.**',
            groups='event.group_event_user,base.group_user'
        )

        self.portal_user = mail_new_test_user(
            self.env, name='Smeagol', login='******', password='******', email='*****@*****.**',
            groups='base.group_portal'
        )
예제 #5
0
    def setUpClass(cls):
        super(StockQuant, cls).setUpClass()
        cls.demo_user = mail_new_test_user(
            cls.env,
            name='Pauline Poivraisselle',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='base.group_user',
        )
        cls.stock_user = mail_new_test_user(
            cls.env,
            name='Pauline Poivraisselle',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='stock.group_stock_user',
        )

        cls.product = cls.env['product.product'].create({
            'name': 'Product A',
            'type': 'product',
        })
        cls.product_lot = cls.env['product.product'].create({
            'name': 'Product A',
            'type': 'product',
            'tracking': 'lot',
        })
        cls.product_consu = cls.env['product.product'].create({
            'name': 'Product A',
            'type': 'consu',
        })
        cls.product_serial = cls.env['product.product'].create({
            'name':
            'Product A',
            'type':
            'product',
            'tracking':
            'serial',
        })
        cls.stock_location = cls.env['stock.location'].create({
            'name':
            'stock_location',
            'usage':
            'internal',
        })
        cls.stock_subloc2 = cls.env['stock.location'].create({
            'name':
            'subloc2',
            'usage':
            'internal',
            'location_id':
            cls.stock_location.id,
        })
예제 #6
0
    def setUpClass(cls, chart_template_ref=None):
        super().setUpClass(chart_template_ref=chart_template_ref)

        group_expense_manager = cls.env.ref(
            'hr_expense.group_hr_expense_manager')

        cls.expense_user_employee = mail_new_test_user(
            cls.env,
            name='expense_user_employee',
            login='******',
            email='*****@*****.**',
            notification_type='email',
            groups='base.group_user',
            company_ids=[(6, 0, cls.env.companies.ids)],
        )
        cls.expense_user_manager = mail_new_test_user(
            cls.env,
            name='Expense manager',
            login='******',
            email='*****@*****.**',
            notification_type='email',
            groups='base.group_user,hr_expense.group_hr_expense_manager',
            company_ids=[(6, 0, cls.env.companies.ids)],
        )

        cls.expense_employee = cls.env['hr.employee'].create({
            'name':
            'expense_employee',
            'user_id':
            cls.expense_user_employee.id,
            'address_home_id':
            cls.expense_user_employee.partner_id.id,
            'address_id':
            cls.expense_user_employee.partner_id.id,
        })

        # Allow the current accounting user to access the expenses.
        cls.env.user.groups_id |= group_expense_manager

        # Create analytic account
        cls.analytic_account_1 = cls.env['account.analytic.account'].create({
            'name':
            'analytic_account_1',
        })
        cls.analytic_account_2 = cls.env['account.analytic.account'].create({
            'name':
            'analytic_account_2',
        })

        # Ensure products can be expensed.
        (cls.product_a + cls.product_b).write({'can_be_expensed': True})
예제 #7
0
    def setUpClass(cls):
        super(TestSalesCommon, cls).setUpClass()

        # Salesmen organization
        # ------------------------------------------------------------
        # Role: M (team member) R (team manager)
        # SALESMAN---------------sales_team_1
        # admin------------------M-----------
        # user_sales_manager-----R-----------
        # user_sales_leads-------M-----------
        # user_sales_salesman----/-----------

        # Sales teams organization
        # ------------------------------------------------------------
        # SALESTEAM-----------SEQU-----COMPANY
        # sales_team_1--------5--------False
        # data----------------9999-----??

        cls.company_main = cls.env.user.company_id
        cls.user_sales_manager = mail_new_test_user(
            cls.env, login='******',
            name='Martin Sales Manager', email='*****@*****.**',
            company_id=cls.company_main.id,
            notification_type='inbox',
            groups='sales_team.group_sale_manager,base.group_partner_manager',
        )
        cls.user_sales_leads = mail_new_test_user(
            cls.env, login='******',
            name='Laetitia Sales Leads', email='*****@*****.**',
            company_id=cls.company_main.id,
            notification_type='inbox',
            groups='sales_team.group_sale_salesman_all_leads,base.group_partner_manager',
        )
        cls.user_sales_salesman = mail_new_test_user(
            cls.env, login='******',
            name='Orteil Sales Own', email='*****@*****.**',
            company_id=cls.company_main.id,
            notification_type='inbox',
            groups='sales_team.group_sale_salesman',
        )
        cls.user_admin = cls.env.ref('base.user_admin')

        cls.env['crm.team'].search([]).write({'sequence': 9999})
        cls.sales_team_1 = cls.env['crm.team'].create({
            'name': 'Test Sales Team',
            'sequence': 5,
            'company_id': False,
            'user_id': cls.user_sales_manager.id,
            'member_ids': [(4, cls.user_sales_leads.id), (4, cls.user_admin.id)],
        })
예제 #8
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)
예제 #9
0
    def test_edit_removal_date_in_inventory_mode(self):
        """ Try to edit removal_date with the inventory mode.
        """
        user_group_stock_manager = self.env.ref('stock.group_stock_manager')
        self.demo_user = mail_new_test_user(
            self.env,
            name='Demo user',
            login='******',
            email='*****@*****.**',
            groups='stock.group_stock_manager',
        )
        lot_form = Form(self.LotObj)
        lot_form.name = 'LOT001'
        lot_form.product_id = self.apple_product
        lot_form.company_id = self.env.company
        apple_lot = lot_form.save()

        quant = self.StockQuantObj.with_context(inventory_mode=True).create({
            'product_id':
            self.apple_product.id,
            'location_id':
            self.stock_location,
            'quantity':
            10,
            'lot_id':
            apple_lot.id,
        })
        # Try to write on quant with inventory mode
        new_date = datetime.today() + timedelta(days=15)
        quant.with_user(self.demo_user).with_context(
            inventory_mode=True).write({'removal_date': new_date})
        self.assertEqual(quant.removal_date, new_date)
    def test_edit_quant_3(self):
        """ Try to edit a record without the inventory mode.
        Must raise an error.
        """
        self.demo_user = mail_new_test_user(
            self.env,
            name='Pauline Poivraisselle',
            login='******',
            email='*****@*****.**',
            groups='base.group_user',
        )
        user_admin = self.env.ref('base.user_admin')
        quant = self.Quant.create({
            'product_id': self.product.id,
            'location_id': self.room1.id,
            'quantity': 12
        })
        self.assertEqual(quant.quantity, 12)
        # Try to write on quant without permission
        with self.assertRaises(AccessError):
            quant.with_user(self.demo_user).write({'inventory_quantity': 8})
        self.assertEqual(quant.quantity, 12)

        # Try to write on quant with permission
        quant.with_user(user_admin).write({'inventory_quantity': 8})
        self.assertEqual(quant.quantity, 8)
예제 #11
0
    def test_approval_and_forecasted_qty(self):
        """
        When a PO is waiting for an approval, its quantities should be included
        in the draft quantity count
        """
        self.env.company.po_double_validation = 'two_step'
        self.env.company.po_double_validation_amount = 0

        basic_purchase_user = mail_new_test_user(
            self.env,
            login='******',
            groups='base.group_user,purchase.group_purchase_user',
        )

        po_form = Form(self.env['purchase.order'])
        po_form.partner_id = self.partner
        with po_form.order_line.new() as line:
            line.product_id = self.product
            line.product_qty = 50
        po_form.save()

        po_form = Form(self.env['purchase.order'])
        po_form.partner_id = self.partner
        with po_form.order_line.new() as line:
            line.product_id = self.product
            line.product_qty = 100
        po = po_form.save()
        po.with_user(basic_purchase_user).button_confirm()

        docs = self.get_report_forecast(product_template_ids=self.product_template.ids)[1]
        self.assertEqual(docs['draft_purchase_qty'], 150)
예제 #12
0
    def setUp(self):
        super(TestPartnerLeadPortal, self).setUp()
        # Partner Grade
        self.grade = self.env['res.partner.grade'].create({
            'name': "Grade Test",
            'partner_weight': 42,
            'sequence': 3,
        })
        # Integrating user/partner, having a salesman
        self.user_portal = mail_new_test_user(
            self.env, login='******',
            name='Patrick Portal', email='*****@*****.**',
            company_id=self.env.ref("base.main_company").id,
            grade_id=self.grade.id,
            user_id=self.user_sales_manager.id,
            notification_type='inbox',
            groups='base.group_portal',
        )

        # New lead, assigned to the new portal
        self.lead_portal = self.env['crm.lead'].with_context(mail_notrack=True).create({
            'type': "lead",
            'name': "Test lead new",
            'user_id': False,
            'team_id': False,
            'description': "This is the description of the test new lead.",
            'partner_assigned_id': self.user_portal.partner_id.id
        })
예제 #13
0
    def setUpClass(cls):
        super(TestLivechatLead, cls).setUpClass()

        cls.user_anonymous = mail_new_test_user(
            cls.env, login='******',
            name='Anonymous Website', email=False,
            company_id=cls.company_main.id,
            notification_type='inbox',
            groups='base.group_public',
        )
        cls.user_portal = mail_new_test_user(
            cls.env, login='******',
            name='Paulette Portal', email='*****@*****.**',
            company_id=cls.company_main.id,
            notification_type='inbox',
            groups='base.group_portal',
        )
예제 #14
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='*****@*****.**')
예제 #15
0
 def setUpClass(cls):
     super().setUpClass()
     cls.user_admin = mail_new_test_user(cls.env,
                                         login='******',
                                         groups='base.group_system')
     cls.basic_user = mail_new_test_user(cls.env,
                                         login='******',
                                         groups='base.group_user')
     sms_enabled_models = cls.env['ir.model'].search([
         ('is_mail_thread', '=', True), ('transient', '=', False)
     ])
     vals = []
     for model in sms_enabled_models:
         vals.append({
             'name': 'SMS Template ' + model.name,
             'body': 'Body Test',
             'model_id': model.id,
         })
     cls.sms_templates = cls.env['sms.template'].create(vals)
예제 #16
0
 def test_project_specific_remove_mutliple_tasks(self):
     self.project_pigs.allowed_user_ids = self.user
     john = mail_new_test_user(self.env, login='******')
     task = self.create_task('task')
     self.task.allowed_user_ids |= john
     self.project_pigs.allowed_user_ids -= self.user
     self.assertIn(john, self.task.allowed_user_ids)
     self.assertNotIn(john, task.allowed_user_ids)
     self.assertNotIn(self.user, task.allowed_user_ids)
     self.assertNotIn(self.user, self.task.allowed_user_ids)
예제 #17
0
    def setUpClass(cls):
        super(TestMessageAccess, cls).setUpClass()

        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')

        Channel = cls.env['mail.channel'].with_context(cls._test_context)
        # 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 gtroup
        cls.group_private = Channel.create({
            'name': 'Private',
            'public': 'private'
        })
        cls.message = cls.env['mail.message'].create({
            'body':
            'My Body',
            'model':
            'mail.channel',
            'res_id':
            cls.group_private.id,
        })
예제 #18
0
    def setUpClass(cls):
        super(TestWebsiteEventCommon, cls).setUpClass()

        cls.company_main = cls.env.user.company_id
        cls.user_event_web_manager = mail_new_test_user(
            cls.env,
            login='******',
            name='Martin Sales Manager',
            email='*****@*****.**',
            company_id=cls.company_main.id,
            notification_type='inbox',
            groups='event.group_event_manager,website.group_website_designer',
        )
예제 #19
0
    def setUpClass(cls):
        super(TestMailComposer, cls).setUpClass()
        cls._init_mail_gateway()

        # ensure employee can create partners, necessary for templates
        cls.user_employee.write({
            'groups_id': [(4, cls.env.ref('base.group_partner_manager').id)],
        })

        cls.user_employee_2 = mail_new_test_user(
            cls.env, login='******', groups='base.group_user',
            notification_type='email', email='*****@*****.**',
            name='Eglantine Employee', signature='--\nEglantine')
        cls.partner_employee_2 = cls.user_employee_2.partner_id

        cls.test_record = cls.env['mail.test.ticket'].with_context(cls._test_context).create({
            'name': 'TestRecord',
            'customer_id': cls.partner_1.id,
            'user_id': cls.user_employee_2.id,
        })
        cls.test_records, cls.test_partners = cls._create_records_for_batch('mail.test.ticket', 2)

        cls.test_report = cls.env['ir.actions.report'].create({
            'name': 'Test Report on mail test ticket',
            'model': 'mail.test.ticket',
            'report_type': 'qweb-pdf',
            'report_name': 'test_mail.mail_test_ticket_test_template',
        })
        cls.test_record_report = cls.test_report._render_qweb_pdf(cls.test_report.ids)

        cls.test_from = '"John Doe" <*****@*****.**>'

        cls.mail_server = cls.env['ir.mail_server'].create({
            'name': 'Dummy Test Server',
            'smtp_host': 'smtp.pizza.moc',
            'smtp_port': 17,
            'smtp_encryption': 'ssl',
            'sequence': 666,
        })

        cls.template = cls.env['mail.template'].create({
            'name': 'TestTemplate',
            'subject': 'TemplateSubject ${object.name}',
            'body_html': '<p>TemplateBody ${object.name}</p>',
            'partner_to': '${object.customer_id.id if object.customer_id else ""}',
            'email_to': '${(object.email_from if not object.customer_id else "") | safe}',
            'email_from': '${(object.user_id.email_formatted or user.email_formatted) | safe}',
            'model_id': cls.env['ir.model']._get('mail.test.ticket').id,
            'mail_server_id': cls.mail_server.id,
            'auto_delete': True,
        })
예제 #20
0
    def setUpClass(cls):
        super(TestStockCommon, cls).setUpClass()

        # User Data: stock user and stock manager
        cls.user_stock_user = mail_new_test_user(
            cls.env,
            name='Pauline Poivraisselle',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='stock.group_stock_user',
        )
        cls.user_stock_manager = mail_new_test_user(
            cls.env,
            name='Julie Tablier',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='stock.group_stock_manager',
        )

        # Warehouses
        cls.warehouse_1 = cls.env['stock.warehouse'].create({
            'name': 'Base Warehouse',
            'reception_steps': 'one_step',
            'delivery_steps': 'ship_only',
            'code': 'BWH'})

        # Locations
        cls.location_1 = cls.env['stock.location'].create({
            'name': 'TestLocation1',
            'posx': 3,
            'location_id': cls.warehouse_1.lot_stock_id.id,
        })

        # Existing data
        cls.existing_inventories = cls.env['stock.inventory'].search([])
        cls.existing_quants = cls.env['stock.quant'].search([])
예제 #21
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',
                                       notification_type='email',
                                       email='e1')  # invalid email
        cls.user2 = mail_new_test_user(cls.env,
                                       login='******',
                                       groups='base.group_portal',
                                       name='Employee 2',
                                       notification_type='email',
                                       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': '*****@*****.**'
            })
        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)
예제 #22
0
    def setUpClass(cls):
        super(MassMailCommon, cls).setUpClass()

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

        cls.email_reply_to = 'MyCompany SomehowAlias <*****@*****.**>'

        cls.env['base'].flush()
예제 #23
0
    def setUpClass(cls):
        super(TestChannelModeration, cls).setUpClass()

        cls.channel_1 = cls.env['mail.channel'].create({
            'name': 'Moderation_1',
            'email_send': True,
            'moderation': True,
            'channel_partner_ids': [(4, cls.partner_employee.id)],
            'moderator_ids': [(4, cls.user_employee.id)],
        })

        # ensure initial data
        cls.user_employee_2 = mail_new_test_user(
            cls.env, login='******', groups='base.group_user', company_id=cls.company_admin.id,
            name='Enguerrand Employee2', notification_type='inbox', signature='--\nEnguerrand'
        )
        cls.partner_employee_2 = cls.user_employee_2.partner_id

        cls.user_portal = cls._create_portal_user()
예제 #24
0
    def setUp(self):
        super(TestCreatePicking, self).setUp()
        self.partner_id = self.env['res.partner'].create(
            {'name': 'Wood Corner Partner'})
        self.product_id_1 = self.env['product.product'].create(
            {'name': 'Large Desk'})
        self.product_id_2 = self.env['product.product'].create(
            {'name': 'Conference Chair'})

        self.user_purchase_user = mail_new_test_user(
            self.env,
            name='Pauline Poivraisselle',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='purchase.group_purchase_user',
        )

        self.po_vals = {
            'partner_id':
            self.partner_id.id,
            'order_line': [(0, 0, {
                'name':
                self.product_id_1.name,
                'product_id':
                self.product_id_1.id,
                'product_qty':
                5.0,
                'product_uom':
                self.product_id_1.uom_po_id.id,
                'price_unit':
                500.0,
                'date_planned':
                datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
            })],
        }
예제 #25
0
파일: common.py 프로젝트: mausvt/flectra
    def setUpClass(cls):
        super(TestLeadConvertMassCommon, cls).setUpClass()
        # Sales Team organization
        # Role: M (team member) R (team manager)
        # SALESMAN-------------------sales_team_1-----sales_team_convert
        # admin----------------------M----------------/
        # user_sales_manager---------R----------------R
        # user_sales_leads-----------M----------------/
        # user_sales_leads_convert---/----------------M  <-- NEW
        # user_sales_salesman--------/----------------M

        cls.user_sales_leads_convert = mail_new_test_user(
            cls.env, login='******',
            name='Lucien Sales Leads Convert', email='*****@*****.**',
            company_id=cls.env.ref("base.main_company").id,
            notification_type='inbox',
            groups='sales_team.group_sale_salesman_all_leads,base.group_partner_manager,crm.group_use_lead',
        )
        cls.sales_team_convert.write({
            'member_ids': [(4, cls.user_sales_leads_convert.id)]
        })

        cls.lead_w_partner = cls.env['crm.lead'].create({
            'name': 'New1',
            'type': 'lead',
            'probability': 10,
            'user_id': cls.user_sales_manager.id,
            'stage_id': False,
            'partner_id': cls.contact_1.id,
        })
        cls.lead_w_partner.write({'stage_id': False})
        cls.lead_w_partner_company = cls.env['crm.lead'].create({
            'name': 'New1',
            'type': 'lead',
            'probability': 15,
            'user_id': cls.user_sales_manager.id,
            'stage_id': cls.stage_team1_1.id,
            'partner_id': cls.contact_company_1.id,
            'contact_name': 'Hermes Conrad',
            'email_from': '*****@*****.**',
        })
        cls.lead_w_contact = cls.env['crm.lead'].create({
            'name': 'LeadContact',
            'type': 'lead',
            'probability': 15,
            'contact_name': 'TestContact',
            'user_id': cls.user_sales_salesman.id,
            'stage_id': cls.stage_gen_1.id,
        })
        cls.lead_w_email = cls.env['crm.lead'].create({
            'name': 'LeadEmailAsContact',
            'type': 'lead',
            'probability': 15,
            'email_from': '*****@*****.**',
            'user_id': cls.user_sales_salesman.id,
            'stage_id': cls.stage_gen_1.id,
        })
        cls.lead_w_email_lost = cls.env['crm.lead'].create({
            'name': 'Lost',
            'type': 'lead',
            'probability': 15,
            'email_from': '*****@*****.**',
            'user_id': cls.user_sales_leads.id,
            'stage_id': cls.stage_team1_2.id,
            'active': False,
        })
        (cls.lead_w_partner | cls.lead_w_partner_company | cls.lead_w_contact | cls.lead_w_email | cls.lead_w_email_lost).flush()
예제 #26
0
 def test_project_specific_permission(self):
     self.project_pigs.allowed_user_ids = self.user
     john = mail_new_test_user(self.env, login='******')
     self.task.allowed_user_ids |= john
     self.project_pigs.allowed_user_ids -= self.user
     self.assertIn(john, self.task.allowed_user_ids, "John should still be allowed to read the task")
예제 #27
0
 def setUp(self):
     super().setUp()
     self.task = self.create_task('Make the world a better place')
     self.user = mail_new_test_user(self.env, 'Internal user', groups='base.group_user')
     self.portal = mail_new_test_user(self.env, 'Portal user', groups='base.group_portal')
예제 #28
0
    def test_multi_company_message_post_notifications(self):
        company_1 = self.company_admin
        company_2 = self.env['res.company'].create({'name': 'Company 2'})

        # Company 1 and notification_type == "inbox"
        user_1 = self.user_employee

        # Company 1 and notification_type == "email"
        user_2 = self.user_admin
        user_2.notification_type = 'email'

        user_3 = mail_new_test_user(
            self.env, login='******', email='*****@*****.**', groups='base.group_user',
            company_id=company_2.id, company_ids=[(6, 0, company_2.ids)],
            name='user3', notification_type='inbox')

        user_4 = mail_new_test_user(
            self.env, login='******', email='*****@*****.**', groups='base.group_user',
            company_id=company_2.id, company_ids=[(6, 0, company_2.ids)],
            name='user4', notification_type='email')

        partner_without_user = self.env['res.partner'].create({
            'name': 'Partner',
            'email': '*****@*****.**',
        })
        mail_channel = self.env['mail.channel'].with_user(user_1).create({
            'name': 'Channel',
            'channel_partner_ids': [
                (4, user_1.partner_id.id),
                (4, user_2.partner_id.id),
                (4, user_3.partner_id.id),
                (4, user_4.partner_id.id),
                (4, partner_without_user.id),
            ],
            'email_send': True,
        })

        mail_channel.invalidate_cache()
        (user_1 | user_2 | user_3 | user_4).invalidate_cache()

        with self.mock_mail_gateway():
            mail_channel.with_user(user_1).with_company(company_1).message_post(
                body='Test body message 1337',
                channel_ids=mail_channel.ids,
            )

        self.assertSentEmail(user_1.partner_id, [user_2.partner_id])
        self.assertSentEmail(user_1.partner_id, [user_4.partner_id])
        self.assertEqual(len(self._mails), 3, 'Should have send only 3 emails to user 2, user 4 and the partner')

        self.assertBusNotifications([(self.cr.dbname, 'mail.channel', mail_channel.id)])

        # Should not create mail notifications for user 1 & 3
        self.assertFalse(self.env['mail.notification'].search([('res_partner_id', '=', user_1.partner_id.id)]))
        self.assertFalse(self.env['mail.notification'].search([('res_partner_id', '=', user_3.partner_id.id)]))

        # Should create mail notifications for user 2 & 4
        self.assertTrue(self.env['mail.notification'].search([('res_partner_id', '=', user_2.partner_id.id)]))
        self.assertTrue(self.env['mail.notification'].search([('res_partner_id', '=', user_4.partner_id.id)]))

        # Check that we did not send a "channel_seen" notifications
        # for the users which receive the notifications by email
        notification_seen_user_2 = self.env['bus.bus'].search([('create_uid', '=', user_2.id)])
        self.assertFalse(notification_seen_user_2, 'Should not have sent a notification as user 2')
        notification_seen_user_4 = self.env['bus.bus'].search([('create_uid', '=', user_4.id)])
        self.assertFalse(notification_seen_user_4, 'Should not have sent a notification as user 4')
예제 #29
0
    def setUpClass(cls):
        super(TestMrpCommon, cls).setUpClass()

        # Update demo products
        (cls.product_2 | cls.product_3 | cls.product_4 | cls.product_5 | cls.product_6 | cls.product_7_3 | cls.product_8).write({
            'type': 'product',
        })

        # User Data: mrp user and mrp manager
        cls.user_mrp_user = mail_new_test_user(
            cls.env,
            name='Hilda Ferachwal',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='mrp.group_mrp_user, stock.group_stock_user, mrp.group_mrp_byproducts',
        )
        cls.user_mrp_manager = mail_new_test_user(
            cls.env,
            name='Gary Youngwomen',
            login='******',
            email='*****@*****.**',
            notification_type='inbox',
            groups='mrp.group_mrp_manager, stock.group_stock_user, mrp.group_mrp_byproducts',
        )

        cls.workcenter_1 = cls.env['mrp.workcenter'].create({
            'name': 'Nuclear Workcenter',
            'capacity': 2,
            'time_start': 10,
            'time_stop': 5,
            'time_efficiency': 80,
        })

        cls.bom_1 = cls.env['mrp.bom'].create({
            'product_id': cls.product_4.id,
            'product_tmpl_id': cls.product_4.product_tmpl_id.id,
            'product_uom_id': cls.uom_unit.id,
            'product_qty': 4.0,
            'consumption': 'flexible',
            'operation_ids': [
            ],
            'type': 'normal',
            'bom_line_ids': [
                (0, 0, {'product_id': cls.product_2.id, 'product_qty': 2}),
                (0, 0, {'product_id': cls.product_1.id, 'product_qty': 4})
            ]})
        cls.bom_2 = cls.env['mrp.bom'].create({
            'product_id': cls.product_5.id,
            'product_tmpl_id': cls.product_5.product_tmpl_id.id,
            'product_uom_id': cls.product_5.uom_id.id,
            'consumption': 'flexible',
            'product_qty': 1.0,
            'operation_ids': [
                (0, 0, {'name': 'Gift Wrap Maching', 'workcenter_id': cls.workcenter_1.id, 'time_cycle': 15, 'sequence': 1}),
            ],
            'type': 'phantom',
            'sequence': 2,
            'bom_line_ids': [
                (0, 0, {'product_id': cls.product_4.id, 'product_qty': 2}),
                (0, 0, {'product_id': cls.product_3.id, 'product_qty': 3})
            ]})
        cls.bom_3 = cls.env['mrp.bom'].create({
            'product_id': cls.product_6.id,
            'product_tmpl_id': cls.product_6.product_tmpl_id.id,
            'product_uom_id': cls.uom_dozen.id,
            'consumption': 'flexible',
            'product_qty': 2.0,
            'operation_ids': [
                (0, 0, {'name': 'Cutting Machine', 'workcenter_id': cls.workcenter_1.id, 'time_cycle': 12, 'sequence': 1}),
                (0, 0, {'name': 'Weld Machine', 'workcenter_id': cls.workcenter_1.id, 'time_cycle': 18, 'sequence': 2}),
            ],
            'type': 'normal',
            'bom_line_ids': [
                (0, 0, {'product_id': cls.product_5.id, 'product_qty': 2}),
                (0, 0, {'product_id': cls.product_4.id, 'product_qty': 8}),
                (0, 0, {'product_id': cls.product_2.id, 'product_qty': 12})
            ]})

        cls.stock_location_14 = cls.env['stock.location'].create({
            'name': 'Shelf 2',
            'location_id': cls.env.ref('stock.warehouse0').lot_stock_id.id,
        })
        cls.stock_location_components = cls.env['stock.location'].create({
            'name': 'Shelf 1',
            'location_id': cls.env.ref('stock.warehouse0').lot_stock_id.id,
        })
        cls.laptop = cls.env['product.product'].create({
            'name': 'Acoustic Bloc Screens',
            'uom_id': cls.env.ref("uom.product_uom_unit").id,
            'uom_po_id': cls.env.ref("uom.product_uom_unit").id,
            'type': 'product',
            'tracking': 'none',
            'categ_id': cls.env.ref('product.product_category_all').id,
        })
        cls.graphics_card = cls.env['product.product'].create({
            'name': 'Individual Workplace',
            'uom_id': cls.env.ref("uom.product_uom_unit").id,
            'uom_po_id': cls.env.ref("uom.product_uom_unit").id,
            'type': 'product',
            'tracking': 'none',
            'categ_id': cls.env.ref('product.product_category_all').id,
        })
예제 #30
0
    def setUpClass(cls):
        super(TestEventSale, cls).setUpClass()

        product = cls.env['product.product'].create({
            'name': 'Event',
            'type': 'service',
            'event_ok': True,
        })

        cls.user_salesperson = mail_new_test_user(
            cls.env,
            login='******',
            groups='sales_team.group_sale_salesman')

        cls.ticket = cls.env['event.event.ticket'].create({
            'name':
            'First Ticket',
            'product_id':
            cls.event_product.id,
            'seats_max':
            30,
            'event_id':
            cls.event_0.id,
        })

        cls.event_0.write({
            'event_ticket_ids': [(6, 0, cls.ticket.ids),
                                 (0, 0, {
                                     'name': 'Second Ticket',
                                     'product_id': cls.event_product.id,
                                 })],
        })

        cls.sale_order = cls.env['sale.order'].create({
            'partner_id':
            cls.env.ref('base.res_partner_2').id,
            'note':
            'Invoice after delivery',
            'payment_term_id':
            cls.env.ref('account.account_payment_term_end_following_month').id
        })

        # In the sales order I add some sales order lines. i choose event product
        cls.env['sale.order.line'].create({
            'product_id':
            product.id,
            'price_unit':
            190.50,
            'product_uom':
            cls.env.ref('uom.product_uom_unit').id,
            'product_uom_qty':
            1.0,
            'order_id':
            cls.sale_order.id,
            'name':
            'sales order line',
            'event_id':
            cls.event_0.id,
            'event_ticket_id':
            cls.ticket.id,
        })

        cls.register_person = cls.env['registration.editor'].create({
            'sale_order_id':
            cls.sale_order.id,
            'event_registration_ids': [(0, 0, {
                'event_id':
                cls.event_0.id,
                'name':
                'Administrator',
                'email':
                '*****@*****.**',
                'sale_order_line_id':
                cls.sale_order.order_line.id,
            })],
        })

        # make a SO for a customer, selling some tickets
        cls.customer_so = cls.env['sale.order'].with_user(
            cls.user_sales_salesman).create({
                'partner_id':
                cls.event_customer.id,
            })