如何修复ValueError:odoo中不存在字段`active` [英] How to fix ValueError: Field `active` does not exist in odoo

查看:74
本文介绍了如何修复ValueError:odoo中不存在字段`active`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从视图员工表单继承的视图,其中包含来自我创建的模型的字段,但是每当我尝试升级模块时,它都会向我显示 ValueError: Field active does not exist 错误.

I have a view which inherits from view employee form, with fields from a model I created, but whenever I try to upgrade the module it shows me the ValueError: Field active does not exist error.

这是我继承员工表单的视图.

Here is the view from which I inherited the employee form.

<record model="ir.ui.view" id="training_log_employee_form_inherit">
        <field name="name">training.log.employee.form.inherit</field>
        <field name="model">training.log.emp</field>
        <field name="inherit_id" ref="hr.view_employee_form"/>
        <field name="arch" type="xml">
           <xpath expr="//notebook" position="inside">
              <page string="Training Log">
                <field name="training_log_line">
                  <form>
                    <group string="Employee Training">
                      <field name="date"/>
                      <field name="course"/>
                      <field name="type_list"/>
                      <field name="completion_status"/>
                    </group>
                  </form>
                    <tree editable="bottom">
                      <field name="date"/>
                      <field name='course'/>
                      <field name="type_list"/>
                      <field name="completion_status"/>
                    </tree>
                  </field>       
                </page>

            </xpath>

        </field>
      </record>

这是training.log.emp模型

This is the training.log.emp model

class TrainingLog(models.Model):
    _name = 'training.log.emp'

    hr_employee = fields.Many2one('hr.employee')
    date = fields.Date()
    course = fields.Char()
    type_list = fields.Many2one('Type', 'hr.training.log')
    completion_status = fields.Selection([
        ('done', 'Done'),
        ('in_view', 'In View'),
        ])

ValueError: Field active 不存在

ValueError: Field active does not exist

错误上下文:查看training_log_employee_form_inherit[view_id:373,xml_id:n/a,模型:training.log.emp,parent_id:302]

Error context: View training_log_employee_form_inherit [view_id: 373, xml_id: n/a, model: training.log.emp, parent_id: 302]

推荐答案

您确定要为正确的模型创建视图吗?我会说它必须是 hr.employee 而不是 training.log.emp,因为您还继承了 hr.employee 视图并且您只想在与您的新模型 training.log.emp 相关的员工上显示 one2many 字段.

Are you sure you're creating the view for the right model? I would say it has to be hr.employee and not training.log.emp, because you're also inheriting a hr.employee view and you just want to show a one2many field on Employees with relation to your new model training.log.emp.

这篇关于如何修复ValueError:odoo中不存在字段`active`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆