Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

res.users create

Subscribe

Get notified when there's activity on this post

This question has been flagged
createres.usersodoo8.0odoo9
1 Reply
13240 Views
Avatar
Gavin Yap

Hi All,


I would like to create 2 sets of user, whenever a form is signup. Hence I cannot use the "auth_signup" module.


I tried to test create a user from the console using the below code:

env['res.users'].sudo().create({
'name': 'testa',
'login': 'testa',
})


But I was not able to create a new user. Instead I got this error.

2016-01-25 00:57:51,435 13091 INFO elm openerp.sql_db: bad query:  SELECT "res_users"."id" as "id","res_users"."company_id" as "company_id" FROM "res_users" LEFT JOIN "res_partner" as "res_users__partner_id" ON ("res_users"."partner_id" = "res_users__partner_id"."id")
WHERE "res_users".id IN (1) ORDER BY "res_users__partner_id"."name" ,"res_users"."login"
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 490, in new_api
result = method(self._model, cr, uid, *args, **old_kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 845, in create
return super(users_view, self).create(cr, uid, values, context)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 643, in create
user_id = super(users_implied, self).create(cr, uid, values, context)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 336, in create
user_id = super(res_users, self).create(cr, uid, vals, context=context)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 354, in old_api
result = method(recs, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/models.py", line 4112, in create
vals = self._add_missing_default_values(vals)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 490, in new_api
result = method(self._model, cr, uid, *args, **old_kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/models.py", line 1775, in _add_missing_default_values
defaults = self.default_get(cr, uid, list(missing_defaults), context)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 875, in default_get
values = super(users_view, self).default_get(cr, uid, fields1, context)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 354, in old_api
result = method(recs, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/models.py", line 1326, in default_get
defaults[name] = field.default(self)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/fields.py", line 75, in <lambda>
value(model._model, model._cr, model._uid, model._context),
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 254, in _get_company
context=context, load='_classic_write')
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 908, in read
res = super(users_view, self).read(cr, uid, ids, other_fields, context=context, load=load)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/addons/base/res/res_users.py", line 307, in read
result = super(res_users, self).read(cr, uid, ids, fields=fields, context=context, load=load)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/models.py", line 3175, in read
result = BaseModel.read(records, fields, load=load)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/models.py", line 3210, in read
self._read_from_database(stored, inherited)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/models.py", line 3348, in _read_from_database
cr.execute(query_str, params)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/sql_db.py", line 139, in wrapper
return f(self, *args, **kwargs)
File "/home/gavinyap/Documents/git/fusionbrm9/openerp/sql_db.py", line 218, in execute
res = self._obj.execute(query, params)
InternalError: current transaction is aborted, commands ignored until end of transaction block


The error does not make sense as I can cut, paste and run the SQL in postgres and it yield results.


What is wrong here and what can I do to create a new User? 

Note: I'm using Odoo8 or 9


0
Avatar
Discard
Avatar
Thanh Loyal
Best Answer

Can you run that code (with a little modification as bellow)  in a web controller?:

class ApiController(http.Controller):

@http.route(route='/create_user', auth='public')
 def create_user(self, **kwargs): 

http.request.env['res.users'].sudo().create({
'name': 'testa',
'login': 'testa',
})


My code is pretty the same as yours and it works well in a controller.

0
Avatar
Discard
Gavin Yap
Author

Thanks. Odoo framework is relatively weird. In the console. if I use self.env it works but not env alone.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to properly create a large amount of users?
create res.users
Avatar
Avatar
Avatar
2
Nov 21
5230
Odoo 10: Change datetime picker options for a field Solved
odoo8.0 odoo9 odoo10
Avatar
Avatar
1
May 21
11312
Customer Invoice and Payment in odoo 8 and 9
accounting odoo8.0 odoo9
Avatar
0
Oct 16
5670
How to check whether two many2many fields are exactly equal or not in odoo9?
odoo odoo8.0 odoo9
Avatar
Avatar
1
Sep 16
8200
write and create function Solved
function create write odoo8.0
Avatar
Avatar
Avatar
2
Jun 25
91656
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now