Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
9 Trả lời
25466 Lượt xem

# -*- 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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Tác giả

but super is not working

Please check my updated answer.

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

Tác giả

its working thanks for the update

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.

Câu trả lời hay nhất

Excellent

Ảnh đại diện
Huỷ bỏ