Example #1
0
def uninstall_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    res_ids = env['ir.model.data'].search([
        ('model', '=', 'ir.ui.menu'),
        ('module', '=', 'sale')
    ]).mapped('res_id')
    env['ir.ui.menu'].browse(res_ids).update({'active': False})
Example #2
0
def post_init_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    res_ids = env['ir.model.data'].search([
        ('model', '=', 'ir.ui.menu'),
        ('module', '=', 'account'),
    ]).mapped('res_id')
    env['ir.ui.menu'].browse(res_ids).update({'active': True})
Example #3
0
 def declined(self, db, token, action, id):
     registry = registry_get(db)
     with registry.cursor() as cr:
         env = Environment(cr, SUPERUSER_ID, {})
         attendee = env['calendar.attendee'].search([
             ('access_token', '=', token), ('state', '!=', 'declined')
         ])
         if attendee:
             attendee.do_decline()
     return self.view(db, token, action, id, view='form')
Example #4
0
    def test_tour(self):
        self.phantom_js("/", "gecoerp.__DEBUG__.services['web_tour.tour'].run('website_crm_tour')", "gecoerp.__DEBUG__.services['web_tour.tour'].tours.website_crm_tour.ready")

        # need environment using the test cursor as it's not committed
        cr = self.registry.cursor()
        assert cr is self.registry.test_cr
        env = Environment(cr, self.uid, {})
        record = env['crm.lead'].search([('description', '=', '### TOUR DATA ###')])
        assert len(record) == 1
        assert record.contact_name == 'John Smith'
        assert record.email_from == '*****@*****.**'
        assert record.partner_name == 'GECOERP S.A.'
Example #5
0
    def setUp(self):
        super(TestConfirmUnsubscribe, self).setUp()

        cr = self.registry.cursor()
        # apparently HttpCase does not properly update self.env?
        self.env2 = env = Environment(cr, self.uid, {})
        self.partner = env['res.partner'].create({
            'name': 'Bob',
            'email': '*****@*****.**'
        })
        self.mailing_list = env['mail.channel'].create({
            'name': 'Test Mailing List',
            'public': 'public',
        })
        self.token = self.mailing_list._generate_action_token(
            self.partner.id, action='unsubscribe')
Example #6
0
    def test_tour(self):
        self.phantom_js(
            "/",
            "gecoerp.__DEBUG__.services['web_tour.tour'].run('website_hr_recruitment_tour')",
            "gecoerp.__DEBUG__.services['web_tour.tour'].tours.website_hr_recruitment_tour.ready"
        )

        # get test cursor to read from same transaction browser is writing to
        cr = self.registry.cursor()
        assert cr == self.registry.test_cr
        env = Environment(cr, self.uid, {})

        record = env['hr.applicant'].search([
            ('description', '=', '### HR RECRUITMENT TEST DATA ###')
        ])
        assert len(record) == 1
        assert record.partner_name == "John Smith"
        assert record.email_from == "*****@*****.**"
        assert record.partner_phone == '118.218'
Example #7
0
    def _auth_method_calendar(cls):
        token = request.params['token']
        dbname = request.params['db']

        registry = gecoerp.registry(dbname)
        error_message = False
        with registry.cursor() as cr:
            env = Environment(cr, SUPERUSER_ID, {})

            attendee = env['calendar.attendee'].sudo().search(
                [('access_token', '=', token)], limit=1)
            if not attendee:
                error_message = """Invalid Invitation Token."""
            elif request.session.uid and request.session.login != 'anonymous':
                # if valid session but user is not match
                user = env['res.users'].sudo().browse(request.session.uid)
                if attendee.partner_id != user.partner_id:
                    error_message = """Invitation cannot be forwarded via email. This event/meeting belongs to %s and you are logged in as %s. Please ask organizer to add you.""" % (
                        attendee.email, user.email)
        if error_message:
            raise BadRequest(error_message)

        return True
Example #8
0
    def view(self, db, token, action, id, view='calendar'):
        registry = registry_get(db)
        with registry.cursor() as cr:
            # Since we are in auth=none, create an env with SUPERUSER_ID
            env = Environment(cr, SUPERUSER_ID, {})
            attendee = env['calendar.attendee'].search([
                ('access_token', '=', token), ('event_id', '=', int(id))
            ])
            if not attendee:
                return request.not_found()
            timezone = attendee.partner_id.tz
            lang = attendee.partner_id.lang or 'en_US'
            event = env['calendar.event'].with_context(tz=timezone,
                                                       lang=lang).browse(
                                                           int(id))

            # If user is internal and logged, redirect to form view of event
            # otherwise, display the simplifyed web page with event informations
            if request.session.uid and request.env['res.users'].browse(
                    request.session.uid).user_has_groups('base.group_user'):
                return werkzeug.utils.redirect(
                    '/web?db=%s#id=%s&view_type=form&model=calendar.event' %
                    (db, id))

            # NOTE : we don't use request.render() since:
            # - we need a template rendering which is not lazy, to render before cursor closing
            # - we need to display the template in the language of the user (not possible with
            #   request.render())
            response_content = env['ir.ui.view'].with_context(
                lang=lang).render_template(
                    'calendar.invitation_page_anonymous', {
                        'event': event,
                        'attendee': attendee,
                    })
            return request.make_response(response_content,
                                         headers=[('Content-Type', 'text/html')
                                                  ])
Example #9
0
def _install_web_settings_dashboard(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    env['ir.module.module'].search([
        ('name', '=', 'web_settings_dashboard'),
        ('state', '=', 'uninstalled'),
    ]).button_install()
Example #10
0
def _install_sale_payment(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    env['ir.module.module'].search([
        ('name', '=', 'sale_payment'),
        ('state', '=', 'uninstalled'),
    ]).button_install()