如果您继承hr.employee.public
来添加stored field(而不是x2many
个字段),您应该会看到相同的错误消息,因为init function试图从hr.employee
获取字段
您不需要将store
属性设置为True
,因为这是默认值(如果将store
设置为False
,则可能无法保存附件).
当attachment
属性设置为True
(默认值)时,Odoo会设置column type of the field to None
和ignore updating the database schema
要解决此问题,您可以使用与扩展Binary
字段image_1920字段相同的逻辑
100
class HrEmployee(models.Model):
_inherit = 'hr.employee'
employee_signature = fields.Binary(string='Employee signaturez', attachment=False)
class HREmployeePublic(models.Model):
_inherit = "hr.employee.public"
employee_signature = fields.Binary(compute="_compute_employee_signature", compute_sudo=True)
def _compute_employee_signature(self):
for employee in self:
employee_id = self.sudo().env['hr.employee'].browse(employee.id)
employee.employee_signature = employee_id.employee_signature
有关更多详细信息,请判断
[IMP] hr: Introduce the public employee profile
提交