Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

how to retrieve user first and last name?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
openerpcostum_module
3 Răspunsuri
11299 Vizualizări
Imagine profil
Andrew

Hello, i'm writing a module for OpenErp and i have some troubles with user's first and last names.

 

this is my piece of code:

def _user_get(self, cr, uid, context=None):
    cr.execute("select id,name from resource_resource")
    return cr.fetchall()
 .....

 

_columns = {

....

'users' : fields.selection(_user_get, 'Users')

...}

 

But it doesn't work. Can someone help me?

It saves data in the table, but does't show user name and family. The rest info is displayed.

0
Imagine profil
Abandonează
Andrew
Autor

Thank you  * Bole [1]  *for your answer. I know about "'my_user':fields.many2one('res.users','User')", but the problem is that it displays too much info, such as "Language, Login and date". But i need only first and last name [1] https://www.odoo.com/forum/help-1/user/6104

Bole

o, so create a new view that shows only the fields you need .. in xml do like: that should do the trick of custom tree view fro many 2 one;) also you can define custom form view;) the same way

Bole

i have edited my answer so now you have example on how to show only the fields you want , and not all of them ;)

Imagine profil
Bole
Cel mai bun răspuns

Well.. you are looking at wrong data.. 

In odoo/openerp resource_resource contains(actualy is hr_employee name i related to this field) 
 the name for employees, not users.. 

there is a table res_users where some user data is stored... (login, password, mail.. etc..) and a relation to res_partner (partner_id) wich contains actual name of user, along with other data (address, phone , mail....)

So eather you rewrite your sql acordingly (using some joins for foreign key ids..) ,

or.. simply user orm methods like.. if you want to search for user wich has login : 'someuser' it would look like:

ids = self.pool.get('res.users').search(cr, uid, [('login'.'=','someuser')])    #expecting a list of ids returned

now that you have list of ids, you can browse those records and read/modify any data stored in fields...

 

but in your case... i think it would be much easier if you do not use fields.selection.. but instead, 

define your:

_columns = {
...
'my_user':fields.many2one('res.users','User'),
...
}
 

this is common usage for many to one field, and it preserves most orm methods in it ( addins and modifying user) 
in case you want to show just a selection on the view... define a view like: (addon after comment:)
<field name="my_user" widget="selection" /> 

If you need only a few fields shown and not the default view for related field, define them in the same view like:

<field name="my_user" widget="selection" > 
    <tree>
        <field name="first_name"/>
        <filed name="last_name"/>
    </tree>
</field>


 

1
Imagine profil
Abandonează
Imagine profil
Zahin
Cel mai bun răspuns

HI. Andrew 

Here right way TODO.

_columns = {

          'user_id': fields.many2one('res.users', 'Salesperson',),

}

_defaults = {
         'user_id': lambda obj, cr, uid, context: uid,

}

I suggest you to read existing code of sale module or account module, and just go through code and understand existing codes and utilize it in your modules.

 

0
Imagine profil
Abandonează
Imagine profil
Andrew
Autor Cel mai bun răspuns

Thank you. I solved this isue in the next way:

_columns = {

...

'user_id': fields.many2many('res.users'),

...

}

 

but in the xml view I inserted this string

 

<field name="user_id" string='Assigned Users' widget="many2many_tags" />

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Create selection type field dynamically?
openerp
Imagine profil
Imagine profil
Imagine profil
2
sept. 23
8487
How to hide the create button dynamical tree view in openerp ? Rezolvat
openerp
Imagine profil
Imagine profil
2
mar. 23
47729
ProgrammingError: can't adapt type 'dict' [SOLVED]
openerp
Imagine profil
Imagine profil
Imagine profil
2
dec. 23
58865
How to use the audit app
openerp
Imagine profil
0
mar. 22
3046
How to change default action of elements of tree view?
openerp
Imagine profil
Imagine profil
3
iun. 20
11412
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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