odoo 加用户

发布时间 2023-10-24 16:15:54作者: CrossPython

 

加用户

    def insert(self, info):
        a = self.env['hr.department'].create({'name': info['orgcode_show']})
        b = self.env['hr.employee'].create(
            {'name': info['USERNAME'], 'department_id': a.id, '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()