【问题标题】:How to fix ValueError: Field `active` does not exist in odoo如何修复 ValueError:odoo 中不存在字段“活动”
【发布时间】:2019-11-08 10:42:48
【问题描述】:

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

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

<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 模型

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: 字段 active 不存在

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

【问题讨论】:

  • 删除你的数据库并创建一个新的
  • 完成了还是不行

标签: python xml odoo odoo-12


【解决方案1】:

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

【讨论】:

  • 我不知道odoo允许这个,继承另一个模型的视图!!你说得对,他应该写&lt;field name="model"&gt;hr.employee&lt;/field&gt;
  • _inherits 涉及产品模板和变体时,这是可能的。
  • 谢谢你,我显然错过了
猜你喜欢
  • 2019-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-31
  • 1970-01-01
相关资源
最近更新 更多