Try ERPNext Buy Support Partners Foundation

Add User by code

Hi

I want to add a User by code.

                user = frappe.new_doc('User')
                            user.first_name = doc.full_name, 
                            user.email = doc.email,
                            user.save()

but this gives an error
File “/home/parth/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 38, in autoname
self.email = self.email.strip().lower()
AttributeError: ‘tuple’ object has no attribute ‘strip’

please help.

thanks

Fixed!

commas were extra

updated code:

user = frappe.new_doc('User')
user.email = doc.email
user.first_name = doc.full_name
user.save()
1 Like