Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

res.users create

Odebírat

Get notified when there's activity on this post

This question has been flagged
createres.usersodoo8.0odoo9
1 Odpovědět
13242 Zobrazení
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
Zrušit
Avatar
Thanh Loyal
Nejlepší odpověď

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
Zrušit
Gavin Yap
Autor

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!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to properly create a large amount of users?
create res.users
Avatar
Avatar
Avatar
2
lis 21
5230
Odoo 10: Change datetime picker options for a field Vyřešeno
odoo8.0 odoo9 odoo10
Avatar
Avatar
1
kvě 21
11312
Customer Invoice and Payment in odoo 8 and 9
accounting odoo8.0 odoo9
Avatar
0
říj 16
5670
How to check whether two many2many fields are exactly equal or not in odoo9?
odoo odoo8.0 odoo9
Avatar
Avatar
1
zář 16
8200
write and create function Vyřešeno
function create write odoo8.0
Avatar
Avatar
Avatar
2
čvn 25
91656
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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