Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Simple XML/RPC python code to retrieve HR_Employee information fails

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
pythonhr_employeeXML/RPC
3 Risposte
4360 Visualizzazioni
Avatar
Markus Schmid

The following code fails when exceuting the read method.  More specifically the fault is: HrEmployeePrivate.read() missing 1 required positional argument: \'fields\'\n'>

... so the the two questions obviously are: (1) What this field & (2) how to adjust the code that the read works.... 

======== Python / Odoo 16 ================

model = "hr.employee"

search = [('work_email','=', 'Donald.Duck@somecompany.com')]

method = "search"


operation = xmlrpc.client.ServerProxy(url+"/xmlrpc/object")

list_of_employee_ids = operation.execute(db, internalID, password, model, method, search)


print(list_of_employee_ids)


method = "read"


list_of_employee_detail = operation.execute(db, internalID, password, model, method, list_of_employee_ids)


0
Avatar
Abbandona
Avatar
Nikhil Nakrani
Risposta migliore

Hi Markus Schmid,

in above error shows that missing fields which you need to read,

try this then check,

fields_to_read = ['name', 'work_email', 'other_field_name']

method = "read"

# Perform read operation with specified fieldslist_of_employee_detail = operation.execute(db, internalID, password, model, method, list_of_employee_ids, fields_to_read)

Thanks

1
Avatar
Abbandona
Avatar
Jort de Vreeze
Risposta migliore

Is the list_of_employee_ids​ a valid list? What does the print statement output? See, e.g., the example in the official documentation (https://www.odoo.com/documentation/16.0/developer/reference/external_api.html#read-records):

ids = models.execute_kw(db, uid, password, 'res.partner', 'search', [[['is_company', '=', True]]], {'limit': 1})
[record] = models.execute_kw(db, uid, password, 'res.partner', 'read', [ids])

The list of fields to fetch is optional for a read request, so you don't have to use that. Why don't you use the search_read​ method instead? Odoo provides a search_read() shortcut which is equivalent to a search() followed by a read(), but avoids having to perform two requests and keep ids around (see documentation link above). E.g.,

models.execute_kw(db, uid, password, 'res.partner', 'search_read', [[['is_company', '=', True]]], {'fields': ['name', 'country_id', 'comment'], 'limit': 5})

I hope this helps!

1
Avatar
Abbandona
Markus Schmid
Autore

Thank you for pointing that out!

The updated python code (combining what Nikhil & Jort point out) looks as follows:

import xmlrpc.client

url = 'https://AAAAAAAAA.odoo.com/'
db = 'AAAAAAAAA'
username = 'XXXXX@zzzz.com'
password = 'correctpassword for username'

common = xmlrpc.client.ServerProxy(url+"/xmlrpc/common")
internalID = common.login(db, username,password)

model = "hr.employee"
method = 'search_read'
search = [[['work_email','=', eMail]]]
fields_to_read = {'fields': ['name', 'job_id', 'parent_id', 'hourly_cost']}

operation = xmlrpc.client.ServerProxy(url+"/xmlrpc/object")

list_of_employee_detail = operation.execute_kw(db, internalID, password, model, method, search, fields_to_read )

print(list_of_employee_detail)

Avatar
Markus Schmid
Autore Risposta migliore

Thank you!

One question: In some cases it works without the "fields_to_read"..... 

To be consistent on my side.... Can I add the "fields_to_read" to all my xml/rpc reads?

Regardless:  You have been a great help for me!  

Thanks again!

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
new python env
python
Avatar
0
mar 25
2389
What means "Too many values to unpack" message? Risolto
python
Avatar
Avatar
Avatar
Avatar
Avatar
4
apr 24
175947
have no data in screen. read data in my own module from different model
python
Avatar
0
dic 23
3003
How to insert value to a one2many field in table with create method? Risolto
python
Avatar
Avatar
Avatar
Avatar
Avatar
5
lug 25
232381
how to disable add product in sales of odoo 12
python
Avatar
Avatar
1
dic 22
4175
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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