Help

3

how to inherit controller in odoo 12

# -*- coding: utf-8 -*-

# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import http

from odoo.http import request



class OnboardingController(http.Controller):


    @http.route('/sales/sale_quotation_onboarding_panel', auth='user', type='json')

    def sale_quotation_onboarding(self):

        """ Returns the `banner` for the sale 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.user.company_id

        if not request.env.user._is_admin() or \

           company.sale_quotation_onboarding_state == 'closed':

            return {}


        return {

            'html': request.env.ref('sale.sale_quotation_onboarding_panel').render({

                'company': company,

                'state': company.get_and_update_sale_quotation_onboarding_state()

            })

        }

i need to inherit  function  sale_quotation_onboarding()

please help

thanks in advance

1 Comment
Avatar
Discard
2 Answers
10

You need to import the class in your custom module and then override the method.

Try following code:

from odoo import http
from odoo.addons.sale.controllers.onboarding import OnboardingController # Import the class


class CustomOnboardingController(OnboardingController): # Inherit in your custom class

@http.route('/sales/sale_quotation_onboarding_panel', auth='user', type='json')
def sale_quotation_onboarding(self):
res = super(CustomOnboardingController, self).sale_quotation_onboarding()
# Your code goes here
return res


6 Comments
Avatar
Discard
Avatar
stephen nedumpally
-

but super is not working

Please check my updated answer.

res = super(CustomOnboardingController, self).sale_quotation_onboarding()

Avatar
stephen nedumpally
-

its working thanks for the update

Avatar
Pawan Kumar Sharma
-

Thanks Sudhir Arya

How could I insert or modify data over 'res = super(.....)'?

You can use "response.qcontext" to get the result returned from super.

0
Avatar
Ahad Pashaeeian
Best Answer

Excellent

Avatar
Discard