21 lines
747 B
Python
21 lines
747 B
Python
from odoo import fields, models
|
||
|
||
|
||
class IrUiView(models.Model):
|
||
_inherit = 'ir.ui.view'
|
||
|
||
# 注册自定义视图类型 mindmap,使其能被 ir.ui.view 的 type 字段接受
|
||
type = fields.Selection(
|
||
selection_add=[('mindmap', 'Mindmap')],
|
||
string='View Type',
|
||
)
|
||
|
||
def _get_view_info(self):
|
||
# 关键:只 selection_add 不够。get_view_info 只会把
|
||
# “既在选择项里、又在 _get_view_info() 字典里”的类型塞进
|
||
# session.view_info。若不在此登记 mindmap 的元数据,前端会报
|
||
# “View types not defined mindmap”。
|
||
res = super()._get_view_info()
|
||
res['mindmap'] = {'icon': 'fa fa-sitemap', 'multi_record': True}
|
||
return res
|