odoo 加用户
加用户
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | def trigger( self ): sql = '''select b.USERNAME,b.LOGINID,a.email,b.PASSWORD,a.orgcode_show,a.dianhua from CP_yuangongdy a left join AU_USERINFO b on a.xingming=b.USERNAME where a.shiyong!='离职' and USERNAME is not null;''' df = pd.read_sql(sql, con = jl_conn) for _, row in df.iterrows(): self .insert(row) def insert( self , info): dept = self .env[ 'hr.department' ].search([( 'name' , '=' , info[ 'orgcode_show' ])], limit = 1 ) if not dept: a = self .env[ 'hr.department' ].create({ 'name' : info[ 'orgcode_show' ]}) deptid = a. id else : deptid = dept. id b = self .env[ 'hr.employee' ].create( { 'name' : info[ 'USERNAME' ], 'department_id' : deptid, 'mobile_phone' : info[ 'dianhua' ], 'work_email' : info[ 'email' ]}) c = self .env[ 'res.partner' ].search([( 'name' , '=' , info[ 'USERNAME' ])], limit = 1 ) c.write({ 'mobile' : info[ 'dianhua' ], 'email' : info[ 'email' ]}) d = self .env[ 'res.users' ].create( { 'partner_id' : c. id , 'login' : info[ 'LOGINID' ], 'password' : info[ 'PASSWORD' ], 'notification_type' : 'inbox' }) b.write({ 'user_id' : d. id }) self ._cr.commit() |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】Flutter适配HarmonyOS 5知识地图,实战解析+高频避坑指南
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合终身会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步