Beispiel #1
0
def post_init_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': True})
Beispiel #2
0
def post_init_hook(cr, pool):
    """
    Fetches all the sale order and resets the sequence of the order lines
    """
    env = Environment(cr, SUPERUSER_ID, {})
    sale = env['sale.order'].search([])
    sale._reset_sequence()
Beispiel #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')
Beispiel #4
0
 def poll(self, channels, last, options=None):
     if request.env.user.has_group('base.group_user'):
         ip_address = request.httprequest.remote_addr
         users_log = request.env['res.users.log'].search_count([
             ('create_uid', '=', request.env.user.id),
             ('ip', '=', ip_address),
             ('create_date', '>=', Datetime.to_string(Datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)))])
         if not users_log:
             with registry(request.env.cr.dbname).cursor() as cr:
                 env = Environment(cr, request.env.user.id, {})
                 env['res.users.log'].create({'ip': ip_address})
     return super(BusController, self).poll(channels, last, options=options)
    def test_stock_picking_barcode(self):

        # needed because tests are run before the module is marked as
        # installed. In js web will only load qweb coming from modules
        # that are returned by the backend in module_boot. Without
        # this you end up with js, css but no qweb.
        cr = self.registry.cursor()
        assert cr == self.registry.test_cr
        env = Environment(cr, self.uid, {})
        env["ir.module.module"].search(
            [("name", "=", "stock_picking_barcode")],
            limit=1).state = "installed"
        cr.release()

        # without a delay there might be problems on the steps whilst opening a POS
        # caused by a not yet loaded button's action
        self.phantom_js(
            "/web",
            "eagle.__DEBUG__.services['web_tour.tour'].run('tour_stock_picking_barcode', 1000)",
            "eagle.__DEBUG__.services['web_tour.tour'].tours.tour_stock_picking_barcode.ready",
            login="******",
        )
Beispiel #6
0
    def _auth_method_calendar(cls):
        token = request.params['token']
        dbname = request.params['db']

        registry = eagle.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
Beispiel #7
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 get_lang(request.env).code
            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')
                                                  ])
Beispiel #8
0
def _synchronize_cron(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {'active_test': False})
    cron = env.ref('crm_iap_lead_enrich.ir_cron_lead_enrichment')
    if cron:
        config = env['ir.config_parameter'].get_param('crm.iap.lead.enrich.setting', 'manual')
        cron.active = config != 'manual'
def uninstall_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    for rec in env['eagle_dashboard.board'].search([]):
        rec.eagle_dashboard_client_action_id.unlink()
        rec.eagle_dashboard_menu_id.unlink()