如何为one2many字段显示与原始视图不同的向导视图?

2024-06-06 14:30:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用一个用于Odoo文档管理的模块,在主目录视图中有一个用于子目录的one2many字段,它指向同一个模型,因此在创建它的同时打开一个与它所定位的表单完全相同的向导,我需要从该向导中隐藏一些字段,并添加一些仅与子目录相关的新字段,我该怎么做,这是代码

 class Directory(models.Model):

_name = 'muk_dms.directory'
_description = "Directory"

_inherit = [
    'muk_utils.mixins.hierarchy',
    'muk_security.mixins.access_rights',
    'muk_dms.mixins.thumbnail',
]

_order = "name asc"

_parent_store = True
_parent_name = "parent_directory"

_parent_path_sudo = False
_parent_path_store = False

_name_path_context = "dms_directory_show_path"

#----------------------------------------------------------
# Database
#----------------------------------------------------------

name = fields.Char(
    string="Name", 
    required=True,
    index=True)

is_root_directory = fields.Boolean(
    string="Is Root Directory", 
    default=False,
    help="""Indicates if the directory is a root directory. A root directory has a settings object,
        while a directory with a set parent inherits the settings form its parent.""")

root_storage = fields.Many2one(
    comodel_name='muk_dms.storage',  
    string="Root Storage",
    ondelete='restrict')

storage = fields.Many2one(
    compute='_compute_storage',
    comodel_name='muk_dms.storage', 
    string="Storage",
    ondelete='restrict',
    auto_join=True,
    readonly=True,
    store=True)

parent_directory = fields.Many2one(
    comodel_name='muk_dms.directory', 
    domain="""[('permission_create', '=', True)]""",
    context="{'dms_directory_show_path': True}",
    string="Parent Directory",
    ondelete='restrict',
    auto_join=True,
    index=True)

如上面代码所示,最后一个字段是从同一个模型中获取数据,如何显示具有不同字段的向导 提前感谢,


Tags: pathstorenamefalsetruefieldsstringdms