Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

Differences in Create Method Between Neutralized and Live Databases

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
1 Відповісти
773 Переглядів
Аватар
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
Аватар
Відмінити
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.

Аватар
Cybrosys Techno Solutions Pvt.Ltd
Найкраща відповідь

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
Аватар
Відмінити
Enjoying the discussion? Don't just read, join in!

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

Реєстрація
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

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