Odoo12 ValueError:元素'<xpath expr =“ // field [@ name ='barcode']”>'不在父视图中

问题描述

我成功继承并在hr.view_employee_form中创建了一个新字段。但是每当我用Admin“ Mitchell Admin”以外的用户查看Employee“看板视图”时,它给我的错误是找不到父视图。

hr_test_att.py:

'''
class hr_test_att(models.Model):
    _inherit = 'hr.employee'
 
    bio_id = fields.Integer('Bio id')
    
    def _default_employee(self):
        return self.env['hr.employee'].search([('bio_id','=',self.env.uid)],limit=1)
'''

hr_test_att_view.xml:

'''
<record model="ir.ui.view" id="hr_test_att">
            <field name="name">hr_test_att</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>

            <field name="arch" type="xml">
                <xpath expr="//field[@name='barcode']" position="before">
                    <field name="bio_id"/>
                </xpath>
                
            </field>
    
        </record>
'''

错误

```
ValueError: Element '<xpath expr="//field[@name='barcode']">' cannot be located in parent view

Error context:
View `hr_test_att`
[view_id: 393,xml_id: hr_test_att.hr_test_att,model: hr.employee,parent_id: 330]

```

更新:

当我更改而不是输入user_id的条形码时,似乎没有显示错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)