summaryrefslogtreecommitdiff
path: root/addons/account/controllers/onboarding.py
blob: 3c0afa38c3aaa3e7d113f86ee2515ef073c1f81d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from odoo import http
from odoo.http import request


class OnboardingController(http.Controller):

    @http.route('/account/account_invoice_onboarding', auth='user', type='json')
    def account_invoice_onboarding(self):
        """ Returns the `banner` for the account 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.account_invoice_onboarding_state == 'closed':
            return {}

        return {
            'html': request.env.ref('account.account_invoice_onboarding_panel')._render({
                'company': company,
                'state': company.get_and_update_account_invoice_onboarding_state()
            })
        }

    @http.route('/account/account_dashboard_onboarding', auth='user', type='json')
    def account_dashboard_onboarding(self):
        """ Returns the `banner` for the account 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.account_dashboard_onboarding_state == 'closed':
            return {}

        return {
            'html': request.env.ref('account.account_dashboard_onboarding_panel')._render({
                'company': company,
                'state': company.get_and_update_account_dashboard_onboarding_state()
            })
        }