如何根据 xml 文件中的条件更改字段名称?

How can i change the field name based on condition in xml file?

如何根据 XML 文件中的条件更改字段名称?

我的代码是:

<field name="parent_id" position="attributes">    
    <attribute name="string">{'HOD':[('is_student','=',True)]}</attribute>    
</field>

如果字段 is_student 为 True,则显示 HOD 否则保持为 Manager 仅。

如何实现?

尝试使用此代码:

替换下面的代码

<field name="parent_id" position="attributes">    
    <attribute name="string">{'HOD':[('is_student','=',True)]}</attribute>    
</field>

<field name="parent_id" position="replace">
    <div>
        <label for="parent_id" attrs="{'invisible': ['is_student','=',False)]}">
        <label for="parent_id" string="HOD" attrs="{'invisible': ['is_student','=',True)]}">
        <field name="parent_id">
    </div>
</field>

因为我无法在 XML 文件中执行此操作,因为如果我尝试 @Odedra 解决方案,我的设计就会受到干扰。

我是用这段代码实现的:

def fields_get(self, cr, uid, fields=None, context=None):
    if context is None:
        context={}
    res = super(hr_employee, self).fields_get(cr, uid, fields, context)
    if 'parent_id' in res and 'is_student' in context and context['is_student']:
        if 'string' in res['parent_id']:
            res['parent_id']['string'] = 'HOD'
    return res