在 odoo 12 中设置用户与员工之间的关联后丢失信息
Lost information after set association between user an employee in odoo 12
我想在创建员工时创建一个用户,到目前为止工作正常
@api.model
@api.returns('self', lambda value: value.id)
def create(self, vals):
rec = super(HrEmployee, self).create(vals)
model = {
'name': rec.name,
'login': rec.work_email,
'sel_groups_1_9_10':9, # user type, portal user
'company_id':1,
'write_uid': 1,
'share': False,
'image':rec.image_medium
}
domain = [('login','=',rec.work_email)]
users = self.env['res.users'].search(domain)
if not users:
try:
user = self.env['res.users'].create(model)
rec.user_id = user.id
except Exception as e:
logging.info(e)
pass
return rec
问题是在我设置 rec.user_id = user.id 员工后 work_email , 转换为 None,知道吗?
出现这种情况是因为新用户email
是空的。
有一个on change method that updates the employee's work_email
with the related user email。
我想在创建员工时创建一个用户,到目前为止工作正常
@api.model
@api.returns('self', lambda value: value.id)
def create(self, vals):
rec = super(HrEmployee, self).create(vals)
model = {
'name': rec.name,
'login': rec.work_email,
'sel_groups_1_9_10':9, # user type, portal user
'company_id':1,
'write_uid': 1,
'share': False,
'image':rec.image_medium
}
domain = [('login','=',rec.work_email)]
users = self.env['res.users'].search(domain)
if not users:
try:
user = self.env['res.users'].create(model)
rec.user_id = user.id
except Exception as e:
logging.info(e)
pass
return rec
问题是在我设置 rec.user_id = user.id 员工后 work_email , 转换为 None,知道吗?
出现这种情况是因为新用户email
是空的。
有一个on change method that updates the employee's work_email
with the related user email。