Odoo 13在添加年龄字段时升级hr模块时出错

时间:2020-04-19 08:21:59

标签: odoo

大家好,当我尝试在hr_emp模块中更新员工生日时,它应该自动返回年龄,但是我在升级模块时将以下错误提示给我

hr.py:

birthday = fields.Date(string="DOB")
age = fields.Integer(string="Age")

@api.onchange('birthday')
def _onchange_birth_date(self):
    """Updates age field when birth_date is changed"""
    if self.birthday:
        d1 = datetime.strptime(self.birthday, "%Y-%m-%d").date()
        d2 = date.today()
        self.age = relativedelta(d2, d1).years

错误:

Odoo Server Error

Traceback (most recent call last):
  File "/odoo/odoo-server/odoo/addons/base/models/ir_ui_view.py", line 392, in _check_xml
    self.postprocess_and_fields(view.model, view_doc, view.id)
  File "/odoo/odoo-server/odoo/addons/base/models/ir_ui_view.py", line 964, in postprocess_and_fields
    self.raise_view_error(message, view_id)
  File "/odoo/odoo-server/odoo/addons/base/models/ir_ui_view.py", line 592, in raise_view_error
    raise ValueError(message)
ValueError: Field `age` does not exist

Error context:
View `hr.employee.form`
[view_id: 766, xml_id: hr.view_employee_form, model: hr.employee, parent_id: n/a]

0 个答案:

没有答案