用方法创建一条记录时,为什么会顺带创建了一条空白记录
-
@api.multi def sync_employee_profile(self): dingding = Dingtalk() users_info = dingding.get_users_info_by_department('1') for user in users_info: userid = user.get('userid') name = user.get('name') department_ids = user.get('department') department_id = department_ids[len(department_ids) - 1] department = dingding.get_department_by_id(department_id).get('name') mobile = user.get('mobile') email = user.get('email') values = { 'userid': userid, 'name': name, 'department': department, 'mobile': mobile, 'email': email } if self.search([('userid', '=', userid)]): print('已存在' + userid) else: user = self.sudo().create(values)
第一次执行,插入两条记录和一条空白记录
第二次执行,重复的记录被拦截,但任然多了一条空白记录
数据库里同样会有空白的记录,怎么回事,如何让这条空白记录不创建出来啊