#odoodaysit - 16) Pedro M. R. Baeza - OpenUpgrade

Odoo Days Italia 2021 / slide

220 visualizzazioni
0 Mi piace
0 0

Condividi sui social Networks

Condividi Link

Usare un link permanente per condividere sui social media

Condividi con un amico

Cortesemente login per inviare questo presentation per email !

Inserisci nel tuo sito web

Seleziona pagina dalla quale partire

1. A brief overview on the community upgrading system: OpenUpgrade Pedro M. Baeza

21. Odoo Days Italia 2021 Thanks for your attention

3. Why upgrades are needed? - It’s not a conspiracy by Odoo S. A. for making you paying the enterprise. - But it’s sometimes a lack of prevision on data model. - Other times is simply that for innovating, you have to break some things. - Data structures and content need to be adapted to the new business code. - The goal is to continue working with the new version seamlessly. Odoo Days Italia 2021 A brief view on OpenUpgrade

6. The Odoo migration machinery - In Odoo itself, there’s also a migration engine that is used by both Odoo enterprise service, OpenUpgrade, and upgrades in the middle of the version. - It allows to execute code when a different version in the manifest file is detected while doing a module update, providing you a database cursor, and the version where you come from. Odoo Days Italia 2021 A brief view on OpenUpgrade

8. What is the OpenUpgrade project? It’s a collection of: - Tools - Patches - Scripts whose goal is the migration from one major version to another. Odoo Days Italia 2021 A brief view on OpenUpgrade

10. Tools of the OpenUpgrade project: openupgrade_analysis (2) How it works? - The module is installed in version N – 1. - The module is installed in version N. - Through OdooRPC library, Odoo version N communicates with Odoo N – 1 and deduces the differences, dumping them into a file. Odoo Days Italia 2021 A brief view on OpenUpgrade

19. FAQ – When migrating from version 8 to version 13, can it be done in one step? - No, you have to make the migration for each intermediate version. - But you don't have to migrate custom modules to each version, only the target one. - Include in the intermediate versions, all the existing OCA modules. Odoo Days Italia 2021 A brief view on OpenUpgrade

4. Why upgrades are needed? (2) What can be argued to Odoo S. A.? To not always fully implement data structures for a single feature. Example: when they implemented the reversal of a move, no “hard” link between the reversed move and the original one was done, so the only way to perform the link when it finally comes, was through the name of the move “Reversal of ...” (with the consequent multi-language problems). Odoo Days Italia 2021 A brief view on OpenUpgrade

14. Patches of the OpenUpgrade project: openupgrade_framework - Previous to v14, these patches were provided through a whole copy of Odoo, and modifying what needed in it. - Now, it’s bundled as a module that must be loaded as server wide module. - Hosted at https://github.com/OCA/OpenUpgrade/tree/14.0/openupgrade_framework Odoo Days Italia 2021 A brief view on OpenUpgrade

20. FAQ – If not all the modules scripts are ready, can I migrate? - In the best case, the module may not contain any DB structural or behavioral change, so no problem on migrating. - On an intermediate case, these changes doesn’t crash the migration process, but data are not fully as expected, and later problems may arise. - On the worst case, the migration will crash, as the expected changes don’t happen and this provokes a subsequent problem. Odoo Days Italia 2021 A brief view on OpenUpgrade

5. The Odoo update machinery - Odoo framework incorporates a mechanism for reflecting the changes in code in the DB layout (for example, adding a new field that adds a column). - This mechanism is triggered when you update (also called upgrade) a module, both on UI (on Apps menu), or by command line (with -u/--update <module> ). - All modules depending on the updated one will be updated as well. Odoo Days Italia 2021 A brief view on OpenUpgrade

12. Tools of the OpenUpgrade project: openupgradelib - It’s a Python library for having common methods to ease you on the usual transformations needed on migrations. - Hosted at https://github.com/OCA/openupgradelib . - At the beginning, all was part of the same “bundle”, but it was extracted for being used in other places, like in middle-version upgrades. Odoo Days Italia 2021 A brief view on OpenUpgrade

16. Tools of the OpenUpgrade project: scripts - This is the code that is going to be executed while doing the update. - It’s mostly deduced from the upgrade_analysis.txt file obtained by the tool. - But it also requires functional knowledge on version N and N – 1. - It’s what takes most of the time when performing the “OpenUpgrade” stuff for a specific version. Odoo Days Italia 2021 A brief view on OpenUpgrade

2. “ More recently, we have seen another kind of dependence in database programs, where you can build and run any given version of the program in the free world, but upgrading from version N to version N+1 requires a nonfree program. ... When a program is diachronically trapped, releasing it from the trap requires more than a one-time job of programming.” FSF statement https://www.gnu.org/philosophy/when-free-depends-on-nonfree.en.html Odoo Days Italia 2021 A brief view on OpenUpgrade

17. Tools of the OpenUpgrade project: scripts (2) - They follow the structure of the migration machinery. The version number for the folder is the current version in the manifest of Odoo version N. - upgrade_analysis tool prepares this structure for you. - They were needed to be inside the same module folder in the past, but not now thanks to the -- upgrade-path argument. Odoo Days Italia 2021 A brief view on OpenUpgrade

9. Tools of the OpenUpgrade project: upgrade_analysis - Called openupgrade_records before 14.0. - It’s an Odoo module, currently hosted at htps://github.com/OCA/server-tools - Its aim is to log the differences in the data structure between the database in version N and in version N-1. - It produces the famous upgrade_analysis.txt (and noupdate_changes.xml ) files. Odoo Days Italia 2021 A brief view on OpenUpgrade

13. Tools of the OpenUpgrade project: openupgradelib (2) Examples of openupgradelib methods: - rename_fields : For renaming a field from name A to name B, involving the DB column, but also export profiles, favorites, etc involving this field (simple cases). - m2o_to_x2m : Perform the needed transformations for converting a many2one field to many2many/one2many. - merge_records : Method for merging several records together, and taking care of the rest of references and merged values. Odoo Days Italia 2021 A brief view on OpenUpgrade

15. Patches of the OpenUpgrade project: openupgrade_framework (2) - It performs several changes over normal Odoo behavior for a more convenient upgrade: * Don’t drop columns or tables in the DB. * Don’t crash on views errors. * Silent several unconvenient logs. * Recursive update for newly discovered dependencies. * Commit after each module update completion. * ... Odoo Days Italia 2021 A brief view on OpenUpgrade

11. Tools of the OpenUpgrade project: openupgrade_analysis (3) Example of upgrade_analysis.txt: account / account.account / _order : _order is now 'is_off_balance, code, company_id' ('code') account / account.account / allowed_journal_ids (many2many): NEW relation: account.journal account / account.account / group_id (many2one) : now a function account / account.account / is_off_balance (boolean) : NEW hasdefault, isfunction: function, stored account / account.account.template / group_id (many2one) : DEL relation: account.group account / account.account.template / root_id (many2one) : DEL relation: account.root account / account.bank.statement / _order : _order is now 'date desc, name desc, id desc' ('date desc, id desc') account / account.bank.statement / accounting_date (date) : DEL account / account.bank.statement / balance_end_real (float) : now a function account / account.bank.statement / balance_start (float) : now a function account / account.bank.statement / is_valid_balance_start (boolean): NEW isfunction: function, stored account / account.bank.statement / sequence_number (integer) : NEW isfunction: function, stored account / account.bank.statement / sequence_prefix (char) : NEW isfunction: function, stored Odoo Days Italia 2021 A brief view on OpenUpgrade

7. The Odoo migration machinery (2) - Folder structure (inside the module): migrations |- 14.0.1.0.0 ( target version) |- pre-....py – To be executed before updating the module |- post-....py – To be executed right after updating the module |- end-....py – To be executed at the end of the whole upgrade process Odoo Days Italia 2021 A brief view on OpenUpgrade

18. Tools of the OpenUpgrade project: scripts (3) Example of script: _column_copies = { 'res_company' : [( 'fiscalyear_last_month' , None , None )] } _column_renames = { 'account_move_line' : [( 'user_type_id' , None )] } _field_renames = [( 'account.move' , 'account_move' , 'amount' , 'amount_total' ) ] @ openupgrade .migrate () def migrate ( env , version ): openupgrade . copy_columns ( env. cr, _column_copies ) openupgrade . rename_columns ( env. cr, _column_renames ) openupgrade . rename_fields ( env , _field_renames ) if openupgrade . table_exists ( env. cr, 'sale_order' ): .... Odoo Days Italia 2021 A brief view on OpenUpgrade Decorator from openupgradelib for providing directly an Odoo environment

Viste

  • 220 Visite totali
  • 176 Website Visite
  • 44 Embedded Views

Azioni

  • 0 Condivisioni social
  • 0 Mi piace
  • 0 Non mi piace
  • 0 Commentis

Condividi conti

  • 0 Facebook
  • 0 Twitter
  • 0 LinkedIn
  • 0 Google+