跳至內容
選單
此問題已被標幟
4 回覆
325 瀏覽次數

Dear Odoo Community,

We are currently implementing a CRM (and potentially a Helpdesk) for one of our clients. Security is a key requirement, so we are setting up development, staging, and production environments.

I’m happy to share that we've successfully created our first project in Odoo SH, made the first commits to the repository, and everything is running smoothly. I must say, Odoo SH is a powerful tool and I truly appreciate how it streamlines deployment and environment management so far.

That said, I do have a question regarding best practices for promoting changes across environments:

  • The GitHub repository linked to Odoo SH only tracks the files in the repo. As far as I understand, standard Odoo apps are installed and stored in the database rather than being tracked in GitHub.
  • When I install new apps, change system settings, or make configuration updates in staging, I would like these changes to be properly promoted to the production branch.
  • Additionally, our client plans to use Odoo Studio to add custom fields and make small adjustments in staging or dev. We also want to ensure those Studio changes are safely moved to production.

What is the correct way to handle this in Odoo SH? Are there recommended workflows or resources that explain how to properly promote database-level changes and Odoo Studio customizations across environments?

Any guidance, references, or shared experiences would be greatly appreciated.

Thanks in advance

頭像
捨棄
最佳答案

Hi,

In Odoo SH, Git manages all code in your repository, but database-level changes like installed apps, system settings, and Studio customizations are not tracked in Git. This means promoting changes across development, staging, and production requires different approaches depending on the type of change.

For database-level updates, Odoo SH allows you to create a backup of an environment and restore it into another one. This is useful for moving apps and configurations from staging to another environment. However, in production, you generally don’t overwrite the database, since it already contains live data. Instead, you replicate the same steps manually or bundle configurations into proper modules for deployment.

Studio customizations need special attention because they are stored in the database by default. The recommended practice is to export them as modules through Studio and then commit them to the Git repository. This ensures they are versioned, tested, and deployable like any other module, reducing risks of inconsistencies between environments.

A good workflow is to use development for trying new apps and customizations, staging for testing with realistic data, and production only for changes that are managed through Git and exported modules. For configurations that cannot be packaged in modules, apply them carefully in production. This approach keeps your environments consistent and makes deployments more reliable.


Hope it helps

頭像
捨棄
作者

this is super helpful, thanks

作者

As a follow up question, when you say: "The recommended practice is to export them as modules through Studio and then commit them to the Git repository" do you mean exporting the .zip file, extracting and adding the contents to the git repo or something else?

作者

I found this video (also from your company, nice!), but this is a simple export - import. https://www.youtube.com/watch?v=Q3dyGb6uj2o

最佳答案

I do it by scripting what is changed / configured in the staging database, so I can re-run the script in Production.

https://www.odoo.com/forum/help-1/easy-way-to-transfer-settings-from-one-database-to-another-can-i-export-them-can-i-programmatically-configure-a-database-184325


Odoo Studio is designed for a single User making relatively simple changes.

Odoo.sh is designed for a team of developers working as a team making complex changes.

Ideally you pick one or the other - so Odoo Studio is not install in most Odoo implemented databases hosted on Odoo.sh.


Odoo Studio changes can be exported and imported between databases - but test this first to ensure the export supports everything you need.

https://www.odoo.com/documentation/master/applications/studio/models_modules_apps.html#export-and-import-customizations

頭像
捨棄
作者

Thanks for the input Ray, much appreciated. Yesterday I indeed got export-import to work. However it feels a bit clunky. Coming from a Python background I would like to see Studio just modify some sort of configuration file. And the configuration file is tracked in the repo. Upon push, Odoo would use the configuration file in the build.

作者

OK in addition to this post I contacted Odoo Support and they referred to multiple of your sources, great. The lady in customer support mentioned that the best practice is to make this database schema changes and settings changes still manually in the production environment. I guess that's fine for now. It bothers me that I cannot get the database in a state using a script, the same way a dockerfile works for a container. Anyway, maybe Odoo could consider adding these best practices to the documentation.

Modules can run code the first time they are installed. You can see how we do this by reviewing the source code of the base module at https://github.com/odoo/odoo/blob/19.0/odoo/addons/base/__init__.py

post_init_hook(cr): This hook runs after the module is installed or upgraded, specifically after the database structure changes are applied. This is the hook used to run logic (like data migration or cleanup) every time a module is upgraded or freshly installed.

作者

very helpful, thanks. I got PGAdmin to work on a local docker instance of Odoo to better understand the database model. very insightful to understand Odoo's inner workings. For now I will keep things simple and just use a bunch of backups, rebuilds etc.

Just be aware up to 30% of the data in any given Odoo database is not persisted in PostgreSQL (calculated/computed fields). Look for Fields in the Odoo Fields Menu (Developer Mode) that are not stored.

最佳答案

Hello Rutger,



It's great to hear you're leveraging Odoo.sh for your CRM and Helpdesk implementation! Promoting changes across environments requires careful handling of both code and database configurations.



  Apps and Modules: Standard Odoo apps are indeed installed at the database level. To promote these, you generally don't track them in Git directly. Instead, the installation status is managed within the database itself.

  Configuration and Settings: System settings and configuration updates made in staging should be exported as data files (e.g., using Odoo's data export feature). These files can then be imported into your production environment.

  Odoo Studio Customizations: Odoo Studio customizations are also stored in the database. The recommended approach is to export these customizations as a Studio patch. This patch can then be applied to your production environment. This ensures that your custom fields and adjustments are safely moved.

  Workflow: A typical workflow involves making changes in your development or staging environment, exporting the relevant data (settings, Studio customizations), and then importing this data into your production environment after testing.

  Important Note: Always back up your production database before importing any changes to prevent data loss.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

頭像
捨棄
最佳答案

Hello Rutger,



It's great to hear you're leveraging Odoo.sh for your CRM and Helpdesk implementation! Promoting changes across environments requires careful handling of both code and database elements.


Here's a breakdown of how to manage apps, settings, and Studio customizations:


  Apps and System Settings:

  Odoo apps and system settings are stored in the database. To move these changes, you'll need to update the production database with the changes from staging.

  Database Synchronization:

  The recommended approach is to create a backup of your staging database and restore it to your production environment. Be aware that this will overwrite the existing production data, so plan accordingly.

  Odoo Studio Customizations:

  Odoo Studio customizations are also stored in the database. When you transfer the staging database to production, these customizations will be included.

  Workflow:

  1. Make changes and customizations in your development or staging environment.

  2. Test thoroughly in staging.

  3. Create a backup of the staging database.

  4. Restore the staging database backup to your production environment.

  Important Considerations:

  Always test database migrations in a safe environment before applying them to production.

  Consider the impact on existing data when restoring a database backup.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

頭像
捨棄
作者

thank you for the response. What I notice is the difference in approach between you and @Cyrbosys. Cybrosis does not replace the production database with a staging database backup but you do. Any thoughts on that? What if changes are made to the data in production during the overwrite?

相關帖文 回覆 瀏覽次數 活動
2
3月 25
7082
1
10月 24
2081
2
10月 24
3410
0
5月 25
3046
1
7月 24
2684