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

default_user_get function

Iscriviti

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

La domanda è stata contrassegnata
crmv7res.user
8 Risposte
10785 Visualizzazioni
Avatar
daouda

Hi, I'am developping a module where i have a field named "user_id" in this field i would like to fill lit automatically by the name of the current user, exactly like it's done in crm.lead module with the field vendor. I know a function named default_user_get is defined but i don't know in what module?. Thanks for your answers

0
Avatar
Abbandona
daouda
Autore

waiting for someone else answer

Avatar
Saloua ELKHOUFAIRI
Risposta migliore

Thank you Mike a lot your solution helps me a lot :)

0
Avatar
Abbandona
Avatar
patrick
Risposta migliore

Check the file addons\crm\crm_lead_view.xml. There you find the screen definition for the LEADS screen.

The field which is filled with the user logged in, is called "user_id". It looks like it is automatically filled with the content / name of the user with ID = uid (uid is a variable which is always needed in every call to a method within openERP. It is the User ID, hence uid). In order to fill it, you might have to copy uid from the call of the method/function to that field.

<update> In the file addons/base_status/base_state.py there is a method _get_default_user defined

#def _get_default_user(self, cr, uid, context=None):

""" Gives current user id

   :param context: if portal not in context returns False

"""
if context is None:
    context = {}
if not context or not context.get('portal'):
    return False
return uid

So as I said before, it is just using the given uid.

Conclusion: If you need to store the user, use uid from the input.

0
Avatar
Abbandona
daouda
Autore

Ok I see it. But what i really want is in addons/crm/crm_lead.py. If you look the defaults definition you'ill see " 'user_id': lambda s, cr, uid, c: s._get_default_user(cr, uid, c), it's the _get_default_user that i wanna see it's definition

daouda
Autore

yes i See it but i get the whole list of ids of all the users and i want only the current user id

patrick

Douada, you mean if you the following, you get all the users? my_field = uid

daouda
Autore

i didn't do my_field = uid. I did my_field = lambda s, cr, uid, c: s._get_default_user(cr, uid, c),, because i copied the _get_default_user function

Avatar
Mike Telahun
Risposta migliore

To use the currently logged in user's id as a default value you don't need the specific function in crm/crm_lead.py. You can use a simple lambda function:

_defaults = {
    'my_field': lambda s, cr, uid, c: uid,
}

If you need to do any special processing (like in crm/crm_lead.py) you can use a function:

def _get_my_field(self, cr, uid, context=None):
    if ...:
        ....
        return uid
    else:
        ...
        return False

_defaults = {
    'my_field': _get_my_field,
}

If you really need to use the base_stage mixin, then you have to import it into you module and inherit from it in your class:

from openerp.addons.base_status.base_stage import base_stage

class my_class(base_stage, osv.Model):
    ...
    ...
    _defaults = {
        'my_field': lambda s, cr, uid, c: s._get_default_user(cr, uid, c),
    }
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à
How do I import my contacts in OpenERP? Risolto
crm v7
Avatar
Avatar
Avatar
3
feb 25
27155
problem in installing crm_claim_ext
crm v7
Avatar
0
mag 15
4486
how to force user to fill fields on every stage of opportunity in openerp 7.0
crm v7
Avatar
Avatar
1
mar 15
5568
CRM in offline mode? Risolto
crm v7 offline
Avatar
Avatar
Avatar
Avatar
Avatar
4
ago 23
21801
How can i set team sales permissions in CRM?
crm domain v7
Avatar
Avatar
Avatar
Avatar
Avatar
5
set 22
12749
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