yuthon_base/project_md/models/ir_ui_view_extend.py
李鹏宇 1fa24f7558 new
2026-07-23 16:08:07 +08:00

21 lines
747 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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