如题,Odoo开发过程中,有时遇到一些需求需要在页面中快速配置一些信息数据,此时就需要用到配置面板, 如下图所示:
配置面板
主要分三步:
一是定义配置面板的模板
二是定义路由渲染模板
三是给指定模型视图绑定模板路由
代码如下:
模板文件sale_onboarding_views.xml
Quotation Layout
Customize the look of your quotations.
Looks great!
Customize
Confirmation & Payment
Choose how to confirm quotations and get paid.
Set payments
Sample Quotation
Send a quotation to test the customer portal.
Send sample
sale.order.confirmation.onboarding.form
sale.payment.acquirer.onboarding.wizard
primary
1000
col col-4
How your customers can confirm an order
ir.actions.act_window
sale.payment.acquirer.onboarding.wizard
form
form
new
sale.onboarding.quotation.layout.form
res.company
primary
1000
Configure your document layout
ir.actions.act_window
res.company
form
form
new
mail.compose.message.sale.onboarding.sample.quotation.form
mail.compose.message
1000
primary
1
1
1
Send a sample quotation.
ir.actions.act_window
mail.compose.message
form
form
new
路由文件sale_onboarding_views.xml
# -*- 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()
})
}
指定模型视图,添加banner_route属性,属性值为路由。
sale.order.tree
sale.order
primary
/sales/sale_quotation_onboarding_panel
以上, 为自定义配置面板大致过程。
============================================================================================================================