onboarding.py 1.5 KB
from odoo import http
from odoo.http import request


class OnboardingController(http.Controller):

    @http.route('/pad/pad_invoice_onboarding', auth='user', type='json')
    def pad_invoice_onboarding(self):
        """ Returns the `banner` for the pad invoice onboarding panel.
            It can be empty if the user has closed it or if he doesn't have
            the permission to see it. """

        company = request.env.company
        if not request.env.is_admin() or \
                company.pad_invoice_onboarding_state == 'closed':
            return {}

        return {
            'html': request.env.ref('pad.pad_invoice_onboarding_panel')._render({
                'company': company,
                'state': company.get_and_update_pad_invoice_onboarding_state()
            })
        }

    @http.route('/pad/pad_dashboard_onboarding', auth='user', type='json')
    def pad_dashboard_onboarding(self):
        """ Returns the `banner` for the pad dashboard onboarding panel.
            It can be empty if the user has closed it or if he doesn't have
            the permission to see it. """
        company = request.env.company

        if not request.env.is_admin() or \
                company.pad_dashboard_onboarding_state == 'closed':
            return {}

        return {
            'html': request.env.ref('pad.pad_dashboard_onboarding_panel')._render({
                'company': company,
                'state': company.get_and_update_pad_dashboard_onboarding_state()
            })
        }