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

Differences in Create Method Between Neutralized and Live Databases

Iscriviti

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

La domanda è stata contrassegnata
1 Rispondi
767 Visualizzazioni
Avatar
Luis Garcia

Hi all,

I noticed something a bit curious after shipping a new feature on a customized Odoo 18 instance on Odoo.sh. We built a custom integration with a service, and part of our implementation involved overriding the create​ and write​ methods in the res.partner​ model to make calls to the service (see the example code below).

  def create(self, vals):

    '''

      Override account creation so that a brivo user is

      created along with this user.

    '''

    res = super().create(vals)

    res._create_brivo_user()

    return res


  def write(self, vals):

    '''

      Override account editing so that the brivo user

      is edited along with this user.

    '''

    res = super().write(vals)

    # Update or create the brivo user on write if the user is active

    if not self.env.context.get('skip_brivo_call_on_write', False) and self.active:  

      if self.brivo_id:

        brivo_update_user(self.env, self)

      else:

        self._create_brivo_user()

    # If the user's barcode was updated,

    # update the Brivo user's credential

    if not self.env.context.get('skip_brivo_call_on_write', False) and vals.get('barcode') and self:

      self._update_user_barcode_credential()

    return res

So, when we call create​, we create a corresponding user on the service (Brivo). We then use the context to avoid making extra calls in write​ because we understand that there's an automatic call to it that's made after the call to create​.

This flow worked perfectly fine on a local (neutralized) copy of our database. However, when we tested it in a production database, we were unable to create new contacts on Odoo. Inspecting the logs, I noticed that there were extra, unexpected calls being made to the Brivo service that were causing creation to fail. After a bit of digging, I realized that the write​ method was being called before the new contact record was being written to the database. We fixed the issue by removing our create​ override.

I expected the flow to be like this: create​, then write to database, then write​. This seemed to be how it worked in the local copy of the database. That doesn't seem to be the case in the production copy.

What are the differences in the create/write lifecycle between a production and a neutralized database, if any?

0
Avatar
Abbandona
Ray Carnes (ray)

Neutralized databases are just "cut off" from integrations such as bank feeds, shipping, email - things that allow them to "contact the outside world".

Think of CREATE as a database SQL INSERT and WRITE as a database SQL UPDATE.

WRITE is not part of CREATE nor is it called before or after it - it is a separate call. Something else is going on.

Ray Carnes (ray)

What may be happening is that your CREATE call is providing data for a field that is used as a dependency for a class method that provides the value for another field, so WRITE is called after your call because of this.

Creating a new res.partner with a value for parent_id will trigger a write to compute the value of commercial_partner_id.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Risposta migliore

Hi,


In Odoo, the lifecycle is always the same: create() writes the new record to the database and then returns a recordset; write() is only called explicitly, not as part of create().


If you saw write() being triggered after create() in your local environment, it was likely due to default values, Studio customizations, or another module calling write() right after creation.


A “neutralized” (sanitized) copy of a database doesn’t behave differently at ORM level, but it may have fewer modules, fewer records, or missing automation, which explains why the extra write() never appeared.


In production, you may have additional modules, server actions, automated fields, or integrations that explicitly trigger a write() right after create().


Many standard Odoo features update records immediately after creation (e.g. assigning sequences, computing related fields, creating followers), which results in extra write() calls.


That’s why overriding both create() and write() with external API calls is risky — you can end up with duplicate or premature calls.


A safer pattern is to keep the API call logic in a dedicated method and trigger it via @api.model_create_multi, @api.onchange, or via a post-commit hook depending on your needs.


In short: the ORM lifecycle is identical across environments; the difference is the extra automation/customizations present in production that trigger write() calls you didn’t see locally.


Hope it helps.

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
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